Refine search
public Document parse(final DocumentBuilder parser) throws SAXException, IOException { InputSource inputSource = new InputSource(inputStream); inputSource.setSystemId("dummy://log4j.dtd"); return parser.parse(inputSource); } public String toString() {
@Override @Nullable public InputSource resolveEntity(String publicId, @Nullable String systemId) throws IOException { if (logger.isTraceEnabled()) { logger.trace("Trying to resolve XML entity with public id [" + publicId + "] and system id [" + systemId + "]"); } if (systemId != null) { String resourceLocation = getSchemaMappings().get(systemId); if (resourceLocation != null) { Resource resource = new ClassPathResource(resourceLocation, this.classLoader); try { InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isTraceEnabled()) { logger.trace("Found XML schema [" + systemId + "] in classpath: " + resourceLocation); } return source; } catch (FileNotFoundException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not find XML schema [" + systemId + "]: " + resource, ex); } } } } return null; }
public InputSource resolveEntity(String publicId, String systemId) { InputSource is = new InputSource(new ByteArrayInputStream(new byte[0])); is.setPublicId(publicId); is.setSystemId(systemId); return is; } }
public Document parse(final DocumentBuilder parser) throws SAXException, IOException { InputSource inputSource = new InputSource(reader); inputSource.setSystemId("dummy://log4j.dtd"); return parser.parse(inputSource); } public String toString() {
InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isTraceEnabled()) { logger.trace("Found beans DTD [" + systemId + "] in classpath: " + dtdFile);
/** * Create a SAX {@code InputSource} from the given resource. * <p>Sets the system identifier to the resource's {@code URL}, if available. * @param resource the resource * @return the input source created from the resource * @throws IOException if an I/O exception occurs * @see InputSource#setSystemId(String) * @see #getSystemId(org.springframework.core.io.Resource) */ public static InputSource createInputSource(Resource resource) throws IOException { InputSource inputSource = new InputSource(resource.getInputStream()); inputSource.setSystemId(getSystemId(resource)); return inputSource; }
source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isDebugEnabled()) { logger.debug("Found XML entity [" + systemId + "]: " + resource);
public Document parse(final DocumentBuilder parser) throws SAXException, IOException { URLConnection uConn = url.openConnection(); uConn.setUseCaches(false); InputStream stream = uConn.getInputStream(); try { InputSource src = new InputSource(stream); src.setSystemId(url.toString()); return parser.parse(src); } finally { stream.close(); } } public String toString() {
private static InputSource createInputSource(String publicId, Template raw) throws IOException, SAXException { StringWriter sw = new StringWriter(); try { raw.process(Collections.EMPTY_MAP, sw); } catch (TemplateException e) { throw new SAXException(e); } InputSource is = new InputSource(); is.setPublicId(publicId); is.setSystemId(raw.getName()); is.setCharacterStream(new StringReader(sw.toString())); return is; }
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId.equals(PREFS_DTD_NAME)) { InputSource result = new InputSource(new StringReader( PREFS_DTD)); result.setSystemId(PREFS_DTD_NAME); return result; } throw new SAXException("Invalid DOCTYPE declaration " + systemId); } });
private InputSource buildInputSource(String publicId, String systemId, InputStream dtdStream, boolean resolved) { if ( dtdStream == null ) { LOG.tracev( "Unable to locate [{0}] on classpath", systemId ); return null; } LOG.tracev( "Located [{0}] in classpath", systemId ); InputSource source = new InputSource( dtdStream ); source.setPublicId( publicId ); source.setSystemId( systemId ); this.resolved = resolved; return source; }
/** * Set the system identifier for this Source. If an input source * has already been set, it will set the system ID or that * input source, otherwise it will create a new input source. * * <p>The system identifier is optional if there is a byte stream * or a character stream, but it is still useful to provide one, * since the application can use it to resolve relative URIs * and can include it in error messages and warnings (the parser * will attempt to open a connection to the URI only if * no byte stream or character stream is specified).</p> * * @param systemId The system identifier as a URI string. */ public void setSystemId(String systemId) { if (null == inputSource) { inputSource = new InputSource(systemId); } else { inputSource.setSystemId(systemId); } }
@Override public InputSource resolveEntity(String publicId, String systemId) throws IOException { InputSource source = super.resolveEntity(publicId, systemId); if (source == null) { Resource resource = new ClassPathResource(TEST_XSD); source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); } return source; } }
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId.equals(PROP_DTD_NAME)) { InputSource result = new InputSource(new StringReader( PROP_DTD)); result.setSystemId(PROP_DTD_NAME); return result; } throw new SAXException("Invalid DOCTYPE declaration: " + systemId); } });
@Override @Nullable public InputSource resolveEntity(String publicId, @Nullable String systemId) throws IOException { if (logger.isTraceEnabled()) { logger.trace("Trying to resolve XML entity with public id [" + publicId + "] and system id [" + systemId + "]"); } if (systemId != null) { String resourceLocation = getSchemaMappings().get(systemId); if (resourceLocation != null) { Resource resource = new ClassPathResource(resourceLocation, this.classLoader); try { InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isTraceEnabled()) { logger.trace("Found XML schema [" + systemId + "] in classpath: " + resourceLocation); } return source; } catch (FileNotFoundException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not find XML schema [" + systemId + "]: " + resource, ex); } } } } return null; }
/** * Parse the content of the given <code>InputStream</code> as an * XML document and return a new DOM {@link Document} object. * An <code>IllegalArgumentException</code> is thrown if the * <code>InputStream</code> is null. * * @param is InputStream containing the content to be parsed. * @param systemId Provide a base for resolving relative URIs. * @return A new DOM Document object. * @exception IOException If any IO errors occur. * @exception SAXException If any parse errors occur. * @see org.xml.sax.DocumentHandler */ public Document parse(InputStream is, String systemId) throws SAXException, IOException { if (is == null) { throw new IllegalArgumentException("InputStream cannot be null"); } InputSource in = new InputSource(is); in.setSystemId(systemId); return parse(in); }
InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isTraceEnabled()) { logger.trace("Found beans DTD [" + systemId + "] in classpath: " + dtdFile);
/** * Compiles an XSL stylesheet passed in through an InputStream * @param stream An InputStream that will pass in the stylesheet contents * @param name The name of the translet class to generate * @return 'true' if the compilation was successful */ public boolean compile(InputStream stream, String name) { final InputSource input = new InputSource(stream); input.setSystemId(name); // We have nothing else!!! return compile(input, name); }
source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isDebugEnabled()) { logger.debug("Found XML entity [" + systemId + "]: " + resource);
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }