Reader r = bs.bootstrapInput(rcfg, false, XmlConsts.XML_V_UNKNOWN); if (bs.declaredXml11()) { rcfg.enableXml11(true); return FullDTDReader.readExternalSubset(src, rcfg, /*int.subset*/null, true, bs.getDeclaredVersion()); } catch (IOException ioe) { throw new WstxIOException(ioe);
private final String readXmlEncoding() throws IOException, WstxException { int c = checkKeyword(XmlConsts.XML_DECL_KW_ENCODING); if (c != CHAR_NULL) { reportUnexpectedChar(c, XmlConsts.XML_DECL_KW_ENCODING); } c = handleEq(XmlConsts.XML_DECL_KW_ENCODING); int len = readQuotedValue(mKeyword, c); /* Hmmh. How about "too long" encodings? Maybe just truncate them, * for now? */ if (len == 0) { // let's still detect missing value... reportPseudoAttrProblem(XmlConsts.XML_DECL_KW_ENCODING, null, null, null); } if (len < 0) { // will be truncated... return new String(mKeyword); } return new String(mKeyword, 0, len); }
mDocXmlVersion = bs.getDeclaredVersion(); mDocInputEncoding = bs.getInputEncoding(); mDocXmlEncoding = bs.getDeclaredEncoding(); String sa = bs.getStandalone(); if (sa == null) { mDocStandalone = DOC_STANDALONE_UNKNOWN;
/** * @param parent * @param entityName Name of the entity expanded to create this input * source: null when source created for the (main level) external * DTD subset entity. * @param xmlVersion Optional xml version identifier of the main parsed * document. Currently only relevant for checking that XML 1.0 document * does not include XML 1.1 external parsed entities. * If unknown, no checks will be done. */ public static ReaderSource constructEntitySource (ReaderConfig cfg, WstxInputSource parent, String entityName, InputBootstrapper bs, String pubId, SystemId sysId, int xmlVersion, Reader r) { // true -> do close the underlying Reader at EOF ReaderSource rs = new ReaderSource (cfg, parent, entityName, pubId, sysId, r, true); if (bs != null) { rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(), -bs.getInputColumn()); } return rs; }
r = bs.bootstrapInput(cfg, true, XmlConsts.XML_V_UNKNOWN); if (bs.declaredXml11()) { cfg.enableXml11(true);
protected void reportNull() throws WstxException { throw new WstxException("Illegal null byte in input stream", getLocation()); }
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; }
r = bs.bootstrapInput(cfg, true, XmlConsts.XML_V_UNKNOWN); if (bs.declaredXml11()) { cfg.enableXml11(true);
protected void reportXmlProblem(String msg) throws WstxException { throw new WstxParsingException(msg, getLocation()); }
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 sysId = ssrc.getSystemId(); URL ctxt = (parent == null) ? null : parent.getSource(); URL url = (sysId == null || sysId.length() == 0) ? null : URLUtil.urlFromSystemId(sysId, ctxt); 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.optimizedStreamFromURL(url); } bs = StreamBootstrapper.getInstance(in, pubId, sysId); } else { bs = ReaderBootstrapper.getInstance(r, pubId, sysId, null); } Reader r2 = bs.bootstrapInput(cfg, false, xmlVersion); return InputSourceFactory.constructEntitySource (cfg, parent, refName, bs, pubId, sysId, xmlVersion, ((url == null) ? ctxt : url), r2); }
private final String readXmlStandalone() throws IOException, WstxException int c = checkKeyword(XmlConsts.XML_DECL_KW_STANDALONE); if (c != CHAR_NULL) { reportUnexpectedChar(c, XmlConsts.XML_DECL_KW_STANDALONE); c = handleEq(XmlConsts.XML_DECL_KW_STANDALONE); int len = readQuotedValue(mKeyword, c); reportPseudoAttrProblem(XmlConsts.XML_DECL_KW_STANDALONE, got, XmlConsts.XML_SA_YES, XmlConsts.XML_SA_NO); return got; // never gets here, but compiler can't figure it out
/** * Factory method used for creating the main-level document reader * source. */ public static BranchingReaderSource constructDocumentSource (ReaderConfig cfg, InputBootstrapper bs, String pubId, String sysId, URL src, Reader r, boolean realClose) { BranchingReaderSource rs = new BranchingReaderSource (cfg, pubId, sysId, src, r, realClose); if (bs != null) { rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(), -bs.getInputColumn()); } return rs; }
mDocXmlVersion = bs.getDeclaredVersion(); mDocInputEncoding = bs.getInputEncoding(); mDocXmlEncoding = bs.getDeclaredEncoding(); String sa = bs.getStandalone(); if (sa == null) { mDocStandalone = DOC_STANDALONE_UNKNOWN;
Reader r = bs.bootstrapInput(rcfg, false, XmlConsts.XML_V_UNKNOWN); if (bs.declaredXml11()) { rcfg.enableXml11(true); return FullDTDReader.readExternalSubset(src, rcfg, /*int.subset*/null, true, bs.getDeclaredVersion()); } catch (IOException ioe) { throw new WstxIOException(ioe);
r = bs.bootstrapInput(cfg, true, XmlConsts.XML_V_UNKNOWN); if (bs.declaredXml11()) { cfg.enableXml11(true);
private final void reportPseudoAttrProblem(String attrName, String got, String expVal1, String expVal2) throws WstxException { String expStr = (expVal1 == null) ? "" : ("; expected \""+expVal1+"\" or \""+expVal2+"\""); if (got == null || got.length() == 0) { throw new WstxParsingException("Missing XML pseudo-attribute '"+attrName+"' value"+expStr, getLocation()); } throw new WstxParsingException("Invalid XML pseudo-attribute '"+attrName+"' value "+got+expStr, getLocation()); } }
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 sysId = ssrc.getSystemId(); URL ctxt = (parent == null) ? null : parent.getSource(); URL url = (sysId == null || sysId.length() == 0) ? null : URLUtil.urlFromSystemId(sysId, ctxt); 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.optimizedStreamFromURL(url); } bs = StreamBootstrapper.getInstance(in, pubId, sysId); } else { bs = ReaderBootstrapper.getInstance(r, pubId, sysId, null); } Reader r2 = bs.bootstrapInput(cfg, false, xmlVersion); return InputSourceFactory.constructEntitySource (cfg, parent, refName, bs, pubId, sysId, xmlVersion, ((url == null) ? ctxt : url), r2); }
throws IOException, WstxException int c = checkKeyword(XmlConsts.XML_DECL_KW_VERSION); if (c != CHAR_NULL) { reportUnexpectedChar(c, XmlConsts.XML_DECL_KW_VERSION); c = handleEq(XmlConsts.XML_DECL_KW_VERSION); int len = readQuotedValue(mKeyword, c); got = "'"+new String(mKeyword, 0, len)+"'"; reportPseudoAttrProblem(XmlConsts.XML_DECL_KW_VERSION, got, XmlConsts.XML_V_10_STR, XmlConsts.XML_V_11_STR); return XmlConsts.XML_V_UNKNOWN; // never gets here, but compiler needs it
/** * Factory method used for creating the main-level document reader * source. */ public static BranchingReaderSource constructDocumentSource (ReaderConfig cfg, InputBootstrapper bs, String pubId, String sysId, URL src, Reader r, boolean realClose) { BranchingReaderSource rs = new BranchingReaderSource (cfg, pubId, sysId, src, r, realClose); if (bs != null) { rs.setInputOffsets(bs.getInputTotal(), bs.getInputRow(), -bs.getInputColumn()); } return rs; }