Java Code Examples for com.sun.org.apache.xerces.internal.xni.NamespaceContext#XMLNS_URI

The following examples show how to use com.sun.org.apache.xerces.internal.xni.NamespaceContext#XMLNS_URI . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NamespaceSupport.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see com.sun.org.apache.xerces.internal.xni.NamespaceContext#reset()
 */
public void reset() {

    // reset namespace and context info
    fNamespaceSize = 0;
    fCurrentContext = 0;


    // bind "xml" prefix to the XML uri
    fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XML;
    fNamespace[fNamespaceSize++] = NamespaceContext.XML_URI;
    // bind "xmlns" prefix to the XMLNS uri
    fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS;
    fNamespace[fNamespaceSize++] = NamespaceContext.XMLNS_URI;

    fContext[fCurrentContext] = fNamespaceSize;
    //++fCurrentContext;

}
 
Example 2
Source File: MultipleScopeNamespaceSupport.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public String getPrefix(String uri, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (uri == NamespaceContext.XML_URI) {
        return XMLSymbols.PREFIX_XML;
    }
    if (uri == NamespaceContext.XMLNS_URI) {
        return XMLSymbols.PREFIX_XMLNS;
    }

    // find uri in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 1] == uri) {
            if (getURI(fNamespace[i - 2]) == uri)
                return fNamespace[i - 2];
        }
    }

    // uri not found
    return null;
}
 
Example 3
Source File: NamespaceSupport.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see com.sun.org.apache.xerces.internal.xni.NamespaceContext#reset()
 */
public void reset() {

    // reset namespace and context info
    fNamespaceSize = 0;
    fCurrentContext = 0;


    // bind "xml" prefix to the XML uri
    fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XML;
    fNamespace[fNamespaceSize++] = NamespaceContext.XML_URI;
    // bind "xmlns" prefix to the XMLNS uri
    fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS;
    fNamespace[fNamespaceSize++] = NamespaceContext.XMLNS_URI;

    fContext[fCurrentContext] = fNamespaceSize;
    //++fCurrentContext;

}
 
Example 4
Source File: MultipleScopeNamespaceSupport.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public String getPrefix(String uri, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (uri == NamespaceContext.XML_URI) {
        return XMLSymbols.PREFIX_XML;
    }
    if (uri == NamespaceContext.XMLNS_URI) {
        return XMLSymbols.PREFIX_XMLNS;
    }

    // find uri in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 1] == uri) {
            if (getURI(fNamespace[i - 2]) == uri)
                return fNamespace[i - 2];
        }
    }

    // uri not found
    return null;
}
 
Example 5
Source File: MultipleScopeNamespaceSupport.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public String getPrefix(String uri, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (uri == NamespaceContext.XML_URI) {
        return XMLSymbols.PREFIX_XML;
    }
    if (uri == NamespaceContext.XMLNS_URI) {
        return XMLSymbols.PREFIX_XMLNS;
    }

    // find uri in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 1] == uri) {
            if (getURI(fNamespace[i - 2]) == uri)
                return fNamespace[i - 2];
        }
    }

    // uri not found
    return null;
}
 
Example 6
Source File: MultipleScopeNamespaceSupport.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public String getPrefix(String uri, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (uri == NamespaceContext.XML_URI) {
        return XMLSymbols.PREFIX_XML;
    }
    if (uri == NamespaceContext.XMLNS_URI) {
        return XMLSymbols.PREFIX_XMLNS;
    }

    // find uri in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 1] == uri) {
            if (getURI(fNamespace[i - 2]) == uri)
                return fNamespace[i - 2];
        }
    }

    // uri not found
    return null;
}
 
Example 7
Source File: NamespaceSupport.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * @see com.sun.org.apache.xerces.internal.xni.NamespaceContext#reset()
 */
public void reset() {

    // reset namespace and context info
    fNamespaceSize = 0;
    fCurrentContext = 0;


    // bind "xml" prefix to the XML uri
    fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XML;
    fNamespace[fNamespaceSize++] = NamespaceContext.XML_URI;
    // bind "xmlns" prefix to the XMLNS uri
    fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS;
    fNamespace[fNamespaceSize++] = NamespaceContext.XMLNS_URI;

    fContext[fCurrentContext] = fNamespaceSize;
    //++fCurrentContext;

}
 
Example 8
Source File: MultipleScopeNamespaceSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public String getURI(String prefix, int start, int end) {
    // this saves us from having a copy of each of these in fNamespace for each scope
    if (prefix == XMLSymbols.PREFIX_XML) {
        return NamespaceContext.XML_URI;
    }
    if (prefix == XMLSymbols.PREFIX_XMLNS) {
        return NamespaceContext.XMLNS_URI;
    }

    // find prefix in current context
    for (int i = start; i > end; i -= 2) {
        if (fNamespace[i - 2] == prefix) {
            return fNamespace[i - 1];
        }
    }

    // prefix not found
    return null;
}
 
