Refine search
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { LSInput lsInput = impl.createLSInput(); InputStream is = getClass().getResourceAsStream("/" + systemId); if (is == null) return null; lsInput.setByteStream(is); return lsInput; } }
DOMImplementationLS ls = (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS"); // Gets a basic document from string. LSInput input = ls.createLSInput(); String xml = "<bookstore city='shanghai'><a></a><b/></bookstore>"; InputStream istream = new ByteArrayInputStream(xml.getBytes("UTF-8")); input.setByteStream(istream); LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null); Document document = parser.parse(input); // Creates a LSSerializer object and saves to file. LSSerializer serializer = ls.createLSSerializer(); serializer.getDomConfig().setParameter("format-pretty-print", true); LSOutput output = ls.createLSOutput(); OutputStream ostream = new FileOutputStream("c:\\temp\\foo.xml"); output.setByteStream(ostream); serializer.write(document, output);
if (is.getCharacterStream() != null) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), is.getCharacterStream(), "UTF-16"); else if (is.getByteStream() != null) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), is.getByteStream(), is.getEncoding()); else if (is.getStringData() != null && is.getStringData().length() != 0) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), new StringReader(is.getStringData()), "UTF-16"); xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI());
@Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { if (systemId == null) { return null; } LSInput input = new LSInputImpl(); try { File schema = new File(this._schemaDir, systemId); if (schema != null && !schema.exists()) { FileInputStream is = new FileInputStream(schema); input.setByteStream(is); input.setPublicId(publicId); input.setSystemId(systemId); input.setBaseURI(baseURI); input.setCharacterStream(new InputStreamReader(is)); is.close(); } else { throw new FileNotFoundException("Cannot find the internal schema " + schema + "."); } return input; } catch (IOException ex) { LOGGER.warn("Cannot resolve schema.", ex); return null; } } }
@Override public LSInput resolveResource(String type, String ns, String pubId, String sysId, String baseURI) { l.debug("Trying to resolve " + type + ", " + ns + ", " + pubId + ", " + sysId + ", " + baseURI + " in package " + pkgPath); // from http://www.java.net/forum/topic/java-web-services-and-xml/jaxp/ // schemafactory-problem-compiling-multiple-schemas-same-na-0 LSInput lsi = dls.createLSInput(); lsi.setByteStream(cll.getResourceAsStream(pkgPath.replace('.', '/') + "/" + sysId)); lsi.setSystemId(sysId); return lsi; } }
private LSInput loadLSInput(String ns) { String path = ToolConstants.CXF_SCHEMAS_DIR_INJAR + NSFILEMAP.get(ns); URL url = getClass().getClassLoader().getResource(path); LSInput lsin = new LSInputImpl(); lsin.setSystemId(url.toString()); try { lsin.setByteStream(url.openStream()); } catch (IOException e) { return null; } return lsin; }
@Override /* LSResourceResolver */ public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { String schema = schemas.get(namespaceURI); if (schema == null) throw new FormattedRuntimeException("No schema found for namespaceURI ''{0}''", namespaceURI); try { DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS domImplementationLS = (DOMImplementationLS)registry.getDOMImplementation("LS 3.0"); LSInput in = domImplementationLS.createLSInput(); in.setCharacterStream(new StringReader(schema)); in.setSystemId(systemId); return in; } catch (Exception e) { throw new RuntimeException(e); } } }
/** * {@inheritDoc} * @see org.w3c.dom.ls.LSResourceResolver#resolveResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { LSInput input = this.implementation.createLSInput(); input.setPublicId(publicId); input.setSystemId(systemId); input.setBaseURI(baseURI); Map<String, URL> namespaces = this.types.get(type); if (namespaces != null) { URL url = namespaces.get(namespaceURI); if (url != null) { // Substitute our system id, since we have a matching type and namespace input.setSystemId(url.toString()); } } return input; } }
@Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { LSInput input = new DOMInputImpl(); input.setPublicId(publicId); input.setSystemId(systemId); input.setBaseURI(baseURI); input.setCharacterStream(new InputStreamReader( getSchemaAsStream(input.getSystemId(), input.getBaseURI(), localPath))); return input; } }
@Override public LSInput resolveResource(String aType, String aNamespaceURI, String aPublicId, String aSystemId, String aBaseURI) { try { InputStream xslt = resolveImpl(aSystemId).getInputStream(); DOMImplementationLS impl = DomUtils.getDomImplementationLS(); LSInput input = impl.createLSInput(); input.setPublicId(aPublicId); input.setSystemId(aSystemId); input.setByteStream(xslt); return input; } catch (IOException e) { return null; } }
LSParser parser = domImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null); if (resolver != null) { parser.getDomConfig().setParameter("resource-resolver", resolver); LSInput domInput = domImpl.createLSInput(); domInput.setEncoding("UTF-8"); domInput.setByteStream(content);
if (lsInput == null) return; input.setEncoding(lsInput.getEncoding()); input.setUri(lsInput.getSystemId()); final Reader characterStream = lsInput.getCharacterStream(); if (characterStream != null) { input.setCharacterStream(characterStream); return; final InputStream byteStream = lsInput.getByteStream(); if (byteStream != null) { input.setByteStream(byteStream); return; final String stringData = lsInput.getStringData(); if (stringData != null) { input.setCharacterStream(new StringReader(stringData));
public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { LSInput input= wrapped.resolveResource("http://www.w3.org/TR/REC-xml", name, publicId, systemId, baseURI); if (input !=null){ InputSource result = new InputSource(); result.setByteStream(input.getByteStream()); result.setPublicId(input.getPublicId()); result.setSystemId(input.getSystemId()); result.setEncoding(input.getEncoding()); return result; } return null; }
private Document getDocument(InputStream is) throws InstantiationException, IllegalAccessException, ClassNotFoundException { DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); LSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null); // we need to ignore whitespace here so the nodeToString() method will be able to indent it properly: parser.setFilter(new IgnoreWhitespaceFilter()); LSInput domInput = impl.createLSInput(); domInput.setByteStream(is); return parser.parse(domInput); }
if (resource != null) { systemId = resource.toURI().toASCIIString(); LSInput input = dom.createLSInput(); input.setPublicId(publicId); input.setSystemId(systemId); return input;
if (input.getCharacterStream() != null) { inputSource.setCharacterStream(input.getCharacterStream()); if (input.getByteStream() != null) { inputSource.setByteStream(input.getByteStream()); if (input.getStringData() != null) { inputSource.setCharacterStream(new StringReader(input.getStringData())); if (input.getPublicId() != null) { inputSource.setPublicId(input.getPublicId()); if (input.getSystemId() != null) { source.setSystemId(input.getSystemId());
/** * Parse a {@code String} into a DOM Document. * * @param content the content to parse * @return a DOM Document corresponding to the input, {@code null} if the content can't be parsed successfully */ public Document parse(String content) { if (content == null) { return null; } LSInput input = this.lsImpl.createLSInput(); input.setCharacterStream(new StringReader(content)); return parse(input); }
resource.setSystemId(actualSchemaURL); resource.setPublicId(publicId); resource.setByteStream(resourceStream); return resource; }else{
public static class LocalSchemaLSResourceResolver implements LSResourceResolver{ private static final String CARPETA_XSD = "META-INF/xsd/"; //@Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { try { LSInput input = ((DOMImplementationLS)DOMImplementationRegistry.newInstance().getDOMImplementation("LS")).createLSInput(); input.setByteStream(Thread.currentThread().getContextClassLoader().getResourceAsStream(CARPETA_XSD+systemId.replace("../",""))); return input; } catch(Exception e) { throw ExceptionWrapper.wrap(e,"Imposible encontrar importacion type=%, namespace=%, publicId=%, systemId=%, baseURI=%", type,namespaceURI, publicId, systemId, baseURI); } } }
public LSInput resolveAsLSInput(String nsURI, String baseURI, String schemaLocation) { LSInput lsInput = null; InputSource is = getInputSource(nsURI, baseURI, schemaLocation); if (is != null) { String publicId = is.getPublicId(); String systemId = is.getSystemId(); lsInput = new LSInputAdaptor(publicId, systemId, baseURI); lsInput.setCharacterStream(is.getCharacterStream()); lsInput.setByteStream(is.getByteStream()); lsInput.setEncoding(is.getEncoding()); } return lsInput; }