Java Code Examples for com.sun.org.apache.xerces.internal.util.XMLSymbols#PREFIX_XMLNS
The following examples show how to use
com.sun.org.apache.xerces.internal.util.XMLSymbols#PREFIX_XMLNS .
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 openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 2
Source File: SchemaContentHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
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 3
Source File: MultipleScopeNamespaceSupport.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 4
Source File: MultipleScopeNamespaceSupport.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
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 5
Source File: MultipleScopeNamespaceSupport.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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: SchemaContentHandler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 7
Source File: DOMValidatorHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 8
Source File: DOMValidatorHelper.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 9
Source File: DOMParserImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * The start of an element. If the document specifies the start element * by using an empty tag, then the startElement method will immediately * be followed by the endElement method, with no intervening methods. * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false. * * @param element The name of the element. * @param attributes The element attributes. * @param augs Additional information that may include infoset augmentations * * @throws XNIException Thrown by handler to signal an error. */ public void startElement (QName element, XMLAttributes attributes, Augmentations augs) { // namespace declarations parameter has no effect if namespaces is false. if (!fNamespaceDeclarations && fNamespaceAware) { int len = attributes.getLength(); for (int i = len - 1; i >= 0; --i) { if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) || XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) { attributes.removeAttributeAt(i); } } } super.startElement(element, attributes, augs); }
Example 10
Source File: StAXSchemaParser.java From hottub with GNU General Public License v2.0 | 5 votes |
private void addNamespaceDeclarations() { String prefix = null; String localpart = null; String rawname = null; String nsPrefix = null; String nsURI = null; final Iterator iter = fDeclaredPrefixes.iterator(); while (iter.hasNext()) { nsPrefix = (String) iter.next(); nsURI = fNamespaceContext.getURI(nsPrefix); if (nsPrefix.length() > 0) { prefix = XMLSymbols.PREFIX_XMLNS; localpart = nsPrefix; fStringBuffer.clear(); fStringBuffer.append(prefix); fStringBuffer.append(':'); fStringBuffer.append(localpart); rawname = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); } 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 != null) ? nsURI : XMLSymbols.EMPTY_STRING); } }
Example 11
Source File: StAXSchemaParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void addNamespaceDeclarations() { String prefix = null; String localpart = null; String rawname = null; String nsPrefix = null; String nsURI = null; final Iterator iter = fDeclaredPrefixes.iterator(); while (iter.hasNext()) { nsPrefix = (String) iter.next(); nsURI = fNamespaceContext.getURI(nsPrefix); if (nsPrefix.length() > 0) { prefix = XMLSymbols.PREFIX_XMLNS; localpart = nsPrefix; fStringBuffer.clear(); fStringBuffer.append(prefix); fStringBuffer.append(':'); fStringBuffer.append(localpart); rawname = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); } 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 != null) ? nsURI : XMLSymbols.EMPTY_STRING); } }
Example 12
Source File: DOMValidatorHelper.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 13
Source File: StAXSchemaParser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void addNamespaceDeclarations() { String prefix = null; String localpart = null; String rawname = null; String nsPrefix = null; String nsURI = null; final Iterator iter = fDeclaredPrefixes.iterator(); while (iter.hasNext()) { nsPrefix = (String) iter.next(); nsURI = fNamespaceContext.getURI(nsPrefix); if (nsPrefix.length() > 0) { prefix = XMLSymbols.PREFIX_XMLNS; localpart = nsPrefix; fStringBuffer.clear(); fStringBuffer.append(prefix); fStringBuffer.append(':'); fStringBuffer.append(localpart); rawname = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); } 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 != null) ? nsURI : XMLSymbols.EMPTY_STRING); } }
Example 14
Source File: DOMParserImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * The start of an element. If the document specifies the start element * by using an empty tag, then the startElement method will immediately * be followed by the endElement method, with no intervening methods. * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false. * * @param element The name of the element. * @param attributes The element attributes. * @param augs Additional information that may include infoset augmentations * * @throws XNIException Thrown by handler to signal an error. */ public void startElement (QName element, XMLAttributes attributes, Augmentations augs) { // namespace declarations parameter has no effect if namespaces is false. if (!fNamespaceDeclarations && fNamespaceAware) { int len = attributes.getLength(); for (int i = len - 1; i >= 0; --i) { if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) || XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) { attributes.removeAttributeAt(i); } } } super.startElement(element, attributes, augs); }
Example 15
Source File: DOMValidatorHelper.java From hottub with GNU General Public License v2.0 | 5 votes |
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 16
Source File: DOMParserImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * The start of an element. If the document specifies the start element * by using an empty tag, then the startElement method will immediately * be followed by the endElement method, with no intervening methods. * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false. * * @param element The name of the element. * @param attributes The element attributes. * @param augs Additional information that may include infoset augmentations * * @throws XNIException Thrown by handler to signal an error. */ public void startElement (QName element, XMLAttributes attributes, Augmentations augs) { // namespace declarations parameter has no effect if namespaces is false. if (!fNamespaceDeclarations && fNamespaceAware) { int len = attributes.getLength(); for (int i = len - 1; i >= 0; --i) { if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) || XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) { attributes.removeAttributeAt(i); } } } super.startElement(element, attributes, augs); }
Example 17
Source File: DOMValidatorHelper.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 18
Source File: XMLNamespaceBinder.java From Bytecoder with Apache License 2.0 | 4 votes |
protected boolean prefixBoundToNullURI(String uri, String localpart) { return (uri == XMLSymbols.EMPTY_STRING && localpart != XMLSymbols.PREFIX_XMLNS); }
Example 19
Source File: SchemaDOM.java From openjdk-jdk9 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 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"); }