Refine search
@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; }
/** * Attempt to obtain a SAX InputSource object from a Source * object. * * @param source Must be a non-null Source reference. * * @return An InputSource, or null if Source can not be converted. */ public static InputSource sourceToInputSource(Source source) { if (source instanceof SAXSource) { return ((SAXSource) source).getInputSource(); } else if (source instanceof StreamSource) { StreamSource ss = (StreamSource) source; InputSource isource = new InputSource(ss.getSystemId()); isource.setByteStream(ss.getInputStream()); isource.setCharacterStream(ss.getReader()); isource.setPublicId(ss.getPublicId()); return isource; } else { return null; } } }
static InputSource createInputSource(Identifier id, Input input) { InputSource inputSource = createInputSource(input); if (id instanceof ExternalIdentifier) inputSource.setPublicId(((ExternalIdentifier)id).getPublicId()); if (inputSource.getSystemId() == null) inputSource.setSystemId(getSystemId(id)); return inputSource; }
public InputSource resolveEntity(String publicId, String systemId) { InputSource is = new InputSource(new ByteArrayInputStream(new byte[0])); is.setPublicId(publicId); is.setSystemId(systemId); return is; } }
final InputSource iSource = new InputSource(resolved); iSource.setPublicId(publicId); iSource.setByteStream(is); return iSource;
static InputSource createInputSource(Identifier id, Input input) { InputSource inputSource = createInputSource(input); if (id instanceof ExternalIdentifier) inputSource.setPublicId(((ExternalIdentifier)id).getPublicId()); if (inputSource.getSystemId() == null) inputSource.setSystemId(getSystemId(id)); return inputSource; }
InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isTraceEnabled()) { logger.trace("Found beans DTD [" + systemId + "] in classpath: " + dtdFile);
private InputSource getInputSource(URL url) { InputSource is = new InputSource(url.toExternalForm()); is.setPublicId(url.toString()); return is; }
static InputSource createInputSource(Identifier id, Input input) { InputSource inputSource = createInputSource(input); if (id instanceof ExternalIdentifier) inputSource.setPublicId(((ExternalIdentifier)id).getPublicId()); if (inputSource.getSystemId() == null) inputSource.setSystemId(getSystemId(id)); return inputSource; }
source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isDebugEnabled()) { logger.debug("Found XML entity [" + systemId + "]: " + resource);
/** * Sets the public identifier. * * @param publicId The new public identifier. */ public void setPublicId(String publicId) { super.setPublicId(publicId); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setPublicId(publicId); } // setPublicId(String)
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 static Document getDocumentFromStream( InputStream stream, EntityResolver er, String publicId) throws IOException, SAXException { DocumentBuilder builder = getThreadDocumentBuilder(); builder.setEntityResolver(er); InputSource source = new InputSource(stream); source.setPublicId(publicId); Document doc = builder.parse(source); return doc; }
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; }
/** * Sets the public identifier. * * @param publicId The new public identifier. */ public void setPublicId(String publicId) { super.setPublicId(publicId); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setPublicId(publicId); } // setPublicId(String)
@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 static Document getDocumentFromStream( InputStream stream, EntityResolver er, String publicId) throws IOException, SAXException { DocumentBuilder builder = getThreadDocumentBuilder(); builder.setEntityResolver(er); InputSource source = new InputSource(stream); source.setPublicId(publicId); Document doc = builder.parse(source); return doc; }
@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; }
/** * Sets the public identifier. * * @param publicId The new public identifier. */ public void setPublicId(String publicId) { super.setPublicId(publicId); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setPublicId(publicId); } // setPublicId(String)
InputSource source = new InputSource(resource.getInputStream()); source.setPublicId(publicId); source.setSystemId(systemId); if (logger.isTraceEnabled()) { logger.trace("Found beans DTD [" + systemId + "] in classpath: " + dtdFile);