public static URL urlFromSystemId(String sysId, URL ctxt) throws IOException { if (ctxt == null) { return urlFromSystemId(sysId); } try { return new URL(ctxt, sysId); } catch (MalformedURLException e) { throwIOException(e, sysId); return null; // never gets here } }
/** * A very simple utility expansion method used generally when the * only way to resolve an entity is via passed resolver; and where * failing to resolve it is not fatal. */ public static WstxInputSource resolveEntityUsing (WstxInputSource refCtxt, String entityName, String publicId, String systemId, XMLResolver resolver, ReaderConfig cfg, int xmlVersion) throws IOException, XMLStreamException { URL ctxt = (refCtxt == null) ? null : refCtxt.getSource(); if (ctxt == null) { ctxt = URLUtil.urlFromCurrentDir(); } Object source = resolver.resolveEntity(publicId, systemId, ctxt.toExternalForm(), entityName); return (source == null) ? null : sourceFrom(refCtxt, cfg, entityName, xmlVersion, source); }
public XMLValidationSchema createSchema(URL url) throws XMLStreamException { try { InputStream in = URLUtil.inputStreamFromURL(url); InputSource src = new InputSource(in); src.setSystemId(url.toExternalForm()); return loadSchema(src, url); } catch (IOException ioe) { throw new WstxIOException(ioe); } }
/** * Method called to resolve path to external DTD subset, given * system identifier. */ private URI resolveExtSubsetPath(String systemId) throws IOException { // Do we have a context to use for resolving? URL ctxt = (mInput == null) ? null : mInput.getSource(); /* Ok, either got a context or not; let's create the URL based on * the id, and optional context: */ if (ctxt == null) { /* Call will try to figure out if system id has the protocol * in it; if not, create a relative file, if it does, try to * resolve it. */ return URLUtil.uriFromSystemId(systemId); } URL url = URLUtil.urlFromSystemId(systemId, ctxt); try { return new URI(url.toExternalForm()); } catch (URISyntaxException e) { // should never occur... throw new IOException("Failed to construct URI for external subset, URL = "+url.toExternalForm()+": "+e.getMessage()); } }
pathCtxt = parent.getSource(); if (pathCtxt == null) { pathCtxt = URLUtil.urlFromCurrentDir(); +publicId+"')"); URL url = URLUtil.urlFromSystemId(systemId, pathCtxt); return sourceFromURL(parent, cfg, entityName, xmlVersion, url, publicId);
public static URL urlFromSystemId(String sysId, URL ctxt) throws IOException { if (ctxt == null) { return urlFromSystemId(sysId); } try { sysId = cleanSystemId(sysId); return new URL(ctxt, sysId); } catch (MalformedURLException e) { throwIOException(e, sysId); return null; // never gets here } }
out = URLUtil.outputStreamFromURL(URLUtil.urlFromSystemId(sysId)); } catch (IOException ioe) { throw new WstxIOException(ioe);
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); }
public URL asURL() throws IOException { if (mURL == null) { mURL = URLUtil.urlFromSystemId(mSystemId); } return mURL; }
throwIOException(e, sysId); return null; // never gets here
sysId = cleanSystemId(sysId); throwIOException(e, sysId); return null; // never gets here
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); }
public XMLValidationSchema createSchema(URL url) throws XMLStreamException { try { InputStream in = URLUtil.optimizedStreamFromURL(url); InputSource src = new InputSource(in); src.setSystemId(url.toExternalForm()); return loadSchema(src, url); } catch (IOException ioe) { throw new WstxIOException(ioe); } }
pathCtxt = parent.getSource(); if (pathCtxt == null) { pathCtxt = URLUtil.urlFromCurrentDir(); +publicId+"')"); URL url = URLUtil.urlFromSystemId(systemId, pathCtxt); return sourceFromURL(parent, cfg, entityName, xmlVersion, url, publicId);
public static URL urlFromSystemId(String sysId, URL ctxt) throws IOException { if (ctxt == null) { return urlFromSystemId(sysId); } try { sysId = cleanSystemId(sysId); return new URL(ctxt, sysId); } catch (MalformedURLException e) { throwIOException(e, sysId); return null; // never gets here } }
/** * Method called to resolve path to external DTD subset, given * system identifier. */ private URI resolveExtSubsetPath(String systemId) throws IOException { // Do we have a context to use for resolving? URL ctxt = (mInput == null) ? null : mInput.getSource(); /* Ok, either got a context or not; let's create the URL based on * the id, and optional context: */ if (ctxt == null) { /* Call will try to figure out if system id has the protocol * in it; if not, create a relative file, if it does, try to * resolve it. */ return URLUtil.uriFromSystemId(systemId); } URL url = URLUtil.urlFromSystemId(systemId, ctxt); try { return new URI(url.toExternalForm()); } catch (URISyntaxException e) { // should never occur... throw new IOException("Failed to construct URI for external subset, URL = "+url.toExternalForm()+": "+e.getMessage()); } }
out = URLUtil.outputStreamFromURL(URLUtil.urlFromSystemId(sysId)); } catch (IOException ioe) { throw new WstxIOException(ioe);
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); }
public void dtdUnparsedEntityDecl(String name, String publicId, String systemId, String notationName, URL baseURL) throws XMLStreamException { if (mDTDHandler != null) { // SAX expects system id to be fully resolved? if (systemId.indexOf(':') < 0) { // relative path... try { systemId = URLUtil.urlFromSystemId(systemId, baseURL).toExternalForm(); } catch (IOException ioe) { throw new WstxIOException(ioe); } } try { mDTDHandler.unparsedEntityDecl(name, publicId, systemId, notationName); } catch (SAXException sex) { throw new WrappedSaxException(sex); } } }
throwIOException(e, sysId); return null; // never gets here