FileDocCategorySizeDatePackage
XSDocumentInfo.javaAPI DocApache Xerces 3.0.18167Fri Sep 14 20:33:52 BST 2007org.apache.xerces.impl.xs.traversers

XSDocumentInfo

public class XSDocumentInfo extends Object
Objects of this class hold all information pecular to a particular XML Schema document. This is needed because namespace bindings and other settings on the element affect the contents of that schema document alone.
xerces.internal
author
Neil Graham, IBM
version
$Id: XSDocumentInfo.java 446725 2006-09-15 20:40:10Z mrglavas $

Fields Summary
protected org.apache.xerces.impl.xs.SchemaNamespaceSupport
fNamespaceSupport
protected org.apache.xerces.impl.xs.SchemaNamespaceSupport
fNamespaceSupportRoot
protected Stack
SchemaNamespaceSupportStack
protected boolean
fAreLocalAttributesQualified
protected boolean
fAreLocalElementsQualified
protected short
fBlockDefault
protected short
fFinalDefault
String
fTargetNamespace
protected boolean
fIsChameleonSchema
protected Element
fSchemaElement
Vector
fImportedNS
protected org.apache.xerces.impl.validation.ValidationState
fValidationContext
org.apache.xerces.util.SymbolTable
fSymbolTable
protected XSAttributeChecker
fAttrChecker
protected Object[]
fSchemaAttrs
protected XSAnnotationInfo
fAnnotations
private Vector
fReportedTNS
Constructors Summary
XSDocumentInfo(Element schemaRoot, XSAttributeChecker attrChecker, org.apache.xerces.util.SymbolTable symbolTable)


    // note that the caller must ensure to call returnSchemaAttrs()
    // to avoid memory leaks!
          
                      
        
        fSchemaElement = schemaRoot;
        fNamespaceSupport = new SchemaNamespaceSupport(schemaRoot, symbolTable);
        fNamespaceSupport.reset();
        fIsChameleonSchema = false;

        fSymbolTable = symbolTable;
        fAttrChecker = attrChecker;

        if (schemaRoot != null) {
            Element root = schemaRoot;
            fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
            // schemaAttrs == null means it's not an <xsd:schema> element
            // throw an exception, but we don't know the document systemId,
            // so we leave that to the caller.
            if (fSchemaAttrs == null) {
                throw new XMLSchemaException(null, null);
            }
            fAreLocalAttributesQualified =
                ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
            fAreLocalElementsQualified =
                ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
            fBlockDefault =
                ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
            fFinalDefault =
                ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
            fTargetNamespace =
                (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
            if (fTargetNamespace != null)
                fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

            fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

            //set namespace support
            fValidationContext.setNamespaceSupport(fNamespaceSupport);
            fValidationContext.setSymbolTable(symbolTable);
            // pass null as the schema document, so that the namespace
            // context is not popped.

            // don't return the attribute array yet!
            //attrChecker.returnAttrArray(schemaAttrs, null);
        }
    
Methods Summary
public voidaddAllowedNS(java.lang.String namespace)

        fImportedNS.addElement(namespace == null ? "" : namespace);
    
voidaddAnnotation(XSAnnotationInfo info)

        info.next = fAnnotations;
        fAnnotations = info;
    
voidbackupNSSupport(org.apache.xerces.impl.xs.SchemaNamespaceSupport nsSupport)

        SchemaNamespaceSupportStack.push(fNamespaceSupport);
        if (nsSupport == null)
            nsSupport = fNamespaceSupportRoot;
        fNamespaceSupport = new SchemaNamespaceSupport(nsSupport);

        fValidationContext.setNamespaceSupport(fNamespaceSupport);
    
XSAnnotationInfogetAnnotations()

        return fAnnotations;
    
java.lang.Object[]getSchemaAttrs()

        return fSchemaAttrs;
    
public booleanisAllowedNS(java.lang.String namespace)

        return fImportedNS.contains(namespace == null ? "" : namespace);
    
final booleanneedReportTNSError(java.lang.String uri)

    // check whether we need to report an error against the given uri.
    // if we have reported an error, then we don't need to report again;
    // otherwise we reported the error, and remember this fact.
        
        if (fReportedTNS == null)
            fReportedTNS = new Vector();
        else if (fReportedTNS.contains(uri))
            return false;
        fReportedTNS.addElement(uri);
        return true;
    
voidremoveAnnotations()

        fAnnotations = null;
    
voidrestoreNSSupport()

        fNamespaceSupport = (SchemaNamespaceSupport)SchemaNamespaceSupportStack.pop();
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
    
voidreturnSchemaAttrs()

        fAttrChecker.returnAttrArray (fSchemaAttrs, null);
        fSchemaAttrs = null;
    
public java.lang.StringtoString()

        return fTargetNamespace == null?"no targetNamspace":"targetNamespace is " + fTargetNamespace;