com.sun.org.apache.xerces.internal.util.XMLSymbols Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.util.XMLSymbols. 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: MultipleScopeNamespaceSupport.java    From jdk1.8-source-analysis with Apache License 2.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 #2
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 #3
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 #4
Source File: SchemaContentHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void addNamespaceDeclarations(final int prefixCount) {
    String prefix = null;
    String localpart = null;
    String rawname = null;
    String nsPrefix = null;
    String nsURI = null;
    for (int i = 0; i < prefixCount; ++i) {
        nsPrefix = fNamespaceContext.getDeclaredPrefixAt(i);
        nsURI = fNamespaceContext.getURI(nsPrefix);
        if (nsPrefix.length() > 0) {
            prefix = XMLSymbols.PREFIX_XMLNS;
            localpart = nsPrefix;
            rawname = fSymbolTable.addSymbol(prefix + ":" + localpart);
        }
        else {
            prefix = XMLSymbols.EMPTY_STRING;
            localpart = XMLSymbols.PREFIX_XMLNS;
            rawname = XMLSymbols.PREFIX_XMLNS;
        }
        fAttributeQName.setValues(prefix, localpart, rawname, NamespaceContext.XMLNS_URI);
        fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, nsURI);
    }
}
 
Example #5
Source File: XMLSchemaValidator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void storeLocations(String sLocation, String nsLocation) {
    if (sLocation != null) {
        if (!XMLSchemaLoader.tokenizeSchemaLocationStr(sLocation, fLocationPairs)) {
            // error!
            fXSIErrorReporter.reportError(
                XSMessageFormatter.SCHEMA_DOMAIN,
                "SchemaLocation",
                new Object[] { sLocation },
                XMLErrorReporter.SEVERITY_WARNING);
        }
    }
    if (nsLocation != null) {
        XMLSchemaLoader.LocationArray la =
            ((XMLSchemaLoader.LocationArray) fLocationPairs.get(XMLSymbols.EMPTY_STRING));
        if (la == null) {
            la = new XMLSchemaLoader.LocationArray();
            fLocationPairs.put(XMLSymbols.EMPTY_STRING, la);
        }
        la.addLocation(nsLocation);
    }

}
 
Example #6
Source File: DOMNormalizer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a namespace attribute or replaces the value of existing namespace
 * attribute with the given prefix and value for URI.
 * In case prefix is empty will add/update default namespace declaration.
 *
 * @param prefix
 * @param uri
 * @exception IOException
 */

protected final void addNamespaceDecl(String prefix, String uri, ElementImpl element){
    if (DEBUG) {
        System.out.println("[ns-fixup] addNamespaceDecl ["+prefix+"]");
    }
    if (prefix == XMLSymbols.EMPTY_STRING) {
        if (DEBUG) {
            System.out.println("=>add xmlns=\""+uri+"\" declaration");
        }
        element.setAttributeNS(NamespaceContext.XMLNS_URI, XMLSymbols.PREFIX_XMLNS, uri);
    } else {
        if (DEBUG) {
            System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
        }
        element.setAttributeNS(NamespaceContext.XMLNS_URI, "xmlns:"+prefix, uri);
    }
}
 
Example #7
Source File: XMLNSDTDValidator.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/** Handles end element. */
protected void endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #8
Source File: XML11NSDTDValidator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/** Handles end element. */
protected void endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #9
Source File: ValidatorHandlerImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void endElement(QName element, Augmentations augs)
        throws XNIException {
    if (fContentHandler != null) {
        try {
            fTypeInfoProvider.beginEndElement(augs);
            fContentHandler.endElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
                    element.localpart, element.rawname);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
        finally {
            fTypeInfoProvider.finishEndElement();
        }
    }
}
 
Example #10
Source File: ValidatorHandlerImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Fills in a QName object. */
private void fillQName(QName toFill, String uri, String localpart, String raw) {
    if (!fStringsInternalized) {
        uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
        localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
        raw = (raw != null) ? fSymbolTable.addSymbol(raw) : XMLSymbols.EMPTY_STRING;
    }
    else {
        if (uri != null && uri.length() == 0) {
            uri = null;
        }
        if (localpart == null) {
            localpart = XMLSymbols.EMPTY_STRING;
        }
        if (raw == null) {
            raw = XMLSymbols.EMPTY_STRING;
        }
    }
    String prefix = XMLSymbols.EMPTY_STRING;
    int prefixIdx = raw.indexOf(':');
    if (prefixIdx != -1) {
        prefix = fSymbolTable.addSymbol(raw.substring(0, prefixIdx));
    }
    toFill.setValues(prefix, localpart, raw, uri);
}
 
