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

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.SchemaNamespaceSupport. 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: XSAttributeChecker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #2
Source File: XSAttributeChecker.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #3
Source File: XSAttributeChecker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #4
Source File: XSAttributeChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #5
Source File: XSAttributeChecker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #6
Source File: XSAttributeChecker.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #7
Source File: XSAttributeChecker.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #8
Source File: XSAttributeChecker.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #9
Source File: XSAttributeChecker.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #10
Source File: XSAttributeChecker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #11
Source File: XSAttributeChecker.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void resolveNamespace(Element element, Attr[] attrs,
                             SchemaNamespaceSupport nsSupport) {
    // push the namespace context
    nsSupport.pushContext();

    // search for new namespace bindings
    int length = attrs.length;
    Attr sattr = null;
    String rawname, prefix, uri;
    for (int i = 0; i < length; i++) {
        sattr = attrs[i];
        rawname = DOMUtil.getName(sattr);
        prefix = null;
        if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
            prefix = XMLSymbols.EMPTY_STRING;
        else if (rawname.startsWith("xmlns:"))
            prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
        if (prefix != null) {
            uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
            nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
        }
    }
}
 
Example #12
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #13
Source File: XSDHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #14
Source File: XSDocumentInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #15
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #16
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #17
Source File: XSDocumentInfo.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #18
Source File: XSDocumentInfo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #19
Source File: XSDocumentInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #20
Source File: XSDocumentInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #21
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #22
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #23
Source File: XSDocumentInfo.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #24
Source File: XSDocumentInfo.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #25
Source File: XSDocumentInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #26
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #27
Source File: XSDHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #28
Source File: XSDocumentInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #29
Source File: XSDocumentInfo.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #30
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}