com.sun.org.apache.xerces.internal.xni.NamespaceContext Java Examples
The following examples show how to use
com.sun.org.apache.xerces.internal.xni.NamespaceContext.
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: XIncludeHandler.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Search for a xml:base attribute, and if one is found, put the new base URI into * effect. */ protected void processXMLBaseAttributes(XMLAttributes attributes) { String baseURIValue = attributes.getValue(NamespaceContext.XML_URI, "base"); if (baseURIValue != null) { try { String expandedValue = XMLEntityManager.expandSystemId( baseURIValue, fCurrentBaseURI.getExpandedSystemId(), false); fCurrentBaseURI.setLiteralSystemId(baseURIValue); fCurrentBaseURI.setBaseSystemId( fCurrentBaseURI.getExpandedSystemId()); fCurrentBaseURI.setExpandedSystemId(expandedValue); // push the new values on the stack saveBaseURI(); } catch (MalformedURIException e) { // REVISIT: throw error here } } }
Example #2
Source File: XIncludeHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Search for a xml:base attribute, and if one is found, put the new base URI into * effect. */ protected void processXMLBaseAttributes(XMLAttributes attributes) { String baseURIValue = attributes.getValue(NamespaceContext.XML_URI, "base"); if (baseURIValue != null) { try { String expandedValue = XMLEntityManager.expandSystemId( baseURIValue, fCurrentBaseURI.getExpandedSystemId(), false); fCurrentBaseURI.setLiteralSystemId(baseURIValue); fCurrentBaseURI.setBaseSystemId( fCurrentBaseURI.getExpandedSystemId()); fCurrentBaseURI.setExpandedSystemId(expandedValue); // push the new values on the stack saveBaseURI(); } catch (MalformedURIException e) { // REVISIT: throw error here } } }
Example #3
Source File: XIncludeHandler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Search for a xml:base attribute, and if one is found, put the new base URI into * effect. */ protected void processXMLBaseAttributes(XMLAttributes attributes) { String baseURIValue = attributes.getValue(NamespaceContext.XML_URI, "base"); if (baseURIValue != null) { try { String expandedValue = XMLEntityManager.expandSystemId( baseURIValue, fCurrentBaseURI.getExpandedSystemId(), false); fCurrentBaseURI.setLiteralSystemId(baseURIValue); fCurrentBaseURI.setBaseSystemId( fCurrentBaseURI.getExpandedSystemId()); fCurrentBaseURI.setExpandedSystemId(expandedValue); // push the new values on the stack saveBaseURI(); } catch (MalformedURIException e) { // REVISIT: throw error here } } }
Example #4
Source File: XMLDocumentScannerImpl.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Sets the value of a property. This method is called by the component * manager any time after reset when a property changes value. * <p> * <strong>Note:</strong> Components should silently ignore properties * that do not affect the operation of the component. * * @param propertyId The property identifier. * @param value The value of the property. * * @throws SAXNotRecognizedException The component should not throw * this exception. * @throws SAXNotSupportedException The component should not throw * this exception. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { super.setProperty(propertyId, value); // Xerces properties if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() && propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) { fDTDScanner = (XMLDTDScanner)value; } if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() && propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) { if (value != null) { fNamespaceContext = (NamespaceContext)value; } } return; } }
Example #5
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 #6
Source File: MultipleScopeNamespaceSupport.java From Bytecoder with Apache License 2.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 #7
Source File: SchemaContentHandler.java From jdk8u60 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 #8
Source File: XMLDocumentScannerImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Sets the value of a property. This method is called by the component * manager any time after reset when a property changes value. * <p> * <strong>Note:</strong> Components should silently ignore properties * that do not affect the operation of the component. * * @param propertyId The property identifier. * @param value The value of the property. * * @throws SAXNotRecognizedException The component should not throw * this exception. * @throws SAXNotSupportedException The component should not throw * this exception. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { super.setProperty(propertyId, value); // Xerces properties if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() && propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) { fDTDScanner = (XMLDTDScanner)value; } if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() && propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) { if (value != null) { fNamespaceContext = (NamespaceContext)value; } } return; } }
Example #9
Source File: Field.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** Constructs a field XPath expression. */ public XPath(String xpath, SymbolTable symbolTable, NamespaceContext context) throws XPathException { // NOTE: We have to prefix the field XPath with "./" in // order to handle selectors such as "@attr" that // select the attribute because the fields could be // relative to the selector element. -Ac // Unless xpath starts with a descendant node -Achille Fokoue // ... or a / or a . - NG super(((xpath.trim().startsWith("/") ||xpath.trim().startsWith("."))? xpath:"./"+xpath), symbolTable, context); // verify that only one attribute is selected per branch for (int i=0;i<fLocationPaths.length;i++) { for(int j=0; j<fLocationPaths[i].steps.length; j++) { com.sun.org.apache.xerces.internal.impl.xpath.XPath.Axis axis = fLocationPaths[i].steps[j].axis; if (axis.type == XPath.Axis.ATTRIBUTE && (j < fLocationPaths[i].steps.length-1)) { throw new XPathException("c-fields-xpaths"); } } } }
Example #10
Source File: DOMNormalizer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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 #11
Source File: NamespaceSupport.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * @see com.sun.org.apache.xerces.internal.xni.NamespaceContext#reset() */ public void reset() { // reset namespace and context info fNamespaceSize = 0; fCurrentContext = 0; // bind "xml" prefix to the XML uri fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XML; fNamespace[fNamespaceSize++] = NamespaceContext.XML_URI; // bind "xmlns" prefix to the XMLNS uri fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS; fNamespace[fNamespaceSize++] = NamespaceContext.XMLNS_URI; fContext[fCurrentContext] = fNamespaceSize; //++fCurrentContext; }
Example #12
Source File: MultipleScopeNamespaceSupport.java From hottub 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 #13
Source File: MultipleScopeNamespaceSupport.java From openjdk-jdk8u-backup 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 #14
Source File: MultipleScopeNamespaceSupport.java From Bytecoder 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 #15
Source File: MultipleScopeNamespaceSupport.java From TencentKona-8 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 #16
Source File: XMLDocumentScannerImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Sets the value of a property. This method is called by the component * manager any time after reset when a property changes value. * <p> * <strong>Note:</strong> Components should silently ignore properties * that do not affect the operation of the component. * * @param propertyId The property identifier. * @param value The value of the property. * * @throws SAXNotRecognizedException The component should not throw * this exception. * @throws SAXNotSupportedException The component should not throw * this exception. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { super.setProperty(propertyId, value); // Xerces properties if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() && propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) { fDTDScanner = (XMLDTDScanner)value; } if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() && propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) { if (value != null) { fNamespaceContext = (NamespaceContext)value; } } return; } }
Example #17
Source File: XMLDocumentScannerImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Sets the value of a property. This method is called by the component * manager any time after reset when a property changes value. * <p> * <strong>Note:</strong> Components should silently ignore properties * that do not affect the operation of the component. * * @param propertyId The property identifier. * @param value The value of the property. * * @throws SAXNotRecognizedException The component should not throw * this exception. * @throws SAXNotSupportedException The component should not throw * this exception. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { super.setProperty(propertyId, value); // Xerces properties if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() && propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) { fDTDScanner = (XMLDTDScanner)value; } if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() && propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) { if (value != null) { fNamespaceContext = (NamespaceContext)value; } } return; } }
Example #18
Source File: DOMNormalizer.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * 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 #19
Source File: XMLDocumentFilterImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
public void startDocument( XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException { next.startDocument(locator, encoding, namespaceContext, augs); }
Example #20
Source File: XIncludeHandler.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Search for a xml:lang attribute, and if one is found, put the new * [language] into effect. */ protected void processXMLLangAttributes(XMLAttributes attributes) { String language = attributes.getValue(NamespaceContext.XML_URI, "lang"); if (language != null) { fCurrentLanguage = language; saveLanguage(fCurrentLanguage); } }
Example #21
Source File: ValidatorHandlerImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public ValidatorHandlerImpl(XMLSchemaValidatorComponentManager componentManager) { fComponentManager = componentManager; fErrorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER); fNamespaceContext = (NamespaceContext) fComponentManager.getProperty(NAMESPACE_CONTEXT); fSchemaValidator = (XMLSchemaValidator) fComponentManager.getProperty(SCHEMA_VALIDATOR); fSymbolTable = (SymbolTable) fComponentManager.getProperty(SYMBOL_TABLE); fValidationManager = (ValidationManager) fComponentManager.getProperty(VALIDATION_MANAGER); }
Example #22
Source File: XIncludeHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Search for a xml:lang attribute, and if one is found, put the new * [language] into effect. */ protected void processXMLLangAttributes(XMLAttributes attributes) { String language = attributes.getValue(NamespaceContext.XML_URI, "lang"); if (language != null) { fCurrentLanguage = language; saveLanguage(fCurrentLanguage); } }
Example #23
Source File: XMLDocumentFilterImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void startDocument( XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException { next.startDocument(locator, encoding, namespaceContext, augs); }
Example #24
Source File: XIncludeHandler.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Search for a xml:lang attribute, and if one is found, put the new * [language] into effect. */ protected void processXMLLangAttributes(XMLAttributes attributes) { String language = attributes.getValue(NamespaceContext.XML_URI, "lang"); if (language != null) { fCurrentLanguage = language; saveLanguage(fCurrentLanguage); } }
Example #25
Source File: DOMValidatorHelper.java From openjdk-8-source 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 #26
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 #27
Source File: TeeXMLDocumentFilterImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void startDocument( XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException { side.startDocument(locator, encoding, namespaceContext, augs); next.startDocument(locator, encoding, namespaceContext, augs); }
Example #28
Source File: XPath.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** Constructs an XPath object from the specified expression. */ public XPath(String xpath, SymbolTable symbolTable, NamespaceContext context) throws XPathException { fExpression = xpath; fSymbolTable = symbolTable; parseExpression(context); }
Example #29
Source File: TeeXMLDocumentFilterImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void startDocument( XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs) throws XNIException { side.startDocument(locator, encoding, namespaceContext, augs); next.startDocument(locator, encoding, namespaceContext, augs); }
Example #30
Source File: AttrNSImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void setName(String namespaceURI, String qname){ CoreDocumentImpl ownerDocument = ownerDocument(); String prefix; // DOM Level 3: namespace URI is never empty string. this.namespaceURI = namespaceURI; if (namespaceURI !=null) { this.namespaceURI = (namespaceURI.length() == 0)? null : namespaceURI; } int colon1 = qname.indexOf(':'); int colon2 = qname.lastIndexOf(':'); ownerDocument.checkNamespaceWF(qname, colon1, colon2); if (colon1 < 0) { // there is no prefix localName = qname; if (ownerDocument.errorChecking) { ownerDocument.checkQName(null, localName); if (qname.equals("xmlns") && (namespaceURI == null || !namespaceURI.equals(NamespaceContext.XMLNS_URI)) || (namespaceURI!=null && namespaceURI.equals(NamespaceContext.XMLNS_URI) && !qname.equals("xmlns"))) { String msg = DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", null); throw new DOMException(DOMException.NAMESPACE_ERR, msg); } } } else { prefix = qname.substring(0, colon1); localName = qname.substring(colon2+1); ownerDocument.checkQName(prefix, localName); ownerDocument.checkDOMNSErr(prefix, namespaceURI); } }