Example #11
Source File: ValidatorHandlerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void startPrefixMapping(String prefix, String uri)
        throws SAXException {
    String prefixSymbol;
    String uriSymbol;
    if (!fStringsInternalized) {
        prefixSymbol = (prefix != null) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
        uriSymbol = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
    }
    else {
        prefixSymbol = (prefix != null) ? prefix : XMLSymbols.EMPTY_STRING;
        uriSymbol = (uri != null && uri.length() > 0) ? uri : null;
    }
    if (fNeedPushNSContext) {
        fNeedPushNSContext = false;
        fNamespaceContext.pushContext();
    }
    fNamespaceContext.declarePrefix(prefixSymbol, uriSymbol);
    if (fContentHandler != null) {
        fContentHandler.startPrefixMapping(prefix, uri);
    }
}
 
Example #12
Source File: ValidatorHandlerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void startPrefixMapping(String prefix, String uri)
        throws SAXException {
    String prefixSymbol;
    String uriSymbol;
    if (!fStringsInternalized) {
        prefixSymbol = (prefix != null) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
        uriSymbol = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
    }
    else {
        prefixSymbol = (prefix != null) ? prefix : XMLSymbols.EMPTY_STRING;
        uriSymbol = (uri != null && uri.length() > 0) ? uri : null;
    }
    if (fNeedPushNSContext) {
        fNeedPushNSContext = false;
        fNamespaceContext.pushContext();
    }
    fNamespaceContext.declarePrefix(prefixSymbol, uriSymbol);
    if (fContentHandler != null) {
        fContentHandler.startPrefixMapping(prefix, uri);
    }
}
 
Example #13
Source File: XMLSchemaValidator.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
void storeLocations(String sLocation, String nsLocation) {
    if (sLocation != null) {
        if (!XMLSchemaLoader.tokenizeSchemaLocationStr(sLocation, fLocationPairs)) {
            // error!
            fXSIErrorReporter.reportError(
                XSMessageFormatter.SCHEMA_DOMAIN,
                "SchemaLocation",
                new Object[] { sLocation },
                XMLErrorReporter.SEVERITY_WARNING);
        }
    }
    if (nsLocation != null) {
        XMLSchemaLoader.LocationArray la = fLocationPairs.get(XMLSymbols.EMPTY_STRING);
        if (la == null) {
            la = new XMLSchemaLoader.LocationArray();
            fLocationPairs.put(XMLSymbols.EMPTY_STRING, la);
        }
        la.addLocation(nsLocation);
    }

}
 
Example #14
Source File: XMLNamespaceBinder.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/** Handles end element. */
protected void handleEndElement(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null && !fOnlyPassPrefixMappingEvents) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #15
Source File: XMLSerializer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a namespace attribute with the given prefix and value for URI.
 * In case prefix is empty will serialize default namespace declaration.
 *
 * @param prefix
 * @param uri
 * @exception IOException
 */

private void printNamespaceAttr(String prefix, String uri) throws IOException{
    _printer.printSpace();
    if (prefix == XMLSymbols.EMPTY_STRING) {
        if (DEBUG) {
            System.out.println("=>add xmlns=\""+uri+"\" declaration");
        }
        _printer.printText( XMLSymbols.PREFIX_XMLNS );
    } else {
        if (DEBUG) {
            System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
        }
        _printer.printText( "xmlns:"+prefix );
    }
    _printer.printText( "=\"" );
    printEscaped( uri );
    _printer.printText( '"' );
}
 
Example #16
Source File: DOMNormalizer.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a namespace attribute or replaces the value of existing namespace
 * attribute with the given prefix and value for URI.
 * In case prefix is empty will add/update default namespace declaration.
 *
 * @param prefix
 * @param uri
 * @exception IOException
 */

protected final void addNamespaceDecl(String prefix, String uri, ElementImpl element){
    if (DEBUG) {
        System.out.println("[ns-fixup] addNamespaceDecl ["+prefix+"]");
    }
    if (prefix == XMLSymbols.EMPTY_STRING) {
        if (DEBUG) {
            System.out.println("=>add xmlns=\""+uri+"\" declaration");
        }
        element.setAttributeNS(NamespaceContext.XMLNS_URI, XMLSymbols.PREFIX_XMLNS, uri);
    } else {
        if (DEBUG) {
            System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
        }
        element.setAttributeNS(NamespaceContext.XMLNS_URI, "xmlns:"+prefix, uri);
    }
}
 
Example #17
Source File: XML11NSDTDValidator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Handles end element. */
protected void endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #18
Source File: ValidatorHandlerImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Fills in a QName object. */
private void fillQName(QName toFill, String uri, String localpart, String raw) {
    if (!fStringsInternalized) {
        uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
        localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
        raw = (raw != null) ? fSymbolTable.addSymbol(raw) : XMLSymbols.EMPTY_STRING;
    }
    else {
        if (uri != null && uri.length() == 0) {
            uri = null;
        }
        if (localpart == null) {
            localpart = XMLSymbols.EMPTY_STRING;
        }
        if (raw == null) {
            raw = XMLSymbols.EMPTY_STRING;
        }
    }
    String prefix = XMLSymbols.EMPTY_STRING;
    int prefixIdx = raw.indexOf(':');
    if (prefixIdx != -1) {
        prefix = fSymbolTable.addSymbol(raw.substring(0, prefixIdx));
    }
    toFill.setValues(prefix, localpart, raw, uri);
}
 