Example 9
Source File: DOMValidatorHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void fillNamespaceContext() {
    if (fRoot != null) {
        Node currentNode = fRoot.getParentNode();
        while (currentNode != null) {
            if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
                NamedNodeMap attributes = currentNode.getAttributes();
                final int attrCount = attributes.getLength();
                for (int i = 0; i < attrCount; ++i) {
                    Attr attr = (Attr) attributes.item(i);
                    String value = attr.getValue();
                    if (value == null) {
                        value = XMLSymbols.EMPTY_STRING;
                    }
                    fillQName(fAttributeQName, attr);
                    // REVISIT: Should we be looking at non-namespace attributes
                    // for additional mappings? Should we detect illegal namespace
                    // declarations and exclude them from the context? -- mrglavas
                    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
                        // process namespace attribute
                        if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                            declarePrefix0(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                        else {
                            declarePrefix0(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                    }
                }

            }
            currentNode = currentNode.getParentNode();
        }
    }
}
 
Example 10
Source File: SchemaDOMParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: SchemaDOMParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 12
Source File: SchemaDOMParser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 13
Source File: DOMValidatorHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void processAttributes(NamedNodeMap attrMap) {
    final int attrCount = attrMap.getLength();
    fAttributes.removeAllAttributes();
    for (int i = 0; i < attrCount; ++i) {
        Attr attr = (Attr) attrMap.item(i);
        String value = attr.getValue();
        if (value == null) {
            value = XMLSymbols.EMPTY_STRING;
        }
        fillQName(fAttributeQName, attr);
        // REVISIT: Assuming all attributes are of type CDATA. The actual type may not matter. -- mrglavas
        fAttributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, value);
        fAttributes.setSpecified(i, attr.getSpecified());
        // REVISIT: Should we be looking at non-namespace attributes
        // for additional mappings? Should we detect illegal namespace
        // declarations and exclude them from the context? -- mrglavas
        if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
            // process namespace attribute
            if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                fNamespaceContext.declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
            else {
                fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
        }
    }
}
 
Example 14
Source File: SchemaDOMParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 15
Source File: DOMValidatorHelper.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void processAttributes(NamedNodeMap attrMap) {
    final int attrCount = attrMap.getLength();
    fAttributes.removeAllAttributes();
    for (int i = 0; i < attrCount; ++i) {
        Attr attr = (Attr) attrMap.item(i);
        String value = attr.getValue();
        if (value == null) {
            value = XMLSymbols.EMPTY_STRING;
        }
        fillQName(fAttributeQName, attr);
        // REVISIT: Assuming all attributes are of type CDATA. The actual type may not matter. -- mrglavas
        fAttributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, value);
        fAttributes.setSpecified(i, attr.getSpecified());
        // REVISIT: Should we be looking at non-namespace attributes
        // for additional mappings? Should we detect illegal namespace
        // declarations and exclude them from the context? -- mrglavas
        if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
            // process namespace attribute
            if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                fNamespaceContext.declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
            else {
                fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
        }
    }
}
 
Example 16
Source File: DOMValidatorHelper.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void fillNamespaceContext() {
    if (fRoot != null) {
        Node currentNode = fRoot.getParentNode();
        while (currentNode != null) {
            if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
                NamedNodeMap attributes = currentNode.getAttributes();
                final int attrCount = attributes.getLength();
                for (int i = 0; i < attrCount; ++i) {
                    Attr attr = (Attr) attributes.item(i);
                    String value = attr.getValue();
                    if (value == null) {
                        value = XMLSymbols.EMPTY_STRING;
                    }
                    fillQName(fAttributeQName, attr);
                    // REVISIT: Should we be looking at non-namespace attributes
                    // for additional mappings? Should we detect illegal namespace
                    // declarations and exclude them from the context? -- mrglavas
                    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
                        // process namespace attribute
                        if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                            declarePrefix0(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                        else {
                            declarePrefix0(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                    }
                }

            }
            currentNode = currentNode.getParentNode();
        }
    }
}
 
Example 17
Source File: DOMValidatorHelper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void processAttributes(NamedNodeMap attrMap) {
    final int attrCount = attrMap.getLength();
    fAttributes.removeAllAttributes();
    for (int i = 0; i < attrCount; ++i) {
        Attr attr = (Attr) attrMap.item(i);
        String value = attr.getValue();
        if (value == null) {
            value = XMLSymbols.EMPTY_STRING;
        }
        fillQName(fAttributeQName, attr);
        // REVISIT: Assuming all attributes are of type CDATA. The actual type may not matter. -- mrglavas
        fAttributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, value);
        fAttributes.setSpecified(i, attr.getSpecified());
        // REVISIT: Should we be looking at non-namespace attributes
        // for additional mappings? Should we detect illegal namespace
        // declarations and exclude them from the context? -- mrglavas
        if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
            // process namespace attribute
            if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                fNamespaceContext.declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
            else {
                fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
            }
        }
    }
}
 
