/** * Create a SAXSource from a Reader. Any entities will be resolved using JSTL semantics. * * @param reader the source of the XML * @param systemId the system id * @param entityResolver for resolving using JSTL semamtics * @return a new SAXSource * @throws ParserConfigurationException if there was a configuration problem creating the source * @throws SAXException if there was a problem creating the source */ public static SAXSource newSAXSource(Reader reader, String systemId, JstlEntityResolver entityResolver) throws ParserConfigurationException, SAXException { SAXSource source = new SAXSource(newXMLReader(entityResolver), new InputSource(reader)); source.setSystemId(wrapSystemId(systemId)); return source; }
/** * Create a SAXSource from a Reader. Any entities will be resolved using JSTL semantics. * * @param reader the source of the XML * @param systemId the system id * @param entityResolver for resolving using JSTL semamtics * @return a new SAXSource * @throws ParserConfigurationException if there was a configuration problem creating the source * @throws SAXException if there was a problem creating the source */ public static SAXSource newSAXSource(Reader reader, String systemId, JstlEntityResolver entityResolver) throws ParserConfigurationException, SAXException { SAXSource source = new SAXSource(newXMLReader(entityResolver), new InputSource(reader)); source.setSystemId(wrapSystemId(systemId)); return source; }
/** * Parses the given InputSource after, applying the given XMLFilter. */ private Document parseInputSourceWithFilter(InputSource s, XMLFilter f) throws JspException { try { XMLReader xr = XmlUtil.newXMLReader(entityResolver); // (note that we overwrite the filter's parent. this seems // to be expected usage. we could cache and reset the old // parent, but you can't setParent(null), so this wouldn't // be perfect.) f.setParent(xr); TransformerHandler th = XmlUtil.newTransformerHandler(); Document o = XmlUtil.newEmptyDocument(); th.setResult(new DOMResult(o)); f.setContentHandler(th); f.parse(s); return o; } catch (IOException e) { throw new JspException(e); } catch (SAXException e) { throw new JspException(e); } catch (TransformerConfigurationException e) { throw new JspException(e); } catch (ParserConfigurationException e) { throw new JspException(e); } }
/** * Parses the given InputSource after, applying the given XMLFilter. */ private Document parseInputSourceWithFilter(InputSource s, XMLFilter f) throws JspException { try { XMLReader xr = XmlUtil.newXMLReader(entityResolver); // (note that we overwrite the filter's parent. this seems // to be expected usage. we could cache and reset the old // parent, but you can't setParent(null), so this wouldn't // be perfect.) f.setParent(xr); TransformerHandler th = XmlUtil.newTransformerHandler(); Document o = XmlUtil.newEmptyDocument(); th.setResult(new DOMResult(o)); f.setContentHandler(th); f.parse(s); return o; } catch (IOException e) { throw new JspException(e); } catch (SAXException e) { throw new JspException(e); } catch (TransformerConfigurationException e) { throw new JspException(e); } catch (ParserConfigurationException e) { throw new JspException(e); } }
XMLReader xmlReader = XmlUtil.newXMLReader(null); xmlReader.setContentHandler(h); InputStream inputStream = page.getInputStream();
XMLReader xmlReader = XmlUtil.newXMLReader(null); xmlReader.setContentHandler(h); InputStream inputStream = page.getInputStream();