com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport

Here are the examples of the java api class com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport taken from open source projects.

1. XSDHandler#findQName()

Project: openjdk
Source File: XSDHandler.java
View license
// renameRedefiningComponents(XSDocumentInfo, Element, String, String, String):void
// this method takes a name of the form a:b, determines the URI mapped
// to by a in the current SchemaNamespaceSupport object, and returns this
// information in the form (nsURI,b) suitable for lookups in the global
// decl maps.
// REVISIT: should have it return QName, instead of String. this would
//          save lots of string concatenation time. we can use
//          QName#equals() to compare two QNames, and use QName directly
//          as a key to the SymbolHash.
//          And when the DV's are ready to return compiled values from
//          validate() method, we should just call QNameDV.validate()
//          in this method.
private String findQName(String name, XSDocumentInfo schemaDoc) {
    SchemaNamespaceSupport currNSMap = schemaDoc.fNamespaceSupport;
    int colonPtr = name.indexOf(':');
    String prefix = XMLSymbols.EMPTY_STRING;
    if (colonPtr > 0)
        prefix = name.substring(0, colonPtr);
    String uri = currNSMap.getURI(fSymbolTable.addSymbol(prefix));
    String localpart = (colonPtr == 0) ? name : name.substring(colonPtr + 1);
    if (prefix == XMLSymbols.EMPTY_STRING && uri == null && schemaDoc.fIsChameleonSchema)
        uri = schemaDoc.fTargetNamespace;
    if (uri == null)
        return "," + localpart;
    return uri + "," + localpart;
}

2. XSDHandler#traverseGlobalDecl()

Project: openjdk
Source File: XSDHandler.java
View license
protected Object traverseGlobalDecl(int declType, Element decl, XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
    Object retObj = null;
    DOMUtil.setHidden(decl, fHiddenNodes);
    SchemaNamespaceSupport nsSupport = null;
    // if the parent is <redefine> use the namespace delcs for it.
    Element parent = DOMUtil.getParent(decl);
    if (DOMUtil.getLocalName(parent).equals(SchemaSymbols.ELT_REDEFINE))
        nsSupport = (fRedefine2NSSupport != null) ? (SchemaNamespaceSupport) fRedefine2NSSupport.get(parent) : null;
    // back up the current SchemaNamespaceSupport, because we need to provide
    // a fresh one to the traverseGlobal methods.
    schemaDoc.backupNSSupport(nsSupport);
    // traverse the referenced global component
    switch(declType) {
        case TYPEDECL_TYPE:
            if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
                retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
            } else {
                retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
            }
            break;
        case ATTRIBUTE_TYPE:
            retObj = fAttributeTraverser.traverseGlobal(decl, schemaDoc, grammar);
            break;
        case ELEMENT_TYPE:
            retObj = fElementTraverser.traverseGlobal(decl, schemaDoc, grammar);
            break;
        case ATTRIBUTEGROUP_TYPE:
            retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
            break;
        case GROUP_TYPE:
            retObj = fGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
            break;
        case NOTATION_TYPE:
            retObj = fNotationTraverser.traverse(decl, schemaDoc, grammar);
            break;
        case IDENTITYCONSTRAINT_TYPE:
            // we should never get here
            break;
    }
    // restore the previous SchemaNamespaceSupport, so that the caller can get
    // proper namespace binding.
    schemaDoc.restoreNSSupport();
    return retObj;
}

3. XSDocumentInfo#initNamespaceSupport()

Project: openjdk
Source File: XSDocumentInfo.java
View license
/**
     * Initialize namespace support by collecting all of the namespace
     * declarations in the root's ancestors. This is necessary to
     * support schemas fragments, i.e. schemas embedded in other
     * documents. See,
     *
     * https://jaxp.dev.java.net/issues/show_bug.cgi?id=43
     *
     * Requires the DOM to be created with namespace support enabled.
     */
private void initNamespaceSupport(Element schemaRoot) {
    fNamespaceSupport = new SchemaNamespaceSupport();
    fNamespaceSupport.reset();
    Node parent = schemaRoot.getParentNode();
    while (parent != null && parent.getNodeType() == Node.ELEMENT_NODE && !parent.getNodeName().equals("DOCUMENT_NODE")) {
        Element eparent = (Element) parent;
        NamedNodeMap map = eparent.getAttributes();
        int length = (map != null) ? map.getLength() : 0;
        for (int i = 0; i < length; i++) {
            Attr attr = (Attr) map.item(i);
            String uri = attr.getNamespaceURI();
            // Check if attribute is an ns decl -- requires ns support
            if (uri != null && uri.equals("http://www.w3.org/2000/xmlns/")) {
                String prefix = attr.getLocalName().intern();
                if (prefix == "xmlns")
                    prefix = "";
                // Declare prefix if not set -- moving upwards
                if (fNamespaceSupport.getURI(prefix) == null) {
                    fNamespaceSupport.declarePrefix(prefix, attr.getValue().intern());
                }
            }
        }
        parent = parent.getParentNode();
    }
}

4. XSDocumentInfo#backupNSSupport()

Project: openjdk
Source File: XSDocumentInfo.java
View license
// backup the current ns support, and use the one passed-in.
// if no ns support is passed-in, use the one for <schema> element
void backupNSSupport(SchemaNamespaceSupport nsSupport) {
    SchemaNamespaceSupportStack.push(fNamespaceSupport);
    if (nsSupport == null)
        nsSupport = fNamespaceSupportRoot;
    fNamespaceSupport = new SchemaNamespaceSupport(nsSupport);
    fValidationContext.setNamespaceSupport(fNamespaceSupport);
}