Java Code Examples for jdk.xml.internal.JdkXmlUtils#getXMLReader()
The following examples show how to use
jdk.xml.internal.JdkXmlUtils#getXMLReader() .
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: 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 2
Source File: Parser.java From JDKSourceCode1.8 with MIT License | 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 3
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 4
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 5
Source File: TrAXFilter.java From TencentKona-8 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 6
Source File: TrAXFilter.java From JDKSourceCode1.8 with MIT License | 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 7
Source File: TrAXFilter.java From openjdk-jdk8u 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 8
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 9
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 10
Source File: TransformerFactoryImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * javax.xml.transform.sax.TransformerFactory implementation. * Get the stylesheet specification(s) associated via the xml-stylesheet * processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with * the document document specified in the source parameter, and that match * the given criteria. * * @param source The XML source document. * @param media The media attribute to be matched. May be null, in which * case the prefered templates will be used (i.e. alternate = no). * @param title The value of the title attribute to match. May be null. * @param charset The value of the charset attribute to match. May be null. * @return A Source object suitable for passing to the TransformerFactory. * @throws TransformerConfigurationException */ @Override public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { String baseId; XMLReader reader = null; InputSource isource; /** * Fix for bugzilla bug 24187 */ StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset); try { if (source instanceof DOMSource ) { final DOMSource domsrc = (DOMSource) source; baseId = domsrc.getSystemId(); final org.w3c.dom.Node node = domsrc.getNode(); final DOM2SAX dom2sax = new DOM2SAX(node); _stylesheetPIHandler.setBaseId(baseId); dom2sax.setContentHandler( _stylesheetPIHandler); dom2sax.parse(); } else { if (source instanceof SAXSource) { reader = ((SAXSource)source).getXMLReader(); } isource = SAXSource.sourceToInputSource(source); baseId = isource.getSystemId(); if (reader == null) { reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, !_isNotSecureProcessing); } _stylesheetPIHandler.setBaseId(baseId); reader.setContentHandler(_stylesheetPIHandler); reader.parse(isource); } if (_uriResolver != null ) { _stylesheetPIHandler.setURIResolver(_uriResolver); } } catch (StopParseException e ) { // startElement encountered so do not parse further } catch (org.xml.sax.SAXException se) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", se); } catch (IOException ioe ) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", ioe); } return _stylesheetPIHandler.getAssociatedStylesheet(); }
Example 11
Source File: TransformerFactoryImpl.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * javax.xml.transform.sax.TransformerFactory implementation. * Get the stylesheet specification(s) associated via the xml-stylesheet * processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with * the document document specified in the source parameter, and that match * the given criteria. * * @param source The XML source document. * @param media The media attribute to be matched. May be null, in which * case the prefered templates will be used (i.e. alternate = no). * @param title The value of the title attribute to match. May be null. * @param charset The value of the charset attribute to match. May be null. * @return A Source object suitable for passing to the TransformerFactory. * @throws TransformerConfigurationException */ @Override public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { String baseId; XMLReader reader = null; InputSource isource; /** * Fix for bugzilla bug 24187 */ StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset); try { if (source instanceof DOMSource ) { final DOMSource domsrc = (DOMSource) source; baseId = domsrc.getSystemId(); final org.w3c.dom.Node node = domsrc.getNode(); final DOM2SAX dom2sax = new DOM2SAX(node); _stylesheetPIHandler.setBaseId(baseId); dom2sax.setContentHandler( _stylesheetPIHandler); dom2sax.parse(); } else { if (source instanceof SAXSource) { reader = ((SAXSource)source).getXMLReader(); } isource = SAXSource.sourceToInputSource(source); baseId = isource.getSystemId(); if (reader == null) { reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, !_isNotSecureProcessing); } _stylesheetPIHandler.setBaseId(baseId); reader.setContentHandler(_stylesheetPIHandler); reader.parse(isource); } if (_uriResolver != null ) { _stylesheetPIHandler.setURIResolver(_uriResolver); } } catch (StopParseException e ) { // startElement encountered so do not parse further } catch (org.xml.sax.SAXException se) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", se); } catch (IOException ioe ) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", ioe); } return _stylesheetPIHandler.getAssociatedStylesheet(); }
Example 12
Source File: TransformerFactoryImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * javax.xml.transform.sax.TransformerFactory implementation. * Get the stylesheet specification(s) associated via the xml-stylesheet * processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with * the document document specified in the source parameter, and that match * the given criteria. * * @param source The XML source document. * @param media The media attribute to be matched. May be null, in which * case the prefered templates will be used (i.e. alternate = no). * @param title The value of the title attribute to match. May be null. * @param charset The value of the charset attribute to match. May be null. * @return A Source object suitable for passing to the TransformerFactory. * @throws TransformerConfigurationException */ @Override public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { String baseId; XMLReader reader = null; InputSource isource; /** * Fix for bugzilla bug 24187 */ StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset); try { if (source instanceof DOMSource ) { final DOMSource domsrc = (DOMSource) source; baseId = domsrc.getSystemId(); final org.w3c.dom.Node node = domsrc.getNode(); final DOM2SAX dom2sax = new DOM2SAX(node); _stylesheetPIHandler.setBaseId(baseId); dom2sax.setContentHandler( _stylesheetPIHandler); dom2sax.parse(); } else { if (source instanceof SAXSource) { reader = ((SAXSource)source).getXMLReader(); } isource = SAXSource.sourceToInputSource(source); baseId = isource.getSystemId(); if (reader == null) { reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, !_isNotSecureProcessing); } _stylesheetPIHandler.setBaseId(baseId); reader.setContentHandler(_stylesheetPIHandler); reader.parse(isource); } if (_uriResolver != null ) { _stylesheetPIHandler.setURIResolver(_uriResolver); } } catch (StopParseException e ) { // startElement encountered so do not parse further } catch (org.xml.sax.SAXException se) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", se); } catch (IOException ioe ) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", ioe); } return _stylesheetPIHandler.getAssociatedStylesheet(); }
Example 13
Source File: TransformerFactoryImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * javax.xml.transform.sax.TransformerFactory implementation. * Get the stylesheet specification(s) associated via the xml-stylesheet * processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with * the document document specified in the source parameter, and that match * the given criteria. * * @param source The XML source document. * @param media The media attribute to be matched. May be null, in which * case the prefered templates will be used (i.e. alternate = no). * @param title The value of the title attribute to match. May be null. * @param charset The value of the charset attribute to match. May be null. * @return A Source object suitable for passing to the TransformerFactory. * @throws TransformerConfigurationException */ @Override public Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException { String baseId; XMLReader reader = null; InputSource isource; /** * Fix for bugzilla bug 24187 */ StylesheetPIHandler _stylesheetPIHandler = new StylesheetPIHandler(null,media,title,charset); try { if (source instanceof DOMSource ) { final DOMSource domsrc = (DOMSource) source; baseId = domsrc.getSystemId(); final org.w3c.dom.Node node = domsrc.getNode(); final DOM2SAX dom2sax = new DOM2SAX(node); _stylesheetPIHandler.setBaseId(baseId); dom2sax.setContentHandler( _stylesheetPIHandler); dom2sax.parse(); } else { if (source instanceof SAXSource) { reader = ((SAXSource)source).getXMLReader(); } isource = SAXSource.sourceToInputSource(source); baseId = isource.getSystemId(); if (reader == null) { reader = JdkXmlUtils.getXMLReader(_overrideDefaultParser, !_isNotSecureProcessing); } _stylesheetPIHandler.setBaseId(baseId); reader.setContentHandler(_stylesheetPIHandler); reader.parse(isource); } if (_uriResolver != null ) { _stylesheetPIHandler.setURIResolver(_uriResolver); } } catch (StopParseException e ) { // startElement encountered so do not parse further } catch (org.xml.sax.SAXException se) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", se); } catch (IOException ioe ) { throw new TransformerConfigurationException( "getAssociatedStylesheets failed", ioe); } return _stylesheetPIHandler.getAssociatedStylesheet(); }