Java Code Examples for com.sun.org.apache.xerces.internal.xni.NamespaceContext#getURI()
The following examples show how to use
com.sun.org.apache.xerces.internal.xni.NamespaceContext#getURI() .
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: XPath.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Used by {@link #parseExpression} to parse a node test * from the token list. */ private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context ) throws XPathException { switch(typeToken) { case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY: return new NodeTest(NodeTest.WILDCARD); case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE: case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME: // consume QName token String prefix = xtokens.nextTokenAsString(); String uri = null; if (context != null && prefix != XMLSymbols.EMPTY_STRING) { uri = context.getURI(prefix); } if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) { throw new XPathException("c-general-xpath-ns"); } if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE) return new NodeTest(prefix,uri); String localpart = xtokens.nextTokenAsString(); String rawname = prefix != XMLSymbols.EMPTY_STRING ? fSymbolTable.addSymbol(prefix+':'+localpart) : localpart; return new NodeTest(new QName(prefix, localpart, rawname, uri)); default: // assertion error throw new XPathException("c-general-xpath"); } }
Example 2
Source File: NamespaceSupport.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 3
Source File: XPath.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Used by {@link #parseExpression} to parse a node test * from the token list. */ private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context ) throws XPathException { switch(typeToken) { case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY: return new NodeTest(NodeTest.WILDCARD); case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE: case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME: // consume QName token String prefix = xtokens.nextTokenAsString(); String uri = null; if (context != null && prefix != XMLSymbols.EMPTY_STRING) { uri = context.getURI(prefix); } if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) { throw new XPathException("c-general-xpath-ns"); } if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE) return new NodeTest(prefix,uri); String localpart = xtokens.nextTokenAsString(); String rawname = prefix != XMLSymbols.EMPTY_STRING ? fSymbolTable.addSymbol(prefix+':'+localpart) : localpart; return new NodeTest(new QName(prefix, localpart, rawname, uri)); default: // assertion error throw new XPathException("c-general-xpath"); } }
Example 4
Source File: NamespaceSupport.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 5
Source File: XPath.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Used by {@link #parseExpression} to parse a node test * from the token list. */ private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context ) throws XPathException { switch(typeToken) { case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY: return new NodeTest(NodeTest.WILDCARD); case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE: case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME: // consume QName token String prefix = xtokens.nextTokenAsString(); String uri = null; if (context != null && prefix != XMLSymbols.EMPTY_STRING) { uri = context.getURI(prefix); } if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) { throw new XPathException("c-general-xpath-ns"); } if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE) return new NodeTest(prefix,uri); String localpart = xtokens.nextTokenAsString(); String rawname = prefix != XMLSymbols.EMPTY_STRING ? fSymbolTable.addSymbol(prefix+':'+localpart) : localpart; return new NodeTest(new QName(prefix, localpart, rawname, uri)); default: // assertion error throw new XPathException("c-general-xpath"); } }
Example 6
Source File: NamespaceSupport.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 7
Source File: NamespaceSupport.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration<String> prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 8
Source File: NamespaceSupport.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 9
Source File: NamespaceSupport.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 10
Source File: XPath.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Used by {@link #parseExpression} to parse a node test * from the token list. */ private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context ) throws XPathException { switch(typeToken) { case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY: return new NodeTest(NodeTest.WILDCARD); case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE: case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME: // consume QName token String prefix = xtokens.nextTokenAsString(); String uri = null; if (context != null && prefix != XMLSymbols.EMPTY_STRING) { uri = context.getURI(prefix); } if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) { throw new XPathException("c-general-xpath-ns"); } if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE) return new NodeTest(prefix,uri); String localpart = xtokens.nextTokenAsString(); String rawname = prefix != XMLSymbols.EMPTY_STRING ? fSymbolTable.addSymbol(prefix+':'+localpart) : localpart; return new NodeTest(new QName(prefix, localpart, rawname, uri)); default: // assertion error throw new XPathException("c-general-xpath"); } }
Example 11
Source File: XPath.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Used by {@link #parseExpression} to parse a node test * from the token list. */ private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context ) throws XPathException { switch(typeToken) { case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY: return new NodeTest(NodeTest.WILDCARD); case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE: case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME: // consume QName token String prefix = xtokens.nextTokenAsString(); String uri = null; if (context != null && prefix != XMLSymbols.EMPTY_STRING) { uri = context.getURI(prefix); } if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) { throw new XPathException("c-general-xpath-ns"); } if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE) return new NodeTest(prefix,uri); String localpart = xtokens.nextTokenAsString(); String rawname = prefix != XMLSymbols.EMPTY_STRING ? fSymbolTable.addSymbol(prefix+':'+localpart) : localpart; return new NodeTest(new QName(prefix, localpart, rawname, uri)); default: // assertion error throw new XPathException("c-general-xpath"); } }
Example 12
Source File: NamespaceSupport.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 13
Source File: NamespaceSupport.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 14
Source File: XPath.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Used by {@link #parseExpression} to parse a node test * from the token list. */ private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context ) throws XPathException { switch(typeToken) { case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY: return new NodeTest(NodeTest.WILDCARD); case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE: case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME: // consume QName token String prefix = xtokens.nextTokenAsString(); String uri = null; if (context != null && prefix != XMLSymbols.EMPTY_STRING) { uri = context.getURI(prefix); } if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) { throw new XPathException("c-general-xpath-ns"); } if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE) return new NodeTest(prefix,uri); String localpart = xtokens.nextTokenAsString(); String rawname = prefix != XMLSymbols.EMPTY_STRING ? fSymbolTable.addSymbol(prefix+':'+localpart) : localpart; return new NodeTest(new QName(prefix, localpart, rawname, uri)); default: // assertion error throw new XPathException("c-general-xpath"); } }
Example 15
Source File: NamespaceSupport.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Constructs a namespace context object and initializes it with * the prefixes declared in the specified context. */ public NamespaceSupport(NamespaceContext context) { pushContext(); // copy declaration in the context Enumeration prefixes = context.getAllPrefixes(); while (prefixes.hasMoreElements()){ String prefix = (String)prefixes.nextElement(); String uri = context.getURI(prefix); declarePrefix(prefix, uri); } }
Example 16
Source File: SchemaDOM.java From Bytecoder with Apache License 2.0 | 4 votes |
void startAnnotation(String elemRawName, XMLAttributes attributes, NamespaceContext namespaceContext) { if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256); fAnnotationBuffer.append("<").append(elemRawName).append(" "); // attributes are a bit of a pain. To get this right, we have to keep track // of the namespaces we've seen declared, then examine the namespace context // for other namespaces so that we can also include them. // optimized for simplicity and the case that not many // namespaces are declared on this annotation... List<String> namespaces = new ArrayList<>(); for (int i = 0; i < attributes.getLength(); ++i) { String aValue = attributes.getValue(i); String aPrefix = attributes.getPrefix(i); String aQName = attributes.getQName(i); // if it's xmlns:* or xmlns, must be a namespace decl if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) { namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ? attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING); } fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" "); } // now we have to look through currently in-scope namespaces to see what // wasn't declared here Enumeration<String> currPrefixes = namespaceContext.getAllPrefixes(); while(currPrefixes.hasMoreElements()) { String prefix = currPrefixes.nextElement(); String uri = namespaceContext.getURI(prefix); if (uri == null) { uri = XMLSymbols.EMPTY_STRING; } if (!namespaces.contains(prefix)) { // have to declare this one if(prefix == XMLSymbols.EMPTY_STRING) { fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" "); } else { fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" "); } } } fAnnotationBuffer.append(">\n"); }
Example 17
Source File: SchemaDOM.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
void startAnnotation(String elemRawName, XMLAttributes attributes, NamespaceContext namespaceContext) { if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256); fAnnotationBuffer.append("<").append(elemRawName).append(" "); // attributes are a bit of a pain. To get this right, we have to keep track // of the namespaces we've seen declared, then examine the namespace context // for other namespaces so that we can also include them. // optimized for simplicity and the case that not many // namespaces are declared on this annotation... ArrayList namespaces = new ArrayList(); for (int i = 0; i < attributes.getLength(); ++i) { String aValue = attributes.getValue(i); String aPrefix = attributes.getPrefix(i); String aQName = attributes.getQName(i); // if it's xmlns:* or xmlns, must be a namespace decl if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) { namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ? attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING); } fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" "); } // now we have to look through currently in-scope namespaces to see what // wasn't declared here Enumeration currPrefixes = namespaceContext.getAllPrefixes(); while(currPrefixes.hasMoreElements()) { String prefix = (String)currPrefixes.nextElement(); String uri = namespaceContext.getURI(prefix); if (uri == null) { uri = XMLSymbols.EMPTY_STRING; } if (!namespaces.contains(prefix)) { // have to declare this one if(prefix == XMLSymbols.EMPTY_STRING) { fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" "); } else { fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" "); } } } fAnnotationBuffer.append(">\n"); }
Example 18
Source File: SchemaDOM.java From JDKSourceCode1.8 with MIT License | 4 votes |
void startAnnotation(String elemRawName, XMLAttributes attributes, NamespaceContext namespaceContext) { if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256); fAnnotationBuffer.append("<").append(elemRawName).append(" "); // attributes are a bit of a pain. To get this right, we have to keep track // of the namespaces we've seen declared, then examine the namespace context // for other namespaces so that we can also include them. // optimized for simplicity and the case that not many // namespaces are declared on this annotation... ArrayList namespaces = new ArrayList(); for (int i = 0; i < attributes.getLength(); ++i) { String aValue = attributes.getValue(i); String aPrefix = attributes.getPrefix(i); String aQName = attributes.getQName(i); // if it's xmlns:* or xmlns, must be a namespace decl if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) { namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ? attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING); } fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" "); } // now we have to look through currently in-scope namespaces to see what // wasn't declared here Enumeration currPrefixes = namespaceContext.getAllPrefixes(); while(currPrefixes.hasMoreElements()) { String prefix = (String)currPrefixes.nextElement(); String uri = namespaceContext.getURI(prefix); if (uri == null) { uri = XMLSymbols.EMPTY_STRING; } if (!namespaces.contains(prefix)) { // have to declare this one if(prefix == XMLSymbols.EMPTY_STRING) { fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" "); } else { fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" "); } } } fAnnotationBuffer.append(">\n"); }
Example 19
Source File: SchemaDOM.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void startAnnotation(String elemRawName, XMLAttributes attributes, NamespaceContext namespaceContext) { if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256); fAnnotationBuffer.append("<").append(elemRawName).append(" "); // attributes are a bit of a pain. To get this right, we have to keep track // of the namespaces we've seen declared, then examine the namespace context // for other namespaces so that we can also include them. // optimized for simplicity and the case that not many // namespaces are declared on this annotation... ArrayList namespaces = new ArrayList(); for (int i = 0; i < attributes.getLength(); ++i) { String aValue = attributes.getValue(i); String aPrefix = attributes.getPrefix(i); String aQName = attributes.getQName(i); // if it's xmlns:* or xmlns, must be a namespace decl if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) { namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ? attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING); } fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" "); } // now we have to look through currently in-scope namespaces to see what // wasn't declared here Enumeration currPrefixes = namespaceContext.getAllPrefixes(); while(currPrefixes.hasMoreElements()) { String prefix = (String)currPrefixes.nextElement(); String uri = namespaceContext.getURI(prefix); if (uri == null) { uri = XMLSymbols.EMPTY_STRING; } if (!namespaces.contains(prefix)) { // have to declare this one if(prefix == XMLSymbols.EMPTY_STRING) { fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" "); } else { fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" "); } } } fAnnotationBuffer.append(">\n"); }
Example 20
Source File: SchemaDOM.java From hottub with GNU General Public License v2.0 | 4 votes |
void startAnnotation(String elemRawName, XMLAttributes attributes, NamespaceContext namespaceContext) { if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256); fAnnotationBuffer.append("<").append(elemRawName).append(" "); // attributes are a bit of a pain. To get this right, we have to keep track // of the namespaces we've seen declared, then examine the namespace context // for other namespaces so that we can also include them. // optimized for simplicity and the case that not many // namespaces are declared on this annotation... ArrayList namespaces = new ArrayList(); for (int i = 0; i < attributes.getLength(); ++i) { String aValue = attributes.getValue(i); String aPrefix = attributes.getPrefix(i); String aQName = attributes.getQName(i); // if it's xmlns:* or xmlns, must be a namespace decl if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) { namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ? attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING); } fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" "); } // now we have to look through currently in-scope namespaces to see what // wasn't declared here Enumeration currPrefixes = namespaceContext.getAllPrefixes(); while(currPrefixes.hasMoreElements()) { String prefix = (String)currPrefixes.nextElement(); String uri = namespaceContext.getURI(prefix); if (uri == null) { uri = XMLSymbols.EMPTY_STRING; } if (!namespaces.contains(prefix)) { // have to declare this one if(prefix == XMLSymbols.EMPTY_STRING) { fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" "); } else { fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" "); } } } fAnnotationBuffer.append(">\n"); }