/** * Creates a JDOM TrAX source wrapping a JDOM element with an * associated EntityResolver to resolve external entities. * * @param source The JDOM Element to use as source for the * transformations * * @param resolver Entity resolver to use for the source * transformation * * @throws IllegalArgumentException if<code>source</code> is * <code>null</code> */ public JDOMSource(Document source, EntityResolver resolver) { setDocument(source); this.resolver = resolver; if (source != null && source.getBaseURI() != null) { super.setSystemId(source.getBaseURI()); } }
@Override public void setSystemId(String systemId) { super.setSystemId(systemId); LazySaxSourceProvider.this.systemId=systemId; }
/** * Set the InputSource part of the returned SAXSource. This is done in a separate * method to allow subclassing. The default implementation simply places the URI in the * InputSource, allowing the XML parser to take responsibility for the dereferencing. * A subclass may choose to dereference the URI at this point an place an InputStream * in the SAXSource. * @param source the SAXSource being initialized * @param uriString the absolute (resolved) URI to be used */ protected void setSAXInputSource(SAXSource source, String uriString) { source.setInputSource(new InputSource(uriString)); source.setSystemId(uriString); }
@Override public Source get() { SAXSource src=new ProxiedSAXSource(); src.setSystemId(this.systemId); return src; } private class ProxiedSAXSource extends SAXSource{
/** * Set the InputSource part of the returned SAXSource. This is done in a separate * method to allow subclassing. The default implementation simply places the URI in the * InputSource, allowing the XML parser to take responsibility for the dereferencing. * A subclass may choose to dereference the URI at this point an place an InputStream * in the SAXSource. * @param source the SAXSource being initialized * @param uriString the absolute (resolved) URI to be used */ protected void setSAXInputSource(SAXSource source, String uriString) { source.setInputSource(new InputSource(uriString)); source.setSystemId(uriString); }
/** * Resolve by searching the classpath, fallback to default resolution * strategy. * */ @Override public Source resolve(String href, String base) throws TransformerException { ClassLoader cl = getClass().getClassLoader(); URL url = cl.getResource(href); if (url != null) { SAXSource saxSource = new SAXSource(); saxSource.setInputSource(new InputSource(url.toString())); saxSource.setSystemId(url.toString()); return saxSource; } else { return standardResolver.resolve(href, base); } }
static public XdmNode readFromURIinsideConfig(String pathOrURI, Processor saxonproc, URI relativeTo) { URL url = URIinsideConfig(pathOrURI, relativeTo); if (url != null) { try { SAXSource source = new SAXSource(new InputSource(url.openStream())); source.setSystemId(url.toString()); return saxonproc.newDocumentBuilder().build(source); } catch (Exception e) { Logger.debug("error while reading " + url + ": " + e); } } return null; }
/** * 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; }
/** * Set the InputSource part of the returned SAXSource. This is done in a separate * method to allow subclassing. The default implementation checks for the (Spring-defined) * "classpath" URI scheme, and if this is in use, it attempts to locate the resource on the * classpath and set the supplied SAXSource to use the corresponding input stream. * In other cases it simply places the URI in the * InputSource, allowing the XML parser to take responsibility for the dereferencing. * A subclass may choose to dereference the URI at this point and place an InputStream * in the SAXSource. * * @param source the SAXSource being initialized * @param uriString the absolute (resolved) URI to be used */ protected void setSAXInputSource(SAXSource source, String uriString) { if (uriString.startsWith("classpath:") && uriString.length() > 10) { InputStream is = getConfiguration().getDynamicLoader().getResourceAsStream(uriString.substring(10)); if (is != null) { source.setInputSource(new InputSource(is)); source.setSystemId(uriString); return; } } source.setInputSource(new InputSource(uriString)); source.setSystemId(uriString); }
/** * Set the InputSource part of the returned SAXSource. This is done in a separate * method to allow subclassing. The default implementation checks for the (Spring-defined) * "classpath" URI scheme, and if this is in use, it attempts to locate the resource on the * classpath and set the supplied SAXSource to use the corresponding input stream. * In other cases it simply places the URI in the * InputSource, allowing the XML parser to take responsibility for the dereferencing. * A subclass may choose to dereference the URI at this point and place an InputStream * in the SAXSource. * * @param source the SAXSource being initialized * @param uriString the absolute (resolved) URI to be used */ protected void setSAXInputSource(SAXSource source, String uriString) { if (uriString.startsWith("classpath:") && uriString.length() > 10) { InputStream is = getConfiguration().getDynamicLoader().getResourceAsStream(uriString.substring(10)); if (is != null) { source.setInputSource(new InputSource(is)); source.setSystemId(uriString); return; } } source.setInputSource(new InputSource(uriString)); source.setSystemId(uriString); }
/** * Returns a SAX source. * * @param xmlRepresentation * The XML representation to wrap. * @return A SAX source. * @throws IOException */ public static SAXSource getSaxSource(Representation xmlRepresentation) throws IOException { SAXSource result = null; if (xmlRepresentation != null) { result = new SAXSource(new InputSource(xmlRepresentation .getStream())); if (xmlRepresentation.getIdentifier() != null) { result.setSystemId(xmlRepresentation.getIdentifier() .getTargetRef().toString()); } } return result; }
/** * Returns a SAX source. * * @param xmlRepresentation * The XML representation to wrap. * @return A SAX source. * @throws IOException */ public static javax.xml.transform.sax.SAXSource getSaxSource( Representation xmlRepresentation) throws IOException { javax.xml.transform.sax.SAXSource result = null; if (xmlRepresentation != null) { result = new javax.xml.transform.sax.SAXSource(new InputSource( xmlRepresentation.getStream())); if (xmlRepresentation.getLocationRef() != null) { result.setSystemId(xmlRepresentation.getLocationRef() .getTargetRef().toString()); } } return result; }
/** * Returns a SAX source. * * @param xmlRepresentation * The XML representation to wrap. * @return A SAX source. * @throws IOException */ public static SAXSource getSaxSource(Representation xmlRepresentation) throws IOException { SAXSource result = null; if (xmlRepresentation != null) { result = new SAXSource(new InputSource(xmlRepresentation .getStream())); if (xmlRepresentation.getIdentifier() != null) { result.setSystemId(xmlRepresentation.getIdentifier() .getTargetRef().toString()); } } return result; }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. * @throws IOException */ public SaxRepresentation(Representation xmlRepresentation) { super(xmlRepresentation.getMediaType()); try { if (xmlRepresentation instanceof XmlRepresentation) { this.source = ((XmlRepresentation) xmlRepresentation) .getSaxSource(); } else { this.source = new SAXSource(new InputSource(xmlRepresentation .getStream())); } if (xmlRepresentation.getIdentifier() != null) { this.source.setSystemId(xmlRepresentation.getIdentifier() .getTargetRef().toString()); } } catch (IOException ioe) { ioe.printStackTrace(); } }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. * @throws IOException */ public SaxRepresentation(Representation xmlRepresentation) { super((xmlRepresentation == null) ? null : xmlRepresentation .getMediaType()); try { if (xmlRepresentation instanceof XmlRepresentation) { this.source = ((XmlRepresentation) xmlRepresentation) .getSaxSource(); } else { this.source = new SAXSource(new InputSource(xmlRepresentation .getStream())); } if (xmlRepresentation.getIdentifier() != null) { this.source.setSystemId(xmlRepresentation.getIdentifier() .getTargetRef().toString()); } } catch (IOException ioe) { ioe.printStackTrace(); } }
source.setXMLReader(filter); if (systemId != null) { source.setSystemId(systemId);
source.setXMLReader(filter); if (systemId != null) { source.setSystemId(systemId);
builder.setStatistics(Statistics.SOURCE_DOCUMENT_STATISTICS); SAXSource source = new SAXSource(in); source.setSystemId(in.getSystemId()); Sender.send(source, builder, parseOptions); TinyDocumentImpl doc = (TinyDocumentImpl) builder.getCurrentRoot();
builder.setStatistics(config.getTreeStatistics().SOURCE_DOCUMENT_STATISTICS); SAXSource source = new SAXSource(in); source.setSystemId(in.getSystemId()); Sender.send(source, builder, parseOptions); TinyDocumentImpl doc = (TinyDocumentImpl) builder.getCurrentRoot();