Object[] parms1={source.getPublicId(),source.getSystemId(),null}; Object xmlsource=fConfigInputSourceCtor.newInstance(parms1); Object[] parmsa={source.getByteStream()}; fConfigSetByteStream.invoke(xmlsource,parmsa); parmsa[0]=source.getCharacterStream(); fConfigSetCharStream.invoke(xmlsource,parmsa); parmsa[0]=source.getEncoding();
private Schema createSchema(List<InputSource> xsdsInJar, String[] schemas) throws SAXException, IOException { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); sf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); sf.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "file"); SchemaResourceResolver resourceResolver = new SchemaResourceResolver(); sf.setResourceResolver(resourceResolver); List<Source> sources = new ArrayList<>(); for (InputSource is : xsdsInJar) { Message msg = new Message("CREATE_SCHEMA_LOADED_FROM_JAR", LOG, is.getSystemId()); LOG.log(Level.FINE, msg.toString()); Document doc = docBuilder.parse(is.getByteStream()); DOMSource stream = new DOMSource(doc, is.getSystemId()); stream.setSystemId(is.getSystemId()); sources.add(stream); } if (schemas != null) { for (int i = 0; i < schemas.length; i++) { Document doc = docBuilder.parse(schemas[i]); DOMSource stream = new DOMSource(doc, schemas[i]); sources.add(stream); } } Source[] args = new Source[sources.size()]; sources.toArray(args); return sf.newSchema(args); }
public void parse(InputSource source) throws SAXException, IOException systemId = source.getSystemId(); contentHandler.setDocumentLocator(this); final Reader reader = source.getCharacterStream(); try { if (reader == null) { InputStream stream = source.getByteStream(); final String encoding = source.getEncoding(); systemId = source.getSystemId(); if(systemId == null) { SAXParseException saxException = new SAXParseException(
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = core.resolveEntity(publicId,systemId); if(source==null) return null; // default // ideally entity resolvers should be giving us the system ID for the resource // (or otherwise we won't be able to resolve references within this imported WSDL correctly), // but if none is given, the system ID before the entity resolution is better than nothing. if(source.getSystemId()!=null) systemId = source.getSystemId(); URL url = new URL(systemId); InputStream stream; if (useStreamFromEntityResolver) { stream = source.getByteStream(); } else { stream = url.openStream(); } return new Parser(url, new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream)); } }
} catch (MalformedURLException e) { if (is.getSystemId() == null && is.getCharacterStream() == null && is.getByteStream() == null) { throw new MalformedURLException( "The SAX InputSource has systemId == null && characterStream == null && byteStream == null. "
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = core.resolveEntity(publicId,systemId); if(source==null) return null; // default // ideally entity resolvers should be giving us the system ID for the resource // (or otherwise we won't be able to resolve references within this imported WSDL correctly), // but if none is given, the system ID before the entity resolution is better than nothing. if(source.getSystemId()!=null) systemId = source.getSystemId(); URL url = new URL(systemId); InputStream stream; if (useStreamFromEntityResolver) { stream = source.getByteStream(); } else { stream = url.openStream(); } return new Parser(url, new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream)); } }
Reader reader = input.getCharacterStream(); if (reader != null) { try { parse(reader, input.getPublicId(), input.getSystemId()); } finally { IoUtils.closeQuietly(reader); InputStream in = input.getByteStream(); String encoding = input.getEncoding(); if (in != null) { try { parse(in, encoding, input.getPublicId(), input.getSystemId()); } finally { IoUtils.closeQuietly(in); String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException("No input specified.");
public void parse(InputSource input) throws IOException, SAXException { try { InputStream s = input.getByteStream(); if (s == null) { String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource")); } parse(systemId); } else { parse(s); } } catch (FastInfosetException e) { logger.log(Level.FINE, "parsing error", e); throw new SAXException(e); } }
Reader reader = inputSource.getCharacterStream(); if (reader != null) { try { InputStream in = inputSource.getByteStream(); if (in != null) { try { String systemId = inputSource.getSystemId(); if (systemId == null) {
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = core.resolveEntity(publicId,systemId); if(source==null) return null; // default // ideally entity resolvers should be giving us the system ID for the resource // (or otherwise we won't be able to resolve references within this imported WSDL correctly), // but if none is given, the system ID before the entity resolution is better than nothing. if(source.getSystemId()!=null) systemId = source.getSystemId(); URL url = new URL(systemId); InputStream stream; if (useStreamFromEntityResolver) { stream = source.getByteStream(); } else { stream = url.openStream(); } return new Parser(url, new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream)); } }
DocumentType doctype = null; String inputEncoding = source.getEncoding(); String systemId = source.getSystemId(); DocumentImpl document = new DocumentImpl( dom, namespaceURI, qualifiedName, doctype, inputEncoding); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, namespaceAware); if (source.getByteStream() != null) { parser.setInput(source.getByteStream(), inputEncoding); } else if (source.getCharacterStream() != null) { parser.setInput(source.getCharacterStream()); } else if (systemId != null) { URL url = new URL(systemId);
public void parse(InputSource input) throws IOException, SAXException { try { InputStream s = input.getByteStream(); if (s == null) { String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource")); } parse(systemId); } else { parse(s); } } catch (FastInfosetException e) { logger.log(Level.FINE, "parsing error", e); throw new SAXException(e); } }
String sysIdStr = input.getSystemId(); ReaderConfig cfg = mConfig; URL srcUrl = null; Reader r = input.getCharacterStream(); if (r == null) { is = input.getByteStream(); if (is == null) { if (sysIdStr == null) {
public void parse(InputSource input) throws IOException, SAXException { try { InputStream s = input.getByteStream(); if (s == null) { String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource")); } parse(systemId); } else { parse(s); } } catch (FastInfosetException e) { logger.log(Level.FINE, "parsing error", e); throw new SAXException(e); } }
Reader reader = source.getCharacterStream(); if (reader != null) InputStream bytes = source.getByteStream(); if (bytes != null) String urlToLoad = source.getSystemId(); if (urlToLoad == null) throw new IOException("EntityResolver unable to resolve " + absoluteURL + " (for namespace " + namespace + ")");
public void parse(InputSource input) throws IOException, SAXException { try { InputStream s = input.getByteStream(); if (s == null) { String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource")); } parse(systemId); } else { parse(s); } } catch (FastInfosetException e) { e.printStackTrace(); throw new SAXException(e); } }
private BufferedReader getBufferedReaderForInputSource(InputSource inputSource) { if (inputSource.getByteStream() != null) { return new BufferedReader(new InputStreamReader(inputSource.getByteStream())); } else if (inputSource.getCharacterStream() != null) { return new BufferedReader(inputSource.getCharacterStream()); } else if (inputSource.getSystemId() != null) { InputStream is = getInputStreamFromString(inputSource.getSystemId()); return new BufferedReader(new InputStreamReader(is)); } throw XMLMarshalException.unmarshalException(); }
public LSInput resolveResource(String type, String nsURI, String publicId, String systemId, String baseURI) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("resolving resource type: " + type + "\n" + " namespaceURI:" + nsURI + "\n" + " publicId:" + publicId + "\n" + " systemId:" + systemId + "\n" + " baseURI:" + baseURI); } if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type)) { LSInput lsi = new SchemaInput(type, nsURI, publicId, systemId, baseURI); String resourceName = systemId; InputSource src = getSchemaInputSource(baseURI, resourceName); lsi.setByteStream(src.getByteStream()); lsi.setSystemId(src.getSystemId()); return lsi; } return oldResolver == null ? null : oldResolver.resolveResource(type, nsURI, publicId, systemId, baseURI); } };
private BufferedReader getBufferedReaderForInputSource(InputSource inputSource){ if(inputSource.getByteStream() != null){ return new BufferedReader(new InputStreamReader(inputSource.getByteStream())); }else if(inputSource.getCharacterStream() != null){ return new BufferedReader(inputSource.getCharacterStream()); }else if (inputSource.getSystemId() != null){ InputStream is = getInputStreamFromString(inputSource.getSystemId()); return new BufferedReader(new InputStreamReader(is)); } throw XMLMarshalException.unmarshalException(); }
public static XMLStreamReader createFreshXMLStreamReader(InputSource source) { try { if (source.getCharacterStream() != null) { return XML_INPUT_FACTORY.createXMLStreamReader(source.getSystemId(), source.getCharacterStream()); } if (source.getByteStream() != null) { return XML_INPUT_FACTORY.createXMLStreamReader(source.getSystemId(), source.getByteStream()); } return XML_INPUT_FACTORY.createXMLStreamReader(source.getSystemId(), new URL(source.getSystemId()).openStream()); } catch (Exception e) { Message msg = new Message("FAIL_TO_CREATE_STAX", LOG); throw new ToolException(msg, e); } } }