Example #19
Source File: ValidatorHandlerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    if (fContentHandler != null) {
        try {
            fTypeInfoProvider.beginStartElement(augs, attributes);
            fContentHandler.startElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
                    element.localpart, element.rawname, fAttrAdapter);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
        finally {
            fTypeInfoProvider.finishStartElement();
        }
    }
}
 
Example #20
Source File: DOMNormalizer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a namespace attribute or replaces the value of existing namespace
 * attribute with the given prefix and value for URI.
 * In case prefix is empty will add/update default namespace declaration.
 *
 * @param prefix
 * @param uri
 * @exception IOException
 */

protected final void addNamespaceDecl(String prefix, String uri, ElementImpl element){
    if (DEBUG) {
        System.out.println("[ns-fixup] addNamespaceDecl ["+prefix+"]");
    }
    if (prefix == XMLSymbols.EMPTY_STRING) {
        if (DEBUG) {
            System.out.println("=>add xmlns=\""+uri+"\" declaration");
        }
        element.setAttributeNS(NamespaceContext.XMLNS_URI, XMLSymbols.PREFIX_XMLNS, uri);
    } else {
        if (DEBUG) {
            System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
        }
        element.setAttributeNS(NamespaceContext.XMLNS_URI, "xmlns:"+prefix, uri);
    }
}
 
Example #21
Source File: XMLSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a namespace attribute with the given prefix and value for URI.
 * In case prefix is empty will serialize default namespace declaration.
 *
 * @param prefix
 * @param uri
 * @exception IOException
 */

private void printNamespaceAttr(String prefix, String uri) throws IOException{
    _printer.printSpace();
    if (prefix == XMLSymbols.EMPTY_STRING) {
        if (DEBUG) {
            System.out.println("=>add xmlns=\""+uri+"\" declaration");
        }
        _printer.printText( XMLSymbols.PREFIX_XMLNS );
    } else {
        if (DEBUG) {
            System.out.println("=>add xmlns:"+prefix+"=\""+uri+"\" declaration");
        }
        _printer.printText( "xmlns:"+prefix );
    }
    _printer.printText( "=\"" );
    printEscaped( uri );
    _printer.printText( '"' );
}
 
Example #22
Source File: ValidatorHandlerImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    if (fContentHandler != null) {
        try {
            fTypeInfoProvider.beginStartElement(augs, attributes);
            fContentHandler.startElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
                    element.localpart, element.rawname, fAttrAdapter);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
        finally {
            fTypeInfoProvider.finishStartElement();
        }
    }
}
 
Example #23
Source File: ValidatorHandlerImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void startPrefixMapping(String prefix, String uri)
        throws SAXException {
    String prefixSymbol;
    String uriSymbol;
    if (!fStringsInternalized) {
        prefixSymbol = (prefix != null) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
        uriSymbol = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
    }
    else {
        prefixSymbol = (prefix != null) ? prefix : XMLSymbols.EMPTY_STRING;
        uriSymbol = (uri != null && uri.length() > 0) ? uri : null;
    }
    if (fNeedPushNSContext) {
        fNeedPushNSContext = false;
        fNamespaceContext.pushContext();
    }
    fNamespaceContext.declarePrefix(prefixSymbol, uriSymbol);
    if (fContentHandler != null) {
        fContentHandler.startPrefixMapping(prefix, uri);
    }
}
 
Example #24
Source File: MultipleScopeNamespaceSupport.java    From openjdk-jdk8u-backup 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 #25
Source File: XMLNSDTDValidator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Handles end element. */
protected void endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #26
Source File: MultipleScopeNamespaceSupport.java    From openjdk-jdk8u-backup 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 #27
Source File: MultipleScopeNamespaceSupport.java    From JDKSourceCode1.8 with MIT License 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 #28
Source File: ValidatorHandlerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Fills in a QName object. */
private void fillQName(QName toFill, String uri, String localpart, String raw) {
    if (!fStringsInternalized) {
        uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
        localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
        raw = (raw != null) ? fSymbolTable.addSymbol(raw) : XMLSymbols.EMPTY_STRING;
    }
    else {
        if (uri != null && uri.length() == 0) {
            uri = null;
        }
        if (localpart == null) {
            localpart = XMLSymbols.EMPTY_STRING;
        }
        if (raw == null) {
            raw = XMLSymbols.EMPTY_STRING;
        }
    }
    String prefix = XMLSymbols.EMPTY_STRING;
    int prefixIdx = raw.indexOf(':');
    if (prefixIdx != -1) {
        prefix = fSymbolTable.addSymbol(raw.substring(0, prefixIdx));
    }
    toFill.setValues(prefix, localpart, raw, uri);
}
 
Example #29
Source File: XMLNSDTDValidator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Handles end element. */
protected void endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #30
Source File: MultipleScopeNamespaceSupport.java    From Bytecoder with Apache License 2.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;
}