jdk.xml.internal.JdkXmlUtils Java Examples
The following examples show how to use
jdk.xml.internal.JdkXmlUtils.
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: XSDHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void createAnnotationValidator() { fAnnotationValidator = new XML11Configuration(); fGrammarBucketAdapter = new XSAnnotationGrammarPool(); fAnnotationValidator.setFeature(VALIDATION, true); fAnnotationValidator.setFeature(XMLSCHEMA_VALIDATION, true); fAnnotationValidator.setProperty(XMLGRAMMAR_POOL, fGrammarBucketAdapter); /** set security manager and XML Security Property Manager **/ fAnnotationValidator.setProperty(SECURITY_MANAGER, (fSecurityManager != null) ? fSecurityManager : new XMLSecurityManager(true)); fAnnotationValidator.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); /** Set error handler. **/ fAnnotationValidator.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler()); /** Set locale. **/ fAnnotationValidator.setProperty(LOCALE, fLocale); // Passing on the Catalog settings fAnnotationValidator.setFeature(XMLConstants.USE_CATALOG, fUseCatalog); fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_FILES, fCatalogFile); fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_DEFER, fDefer); fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_PREFER, fPrefer); fAnnotationValidator.setProperty(JdkXmlUtils.CATALOG_RESOLVE, fResolve); }
Example #2
Source File: Catalog.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Setup readers. */ public void setupReaders() { SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(false); SAXCatalogReader saxReader = new SAXCatalogReader(spf); saxReader.setCatalogParser(null, "XMLCatalog", "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader"); addReader("application/xml", saxReader); TR9401CatalogReader textReader = new TR9401CatalogReader(); addReader("text/plain", textReader); }
Example #3
Source File: XSLTC.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Return allowed protocols for accessing external stylesheet. * @param name the name of the property * @return the value of the property */ public Object getProperty(String name) { if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) { return _accessExternalStylesheet; } else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) { return _accessExternalDTD; } else if (name.equals(XalanConstants.SECURITY_MANAGER)) { return _xmlSecurityManager; } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) { return _extensionClassLoader; } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) { return _catalogFeatures; } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) { return _cdataChunkSize; } return null; }
Example #4
Source File: Catalog.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Setup readers. */ public void setupReaders() { SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(false); SAXCatalogReader saxReader = new SAXCatalogReader(spf); saxReader.setCatalogParser(null, "XMLCatalog", "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader"); addReader("application/xml", saxReader); TR9401CatalogReader textReader = new TR9401CatalogReader(); addReader("text/plain", textReader); }
Example #5
Source File: SAX2DOM.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private Document createDocument(boolean overrideDefaultParser) throws ParserConfigurationException { if (_factory == null) { _factory = JdkXmlUtils.getDOMFactory(overrideDefaultParser); _internal = true; if (!(_factory instanceof com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)) { _internal = false; } } Document doc; if (_internal) { //default implementation is thread safe doc = _factory.newDocumentBuilder().newDocument(); } else { synchronized(SAX2DOM.class) { doc = _factory.newDocumentBuilder().newDocument(); } } return doc; }
Example #6
Source File: XPathImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private DocumentBuilder getParser() { try { // we'd really like to cache those DocumentBuilders, but we can't because: // 1. thread safety. parsers are not thread-safe, so at least // we need one instance per a thread. // 2. parsers are non-reentrant, so now we are looking at having a // pool of parsers. // 3. then the class loading issue. The look-up procedure of // DocumentBuilderFactory.newInstance() depends on context class loader // and system properties, which may change during the execution of JVM. // // so we really have to create a fresh DocumentBuilder every time we need one // - KK DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(overrideDefaultParser); return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { // this should never happen with a well-behaving JAXP implementation. throw new Error(e); } }
Example #7
Source File: XPathImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private DocumentBuilder getParser() { try { // we'd really like to cache those DocumentBuilders, but we can't because: // 1. thread safety. parsers are not thread-safe, so at least // we need one instance per a thread. // 2. parsers are non-reentrant, so now we are looking at having a // pool of parsers. // 3. then the class loading issue. The look-up procedure of // DocumentBuilderFactory.newInstance() depends on context class loader // and system properties, which may change during the execution of JVM. // // so we really have to create a fresh DocumentBuilder every time we need one // - KK DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(overrideDefaultParser); return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { // this should never happen with a well-behaving JAXP implementation. throw new Error(e); } }
Example #8
Source File: Parser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Parses a stylesheet and builds the internal abstract syntax tree * @param input A SAX2 InputSource can be passed to a SAX reader * @return The root of the abstract syntax tree */ public SyntaxTreeNode parse(InputSource input) { final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, _xsltc.isSecureProcessing()); JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD, _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true); String lastProperty = ""; try { XMLSecurityManager securityManager = (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER); for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) { lastProperty = limit.apiProperty(); reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit)); } if (securityManager.printEntityCountInfo()) { lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO; reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES); } } catch (SAXException se) { XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se); } return (parse(reader, input)); }
Example #9
Source File: SAX2DOM.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private Document createDocument(boolean overrideDefaultParser) throws ParserConfigurationException { if (_factory == null) { _factory = JdkXmlUtils.getDOMFactory(overrideDefaultParser); _internal = true; if (!(_factory instanceof com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)) { _internal = false; } } Document doc; if (_internal) { //default implementation is thread safe doc = _factory.newDocumentBuilder().newDocument(); } else { synchronized(SAX2DOM.class) { doc = _factory.newDocumentBuilder().newDocument(); } } return doc; }
Example #10
Source File: XMLSchemaFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public XMLSchemaFactory() { fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper(); fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true); fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); fSecurityPropertyMgr = new XMLSecurityPropertyManager(); fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); fXmlFeatures = new JdkXmlFeatures(fSecurityManager.isSecureProcessing()); fOverrideDefaultParser = fXmlFeatures.getFeature( JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER); fXMLSchemaLoader.setFeature(JdkXmlUtils.OVERRIDE_PARSER, fOverrideDefaultParser); }
Example #11
Source File: Resolver.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Setup readers. */ public void setupReaders() { SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(false); SAXCatalogReader saxReader = new SAXCatalogReader(spf); saxReader.setCatalogParser(null, "XMLCatalog", "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", "com.sun.org.apache.xml.internal.resolver.readers.ExtendedXMLCatalogReader"); addReader("application/xml", saxReader); TR9401CatalogReader textReader = new TR9401CatalogReader(); addReader("text/plain", textReader); }
Example #12
Source File: DTMManagerDefault.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Method createDocumentFragment * * * NEEDSDOC (createDocumentFragment) @return */ synchronized public DTM createDocumentFragment() { try { DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(super.overrideDefaultParser()); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); Node df = doc.createDocumentFragment(); return getDTM(new DOMSource(df), true, null, false, false); } catch (Exception e) { throw new DTMException(e); } }
Example #13
Source File: DTMManagerDefault.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Method createDocumentFragment * * * NEEDSDOC (createDocumentFragment) @return */ synchronized public DTM createDocumentFragment() { try { DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(super.overrideDefaultParser()); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); Node df = doc.createDocumentFragment(); return getDTM(new DOMSource(df), true, null, false, false); } catch (Exception e) { throw new DTMException(e); } }
Example #14
Source File: Parser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Parses a stylesheet and builds the internal abstract syntax tree * @param input A SAX2 InputSource can be passed to a SAX reader * @return The root of the abstract syntax tree */ public SyntaxTreeNode parse(InputSource input) { final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, _xsltc.isSecureProcessing()); JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD, _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true); String lastProperty = ""; try { XMLSecurityManager securityManager = (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER); for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) { lastProperty = limit.apiProperty(); reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit)); } if (securityManager.printEntityCountInfo()) { lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO; reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES); } } catch (SAXException se) { XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se); } return (parse(reader, input)); }
Example #15
Source File: XSLTC.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Set allowed protocols for accessing external stylesheet. * @param name the name of the property * @param value the value of the property */ public void setProperty(String name, Object value) { if (name.equals(XMLConstants.ACCESS_EXTERNAL_STYLESHEET)) { _accessExternalStylesheet = (String)value; } else if (name.equals(XMLConstants.ACCESS_EXTERNAL_DTD)) { _accessExternalDTD = (String)value; } else if (name.equals(XalanConstants.SECURITY_MANAGER)) { _xmlSecurityManager = (XMLSecurityManager)value; } else if (name.equals(XalanConstants.JDK_EXTENSION_CLASSLOADER)) { _extensionClassLoader = (ClassLoader) value; /* Clear the external extension functions HashMap if extension class loader was changed */ _externalExtensionFunctions.clear(); } else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) { _catalogFeatures = (CatalogFeatures)value; } else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) { _cdataChunkSize = Integer.parseInt((String)value); } }
Example #16
Source File: Extensions.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Returns a NodeSet containing one text node for each token in the first argument. * Delimiters are specified in the second argument. * Tokens are determined by a call to <code>StringTokenizer</code>. * If the first argument is an empty string or contains only delimiters, the result * will be an empty NodeSet. * * Contributed to XalanJ1 by <a href="mailto:[email protected]">Benoit Cerrina</a>. * * @param toTokenize The string to be split into text tokens. * @param delims The delimiters to use. * @return a NodeSet as described above. */ public static NodeList tokenize(String toTokenize, String delims) { Document doc = JdkXmlUtils.getDOMDocument(); StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims); NodeSet resultSet = new NodeSet(); synchronized (doc) { while (lTokenizer.hasMoreTokens()) { resultSet.addNode(doc.createTextNode(lTokenizer.nextToken())); } } return resultSet; }
Example #17
Source File: SAX2DOM.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private Document createDocument(boolean overrideDefaultParser) throws ParserConfigurationException { if (_factory == null) { _factory = JdkXmlUtils.getDOMFactory(overrideDefaultParser); _internal = true; if (!(_factory instanceof com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)) { _internal = false; } } Document doc; if (_internal) { //default implementation is thread safe doc = _factory.newDocumentBuilder().newDocument(); } else { synchronized(SAX2DOM.class) { doc = _factory.newDocumentBuilder().newDocument(); } } return doc; }
Example #18
Source File: SAX2DOM.java From JDKSourceCode1.8 with MIT License | 6 votes |
private Document createDocument(boolean overrideDefaultParser) throws ParserConfigurationException { if (_factory == null) { _factory = JdkXmlUtils.getDOMFactory(overrideDefaultParser); _internal = true; if (!(_factory instanceof com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)) { _internal = false; } } Document doc; if (_internal) { //default implementation is thread safe doc = _factory.newDocumentBuilder().newDocument(); } else { synchronized(SAX2DOM.class) { doc = _factory.newDocumentBuilder().newDocument(); } } return doc; }
Example #19
Source File: Extensions.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns a NodeSet containing one text node for each token in the first argument. * Delimiters are specified in the second argument. * Tokens are determined by a call to <code>StringTokenizer</code>. * If the first argument is an empty string or contains only delimiters, the result * will be an empty NodeSet. * * Contributed to XalanJ1 by <a href="mailto:[email protected]">Benoit Cerrina</a>. * * @param toTokenize The string to be split into text tokens. * @param delims The delimiters to use. * @return a NodeSet as described above. */ public static NodeList tokenize(String toTokenize, String delims) { Document doc = JdkXmlUtils.getDOMDocument(); StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims); NodeSet resultSet = new NodeSet(); synchronized (doc) { while (lTokenizer.hasMoreTokens()) { resultSet.addNode(doc.createTextNode(lTokenizer.nextToken())); } } return resultSet; }
Example #20
Source File: XMLSchemaFactory.java From JDKSourceCode1.8 with MIT License | 6 votes |
public XMLSchemaFactory() { fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance()); fDOMEntityResolverWrapper = new DOMEntityResolverWrapper(); fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper(); fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true); fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); fSecurityPropertyMgr = new XMLSecurityPropertyManager(); fXMLSchemaLoader.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr); fXmlFeatures = new JdkXmlFeatures(fSecurityManager.isSecureProcessing()); fOverrideDefaultParser = fXmlFeatures.getFeature( JdkXmlFeatures.XmlFeature.JDK_OVERRIDE_PARSER); fXMLSchemaLoader.setFeature(JdkXmlUtils.OVERRIDE_PARSER, fOverrideDefaultParser); }
Example #21
Source File: XPathImplUtil.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Parse the input source and return a Document. * @param source The {@code InputSource} of the document * @return a DOM Document * @throws XPathExpressionException if there is an error parsing the source. */ Document getDocument(InputSource source) throws XPathExpressionException { requireNonNull(source, "Source"); try { // we'd really like to cache those DocumentBuilders, but we can't because: // 1. thread safety. parsers are not thread-safe, so at least // we need one instance per a thread. // 2. parsers are non-reentrant, so now we are looking at having a // pool of parsers. // 3. then the class loading issue. The look-up procedure of // DocumentBuilderFactory.newInstance() depends on context class loader // and system properties, which may change during the execution of JVM. // // so we really have to create a fresh DocumentBuilder every time we need one // - KK DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(overrideDefaultParser); return dbf.newDocumentBuilder().parse(source); } catch (ParserConfigurationException | SAXException | IOException e) { throw new XPathExpressionException (e); } }
Example #22
Source File: Catalog.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Setup readers. */ public void setupReaders() { SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(false); SAXCatalogReader saxReader = new SAXCatalogReader(spf); saxReader.setCatalogParser(null, "XMLCatalog", "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", "com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader"); addReader("application/xml", saxReader); TR9401CatalogReader textReader = new TR9401CatalogReader(); addReader("text/plain", textReader); }
Example #23
Source File: Resolver.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Setup readers. */ public void setupReaders() { SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(false); SAXCatalogReader saxReader = new SAXCatalogReader(spf); saxReader.setCatalogParser(null, "XMLCatalog", "com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader"); saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", "com.sun.org.apache.xml.internal.resolver.readers.ExtendedXMLCatalogReader"); addReader("application/xml", saxReader); TR9401CatalogReader textReader = new TR9401CatalogReader(); addReader("text/plain", textReader); }
Example #24
Source File: Parser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Parses a stylesheet and builds the internal abstract syntax tree * @param input A SAX2 InputSource can be passed to a SAX reader * @return The root of the abstract syntax tree */ public SyntaxTreeNode parse(InputSource input) { final XMLReader reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, _xsltc.isSecureProcessing()); JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD, _xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true); String lastProperty = ""; try { XMLSecurityManager securityManager = (XMLSecurityManager) _xsltc.getProperty(XalanConstants.SECURITY_MANAGER); for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) { lastProperty = limit.apiProperty(); reader.setProperty(lastProperty, securityManager.getLimitValueAsString(limit)); } if (securityManager.printEntityCountInfo()) { lastProperty = XalanConstants.JDK_ENTITY_COUNT_INFO; reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES); } } catch (SAXException se) { XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se); } return (parse(reader, input)); }
Example #25
Source File: XPathAPI.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); // Create an object to resolve namespace prefixes. // XPath namespaces are resolved from the input context node's document element // if it is a root node, or else the current context node (for lack of a better // resolution space, given the simplicity of this sample code). PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result // return xpath.execute(xpathSupport, contextNode, prefixResolver); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example #26
Source File: ResolvingXMLReader.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Construct a new reader from the JAXP factory. * * <p>In order to do its job, a ResolvingXMLReader must in fact be * a filter. So the only difference between this code and the filter * code is that the constructor builds a new reader.</p> */ public ResolvingXMLReader(CatalogManager manager) { super(manager); SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(validating); try { SAXParser parser = spf.newSAXParser(); setParent(parser.getXMLReader()); } catch (Exception ex) { ex.printStackTrace(); } }
Example #27
Source File: TrAXFilter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void createParent() throws SAXException { XMLReader parent = JdkXmlUtils.getXMLReader(_overrideDefaultParser, _transformer.isSecureProcessing()); // make this XMLReader the parent of this filter setParent(parent); }
Example #28
Source File: TrAXFilter.java From Bytecoder with Apache License 2.0 | 5 votes |
private void createParent() throws SAXException { XMLReader parent = JdkXmlUtils.getXMLReader(_overrideDefaultParser, _transformer.isSecureProcessing()); // make this XMLReader the parent of this filter setParent(parent); }
Example #29
Source File: ResolvingXMLReader.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Construct a new reader from the JAXP factory. * * <p>In order to do its job, a ResolvingXMLReader must in fact be * a filter. So the only difference between this code and the filter * code is that the constructor builds a new reader.</p> */ public ResolvingXMLReader() { super(); SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser()); spf.setValidating(validating); try { SAXParser parser = spf.newSAXParser(); setParent(parser.getXMLReader()); } catch (Exception ex) { ex.printStackTrace(); } }
Example #30
Source File: StreamValidatorHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private XMLParserConfiguration initialize() { XML11Configuration config = new XML11Configuration(); if (fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) { config.setProperty(SECURITY_MANAGER, new XMLSecurityManager()); } config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER)); config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER)); XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER); config.setProperty(ERROR_REPORTER, errorReporter); // add message formatters if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { XMLMessageFormatter xmft = new XMLMessageFormatter(); errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft); errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft); } config.setProperty(SYMBOL_TABLE, fComponentManager.getProperty(SYMBOL_TABLE)); config.setProperty(VALIDATION_MANAGER, fComponentManager.getProperty(VALIDATION_MANAGER)); config.setDocumentHandler(fSchemaValidator); config.setDTDHandler(null); config.setDTDContentModelHandler(null); config.setProperty(Constants.XML_SECURITY_PROPERTY_MANAGER, fComponentManager.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER)); config.setProperty(Constants.SECURITY_MANAGER, fComponentManager.getProperty(Constants.SECURITY_MANAGER)); // Passing on the CatalogFeatures settings JdkXmlUtils.catalogFeaturesConfig2Config(fComponentManager, config); config.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, fComponentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE)); fConfiguration = new SoftReference<>(config); return config; }