Refine search
InputSource input = new InputSource(file.toURI().toASCIIString()); input.setByteStream(in); JAXP.newSAXParser().parse(input,new DefaultHandler() { private Locator loc;
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
private static void parseXml(InputStream in, String systemId, DefaultHandler handler) throws SAXException, IOException { InputSource inSrc = new InputSource(); inSrc.setSystemId(systemId); inSrc.setByteStream(toCloseIgnoring(in)); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(false); factory.setValidating(false); // Especially as we use dummy empty DTD-s XMLReader reader; try { reader = factory.newSAXParser().getXMLReader(); } catch (ParserConfigurationException e) { // Not expected throw new RuntimeException("XML parser setup failed", e); } reader.setEntityResolver(new EmptyContentEntityResolver()); // To deal with referred DTD-s reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.parse(inSrc); }
InputSource source = new InputSource(url.toExternalForm()); source.setByteStream(is); document = builder.parse(source);
/** * 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; } } }
InputSource in = new InputSource(); is = fo.getInputStream(); in.setByteStream(is); in.setSystemId(fo.toURL().toExternalForm()); customizeInputSource(in);
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
final InputSource iSource = new InputSource(resolved); iSource.setPublicId(publicId); iSource.setByteStream(is); return iSource;
public InputSource resolveEntity(String publicId, String systemId) throws SAXException { InputSource inputSource2 = new InputSource(systemId); inputSource2.setByteStream(new ByteArrayInputStream(new byte[0])); return inputSource2; }
private InputSource createSource(String msg) { InputSource source = new InputSource(); byte[] msgByte = msg.getBytes(); ByteArrayInputStream in = new ByteArrayInputStream(msgByte); source.setByteStream(in); return source; }
URL url = new URL("http://some-page-with-utf8-encodeing.tld"); InputSource is = new InputSource(); is.setEncoding("UTF-8"); is.setByteStream(url.openStream()); String text = ArticleExtractor.INSTANCE.getText(is);
public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException { if ("xhtml11-flat.dtd".equals(systemId)) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); InputSource is = new InputSource(); is.setSystemId(systemId); is.setByteStream(cl.getResourceAsStream("/com/example/dtd/xhtml11-flat.dtd")); return is; } else { return null; } }
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { String name = ENTITIES.get(publicId); if (name == null) name = ENTITIES.get(systemId); InputStream stream = name != null ? getClass().getResourceAsStream(name) : new ByteArrayInputStream(new byte[0]); InputSource is = new InputSource(); is.setByteStream(stream); is.setPublicId(publicId); is.setSystemId(systemId); return is; } }
public InputSource getBaseInputSource() { try { InputSource is = new InputSource(); is.setByteStream(openResource(baseUri)); is.setSystemId(baseUri.toString()); return is; } catch (IOException e) { log.error("Unable to create InputSource for " + baseUri, e); return null; } }
/** * Transform to InputSource. * @param string Input String. * @return InputSource. */ @Transformer public InputSource toInputSource(String string) { InputSource inputSource = new InputSource(); inputSource.setByteStream(new ByteArrayInputStream(string.getBytes())); inputSource.setCharacterStream(new StringReader(string)); return inputSource; }
public InputSource getBaseInputSource() { try { InputSource is = new InputSource(); is.setByteStream(_resourceFinder.openResource(_base)); is.setSystemId(_base.toString()); return is; } catch (MalformedURLException e) { return null; } catch (IOException e) { return null; } }
private InputSource copyInputSource(InputSource source, byte[] stream) { InputSource is = new InputSource(source.getSystemId()); is.setPublicId(source.getPublicId()); is.setEncoding(source.getEncoding()); if (stream != null) { is.setByteStream(new ByteArrayInputStream(stream)); } return is; }
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }
private static InputSource streamSourceToInputSource( StreamSource ss ) { InputSource is = new InputSource(); is.setSystemId( ss.getSystemId() ); is.setByteStream( ss.getInputStream() ); is.setCharacterStream( ss.getReader() ); return is; }