Search in sources :

Example 6 with DOMLoader

use of org.eclipse.wst.xml.xpath2.processor.DOMLoader in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathTest method loadDOMDocument.

protected void loadDOMDocument(URL fileURL, Schema schema) throws IOException, DOMLoaderException {
    InputStream is = testResolve(fileURL);
    DOMLoader domloader = new XercesLoader(schema);
    domloader.set_validating(false);
    domDoc = domloader.load(is);
    domDoc.setDocumentURI(fileURL.toString());
}
Also used : DOMLoader(org.eclipse.wst.xml.xpath2.processor.DOMLoader) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XercesLoader(org.eclipse.wst.xml.xpath2.processor.XercesLoader)

Example 7 with DOMLoader

use of org.eclipse.wst.xml.xpath2.processor.DOMLoader in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathTest method loadDOMDocument.

protected void loadDOMDocument(URL fileURL, URL schemaURL) throws IOException, DOMLoaderException, SAXException {
    InputStream is = testResolve(fileURL);
    InputStream schemaIs = testResolve(schemaURL);
    Schema jaxpSchema = getSchema(schemaIs);
    DOMLoader domloader = new XercesLoader(jaxpSchema);
    domloader.set_validating(false);
    domDoc = domloader.load(is);
}
Also used : DOMLoader(org.eclipse.wst.xml.xpath2.processor.DOMLoader) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Schema(javax.xml.validation.Schema) XercesLoader(org.eclipse.wst.xml.xpath2.processor.XercesLoader)

Example 8 with DOMLoader

use of org.eclipse.wst.xml.xpath2.processor.DOMLoader in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathTest method formatResultString.

protected String formatResultString(String resultFile) throws Exception {
    DOMLoader domloader = new XercesLoader(null);
    domloader.set_validating(false);
    InputStream is = bundle.getEntry(resultFile).openStream();
    Document resultDoc = domloader.load(is);
    DOMImplementationLS domLS = (DOMImplementationLS) resultDoc.getImplementation().getFeature("LS", "3.0");
    LSSerializer serializer = domLS.createLSSerializer();
    ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
    DelegatingLoader newContext = new DelegatingLoader(originalLoader);
    Thread.currentThread().setContextClassLoader(newContext);
    String actual = null;
    try {
        actual = serializer.writeToString(resultDoc.getDocumentElement());
        actual = actual.replace("<?xml version=\"1.0\" encoding=\"UTF-16\"?>", "");
        return actual.trim();
    } finally {
        Thread.currentThread().setContextClassLoader(originalLoader);
    }
}
Also used : DOMLoader(org.eclipse.wst.xml.xpath2.processor.DOMLoader) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DOMImplementationLS(org.w3c.dom.ls.DOMImplementationLS) LSSerializer(org.w3c.dom.ls.LSSerializer) XercesLoader(org.eclipse.wst.xml.xpath2.processor.XercesLoader) Document(org.w3c.dom.Document)

Example 9 with DOMLoader

use of org.eclipse.wst.xml.xpath2.processor.DOMLoader in project webtools.sourceediting by eclipse.

the class DynamicContextBuilder method retrieve_doc.

// XXX make it nice, and move it out as a utility function
private Document retrieve_doc(URI uri) {
    try {
        DOMLoader loader = new XercesLoader();
        loader.set_validating(false);
        Document doc = loader.load(new URL(uri.toString()).openStream());
        doc.setDocumentURI(uri.toString());
        return doc;
    } catch (FileNotFoundException e) {
        return null;
    } catch (MalformedURLException e) {
        return null;
    } catch (IOException e) {
        return null;
    }
}
Also used : DOMLoader(org.eclipse.wst.xml.xpath2.processor.DOMLoader) MalformedURLException(java.net.MalformedURLException) FileNotFoundException(java.io.FileNotFoundException) XercesLoader(org.eclipse.wst.xml.xpath2.processor.XercesLoader) IOException(java.io.IOException) Document(org.w3c.dom.Document) URL(java.net.URL)

Example 10 with DOMLoader

use of org.eclipse.wst.xml.xpath2.processor.DOMLoader in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathWTPTest method loadDOMDocument.

protected void loadDOMDocument(URL fileURL) throws IOException, DOMLoaderException {
    InputStream is = testResolve(fileURL);
    DOMLoader domloader = new XercesLoader();
    domloader.set_validating(false);
    domDoc = domloader.load(is);
    domDoc.setDocumentURI(fileURL.toString());
}
Also used : DOMLoader(org.eclipse.wst.xml.xpath2.processor.DOMLoader) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XercesLoader(org.eclipse.wst.xml.xpath2.processor.XercesLoader)

Aggregations

DOMLoader (org.eclipse.wst.xml.xpath2.processor.DOMLoader)14 XercesLoader (org.eclipse.wst.xml.xpath2.processor.XercesLoader)14 InputStream (java.io.InputStream)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Document (org.w3c.dom.Document)7 URL (java.net.URL)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DOMLoaderException (org.eclipse.wst.xml.xpath2.processor.DOMLoaderException)2 DOMImplementationLS (org.w3c.dom.ls.DOMImplementationLS)2 LSSerializer (org.w3c.dom.ls.LSSerializer)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Schema (javax.xml.validation.Schema)1