private XMLStreamReader parse(InputStream is, String systemIdStr, boolean restricted) throws IOException, XMLStreamException { if (!quietmode) { LOG.debug("parsing input stream " + is); } if (is == null) { return null; } SystemId systemId = SystemId.construct(systemIdStr); ReaderConfig readerConfig = XML_INPUT_FACTORY.createPrivateConfig(); if (restricted) { readerConfig.setProperty(XMLInputFactory.SUPPORT_DTD, false); } return XML_INPUT_FACTORY.createSR(readerConfig, systemId, StreamBootstrapper.getInstance(null, systemId, is), false, true); }
public void overrideSource(URL src) { //19-May-2014, tatu: I assume this should also override observed systemId... mSystemId = SystemId.construct(src); }
public XMLStreamReader createXMLStreamReader(String systemId, Reader r) throws XMLStreamException { // false for auto-close, since caller has access to the Reader return createSR(SystemId.construct(systemId), r, false, false); }
public XMLStreamReader createXMLStreamReader(String systemId, InputStream in) throws XMLStreamException { // false for auto-close, since caller has access to the input stream return createSR(SystemId.construct(systemId), in, null, false, false); }
/** * Factory method usually used to expand internal parsed entities; in * which case context remains mostly the same. */ public static WstxInputSource constructCharArraySource (WstxInputSource parent, String fromEntity, char[] text, int offset, int len, Location loc, URL src) { SystemId sysId = SystemId.construct(loc.getSystemId(), src); return new CharArraySource(parent, fromEntity, text, offset, len, loc, sysId); } }
private static WstxInputSource sourceFromIS(WstxInputSource parent, ReaderConfig cfg, String refName, int xmlVersion, InputStream is, String pubId, String sysId) throws IOException, XMLStreamException { StreamBootstrapper bs = StreamBootstrapper.getInstance(pubId, SystemId.construct(sysId), is); Reader r = bs.bootstrapInput(cfg, false, xmlVersion); URL ctxt = parent.getSource(); // If we got a real sys id, we do know the source... if (sysId != null && sysId.length() > 0) { ctxt = URLUtil.urlFromSystemId(sysId, ctxt); } return InputSourceFactory.constructEntitySource (cfg, parent, refName, bs, pubId, SystemId.construct(sysId, ctxt), xmlVersion, r); }
private static WstxInputSource sourceFromR(WstxInputSource parent, ReaderConfig cfg, String refName, int xmlVersion, Reader r, String pubId, String sysId) throws IOException, XMLStreamException { /* Last null -> no app-provided encoding (doesn't matter for non- * main-level handling) */ ReaderBootstrapper rbs = ReaderBootstrapper.getInstance(pubId, SystemId.construct(sysId), r, null); // null -> no xml reporter... should have one? Reader r2 = rbs.bootstrapInput(cfg, false, xmlVersion); URL ctxt = (parent == null) ? null : parent.getSource(); if (sysId != null && sysId.length() > 0) { ctxt = URLUtil.urlFromSystemId(sysId, ctxt); } return InputSourceFactory.constructEntitySource (cfg, parent, refName, rbs, pubId, SystemId.construct(sysId, ctxt), xmlVersion, r2); } }
protected XMLStreamReader2 createSR(File f, boolean forER, boolean autoCloseInput) throws XMLStreamException { ReaderConfig cfg = createPrivateConfig(); try { /* 18-Nov-2008, TSa: If P_BASE_URL is set, and File reference is * relative, let's resolve against base... */ if (!f.isAbsolute()) { URL base = cfg.getBaseURL(); if (base != null) { URL src = new URL(base, f.getPath()); return createSR(cfg, SystemId.construct(src), URLUtil.inputStreamFromURL(src), forER, autoCloseInput); } } final SystemId systemId = SystemId.construct(f.toURL()); return createSR(cfg, systemId, new FileInputStream(f), forER, autoCloseInput); } catch (IOException ie) { throw new WstxIOException(ie); } }
public XMLEventReader createXMLEventReader(String systemId, Reader r) throws XMLStreamException { // false for auto-close, since caller has access to the reader return new WstxEventReader(createEventAllocator(), createSR(SystemId.construct(systemId), r, true, false)); }
protected XMLStreamReader2 createSR(ReaderConfig cfg, URL src, boolean forER, boolean autoCloseInput) throws XMLStreamException { final SystemId systemId = SystemId.construct(src); try { return createSR(cfg, systemId, URLUtil.inputStreamFromURL(src), forER, autoCloseInput); } catch (IOException ioe) { throw new WstxIOException(ioe); } }
public XMLValidationSchema createSchema(Reader r, String publicId, String systemId) throws XMLStreamException { ReaderConfig rcfg = createPrivateReaderConfig(); return doCreateSchema(rcfg, ReaderBootstrapper.getInstance (publicId, SystemId.construct(systemId), r, null), publicId, systemId, null); }
public XMLValidationSchema createSchema(InputStream in, String encoding, String publicId, String systemId) throws XMLStreamException { ReaderConfig rcfg = createPrivateReaderConfig(); return doCreateSchema(rcfg, StreamBootstrapper.getInstance (publicId, SystemId.construct(systemId), in), publicId, systemId, null); }
public XMLEventReader createXMLEventReader(String systemId, InputStream in) throws XMLStreamException { // false for auto-close, since caller has access to the input stream return new WstxEventReader(createEventAllocator(), createSR(SystemId.construct(systemId), in, null, true, false)); }
private static WstxInputSource sourceFromURL(WstxInputSource parent, ReaderConfig cfg, String refName, int xmlVersion, URL url, String pubId) throws IOException, XMLStreamException { /* And then create the input source. Note that by default URL's * own input stream creation creates buffered reader -- for us * that's useless and wasteful (adds one unnecessary level of * caching, halving the speed due to copy operations needed), so * let's avoid it. */ InputStream in = URLUtil.inputStreamFromURL(url); SystemId sysId = SystemId.construct(url); StreamBootstrapper bs = StreamBootstrapper.getInstance(pubId, sysId, in); Reader r = bs.bootstrapInput(cfg, false, xmlVersion); return InputSourceFactory.constructEntitySource (cfg, parent, refName, bs, pubId, sysId, xmlVersion, r); }
return doCreateSR(cfg, SystemId.construct(systemId, src), bs, forER, autoCloseInput);
private static WstxInputSource sourceFromSS(WstxInputSource parent, ReaderConfig cfg, String refName, int xmlVersion, StreamSource ssrc) throws IOException, XMLStreamException { InputBootstrapper bs; Reader r = ssrc.getReader(); String pubId = ssrc.getPublicId(); String sysId0 = ssrc.getSystemId(); URL ctxt = (parent == null) ? null : parent.getSource(); URL url = (sysId0 == null || sysId0.length() == 0) ? null : URLUtil.urlFromSystemId(sysId0, ctxt); final SystemId systemId = SystemId.construct(sysId0, (url == null) ? ctxt : url); if (r == null) { InputStream in = ssrc.getInputStream(); if (in == null) { // Need to try just resolving the system id then if (url == null) { throw new IllegalArgumentException("Can not create Stax reader for a StreamSource -- neither reader, input stream nor system id was set."); } in = URLUtil.inputStreamFromURL(url); } bs = StreamBootstrapper.getInstance(pubId, systemId, in); } else { bs = ReaderBootstrapper.getInstance(pubId, systemId, r, null); } Reader r2 = bs.bootstrapInput(cfg, false, xmlVersion); return InputSourceFactory.constructEntitySource (cfg, parent, refName, bs, pubId, systemId, xmlVersion, r2); }
/** * Factory method used for creating the main-level document reader * source. */ public static BranchingReaderSource constructDocumentSource (ReaderConfig cfg, InputBootstrapper bs, String pubId, SystemId sysId, Reader r, boolean realClose) { /* To resolve [WSTX-50] need to ensure that P_BASE_URL overrides * the defaults if/as necessary */ URL url = cfg.getBaseURL(); if (url != null) { sysId = SystemId.construct(url); } BranchingReaderSource rs = new BranchingReaderSource(cfg, pubId, sysId, r, realClose); if (bs != null) { rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(), -bs.getInputColumn()); } return rs; }
SystemId systemId = SystemId.construct(sysIdStr, srcUrl); if (r != null) { bs = ReaderBootstrapper.getInstance(publicId, systemId, r, inputEnc);
bs = StreamBootstrapper.getInstance(pubId, SystemId.construct(sysId), bas.getBuffer(), bas.getBufferStart(), bas.getBufferEnd()); } else { in = ss.constructInputStream(); bs = ReaderBootstrapper.getInstance(pubId, SystemId.construct(sysId), r, encoding); } else if (in != null) { bs = StreamBootstrapper.getInstance(pubId, SystemId.construct(sysId), in); } else if (sysId != null && sysId.length() > 0) {
SystemId systemId = SystemId.construct(systemIdStr, ctxt); WstxInputSource src = InputSourceFactory.constructEntitySource (rcfg, null, null, bs, publicId, systemId, XmlConsts.XML_V_UNKNOWN, r);