Example 18
Source File: DeferredElementNSImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/** Synchronizes the data (name and value) for fast nodes. */
protected final void synchronizeData() {

    // no need to sync in the future
    needsSyncData(false);

    // fluff data
    DeferredDocumentImpl ownerDocument =
        (DeferredDocumentImpl) this.ownerDocument;

    // we don't want to generate any event for this so turn them off
    boolean orig = ownerDocument.mutationEvents;
    ownerDocument.mutationEvents = false;

    name = ownerDocument.getNodeName(fNodeIndex);

    // extract local part from QName
    int index = name.indexOf(':');
    if (index < 0) {
        localName = name;
    }
    else {
        localName = name.substring(index + 1);
    }

        namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
    type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex);

    // attributes
    setupDefaultAttributes();
    int attrIndex = ownerDocument.getNodeExtra(fNodeIndex);
    if (attrIndex != -1) {
        NamedNodeMap attrs = getAttributes();
        boolean seenSchemaDefault = false;
        do {
            AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex);
            // Take special care of schema defaulted attributes. Calling the
            // non-namespace aware setAttributeNode() method could overwrite
            // another attribute with the same local name.
            if (!attr.getSpecified() && (seenSchemaDefault ||
                (attr.getNamespaceURI() != null &&
                attr.getNamespaceURI() != NamespaceContext.XMLNS_URI &&
                attr.getName().indexOf(':') < 0))) {
                seenSchemaDefault = true;
                attrs.setNamedItemNS(attr);
            }
            else {
                attrs.setNamedItem(attr);
            }
            attrIndex = ownerDocument.getPrevSibling(attrIndex);
        } while (attrIndex != -1);
    }

    // set mutation events flag back to its original value
    ownerDocument.mutationEvents = orig;

}
 
Example 19
Source File: DeferredElementNSImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/** Synchronizes the data (name and value) for fast nodes. */
protected final void synchronizeData() {

    // no need to sync in the future
    needsSyncData(false);

    // fluff data
    DeferredDocumentImpl ownerDocument =
        (DeferredDocumentImpl) this.ownerDocument;

    // we don't want to generate any event for this so turn them off
    boolean orig = ownerDocument.mutationEvents;
    ownerDocument.mutationEvents = false;

    name = ownerDocument.getNodeName(fNodeIndex);

    // extract local part from QName
    int index = name.indexOf(':');
    if (index < 0) {
        localName = name;
    }
    else {
        localName = name.substring(index + 1);
    }

        namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
    type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex);

    // attributes
    setupDefaultAttributes();
    int attrIndex = ownerDocument.getNodeExtra(fNodeIndex);
    if (attrIndex != -1) {
        NamedNodeMap attrs = getAttributes();
        boolean seenSchemaDefault = false;
        do {
            AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex);
            // Take special care of schema defaulted attributes. Calling the
            // non-namespace aware setAttributeNode() method could overwrite
            // another attribute with the same local name.
            if (!attr.getSpecified() && (seenSchemaDefault ||
                (attr.getNamespaceURI() != null &&
                attr.getNamespaceURI() != NamespaceContext.XMLNS_URI &&
                attr.getName().indexOf(':') < 0))) {
                seenSchemaDefault = true;
                attrs.setNamedItemNS(attr);
            }
            else {
                attrs.setNamedItem(attr);
            }
            attrIndex = ownerDocument.getPrevSibling(attrIndex);
        } while (attrIndex != -1);
    }

    // set mutation events flag back to its original value
    ownerDocument.mutationEvents = orig;

}
 
Example 20
Source File: DeferredElementNSImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/** Synchronizes the data (name and value) for fast nodes. */
protected final void synchronizeData() {

    // no need to sync in the future
    needsSyncData(false);

    // fluff data
    DeferredDocumentImpl ownerDocument =
        (DeferredDocumentImpl) this.ownerDocument;

    // we don't want to generate any event for this so turn them off
    boolean orig = ownerDocument.mutationEvents;
    ownerDocument.mutationEvents = false;

    name = ownerDocument.getNodeName(fNodeIndex);

    // extract local part from QName
    int index = name.indexOf(':');
    if (index < 0) {
        localName = name;
    }
    else {
        localName = name.substring(index + 1);
    }

        namespaceURI = ownerDocument.getNodeURI(fNodeIndex);
    type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex);

    // attributes
    setupDefaultAttributes();
    int attrIndex = ownerDocument.getNodeExtra(fNodeIndex);
    if (attrIndex != -1) {
        NamedNodeMap attrs = getAttributes();
        boolean seenSchemaDefault = false;
        do {
            AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex);
            // Take special care of schema defaulted attributes. Calling the
            // non-namespace aware setAttributeNode() method could overwrite
            // another attribute with the same local name.
            if (!attr.getSpecified() && (seenSchemaDefault ||
                (attr.getNamespaceURI() != null &&
                attr.getNamespaceURI() != NamespaceContext.XMLNS_URI &&
                attr.getName().indexOf(':') < 0))) {
                seenSchemaDefault = true;
                attrs.setNamedItemNS(attr);
            }
            else {
                attrs.setNamedItem(attr);
            }
            attrIndex = ownerDocument.getPrevSibling(attrIndex);
        } while (attrIndex != -1);
    }

    // set mutation events flag back to its original value
    ownerDocument.mutationEvents = orig;

}