Package net.sf.saxon.s9api

Examples of net.sf.saxon.s9api.DocumentBuilder


    private String errorMessage(QName code) {
        InputStream instream = getClass().getResourceAsStream("/etc/error-list.xml"); //TODO - Get proper path to this
        if (instream != null) {
            try {
                SAXSource source = new SAXSource(new InputSource(instream));
                DocumentBuilder builder = runtime.getProcessor().newDocumentBuilder();
                XdmNode doc = builder.build(source);
                XdmSequenceIterator iter = doc.axisIterator(Axis.DESCENDANT, new QName("error"));
                while (iter.hasNext()) {
                    XdmNode error = (XdmNode) iter.next();
                    if (code.getLocalName().equals(error.getAttributeValue(_code))) {
                        return error.getStringValue();
View Full Code Here


    }
   
    public void write(XdmNode doc) {
        try {
            Processor qtproc = runtime.getProcessor();
            DocumentBuilder builder = qtproc.newDocumentBuilder();
            builder.setBaseURI(new URI("http://example.com/"));
            XQueryCompiler xqcomp = qtproc.newXQueryCompiler();
            XQueryExecutable xqexec = xqcomp.compile(".");
            XQueryEvaluator xqeval = xqexec.load();
            xqeval.setContextItem(doc);
View Full Code Here

            DOMResult result = new DOMResult();
            is = S9apiUtils.xdmToInputSource(runtime, document);
            transformer.transform(new SAXSource(is), result);

            DocumentBuilder xdmBuilder = runtime.getConfiguration().getProcessor().newDocumentBuilder();
            XdmNode xformed = xdmBuilder.build(new DOMSource(result.getNode()));

            // Can be null when nothing is written to the principle result tree...
            if (xformed != null) {
                if (document != null
                        && (xformed.getBaseURI() == null
View Full Code Here

        XsltTransformer transformer = exec.load();

        //transformer.getUnderlyingController().setBaseOutputURI("http://example.com/");

        // No resolver, there isn't one here.
        DocumentBuilder builder = processor.newDocumentBuilder();
        SAXSource document = new SAXSource(new InputSource(new StringReader(textXML)));
        XdmNode context = builder.build(document);
        transformer.setInitialContextNode(context);
        XdmDestination result = new XdmDestination();
        transformer.setDestination(result);
        transformer.transform();
View Full Code Here

    public void run() throws SaxonApiException {
        Processor processor = new Processor(true);
        SchemaManager manager = processor.getSchemaManager();

        // No resolver here, there isn't one.
        DocumentBuilder builder = processor.newDocumentBuilder();
        SAXSource source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/compoundEntity.xml"));
        XdmNode document = builder.build(source);

        source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/document.xsd"));
        XdmNode schema = builder.build(source);
        manager.load(schema.asSource());

        XdmDestination destination = new XdmDestination();
        Controller controller = new Controller(processor.getUnderlyingConfiguration());
        Receiver receiver = destination.getReceiver(controller.getConfiguration());
View Full Code Here

                "<p>Some more content</p>\n" +
                "</doc>";

        SAXSource source = new SAXSource(new InputSource(new StringReader(xml)));
        // No resolver here, there isn't one.
        DocumentBuilder builder = saxon.newDocumentBuilder();
        XdmNode doc = builder.build(source);
        assertNotNull(doc);

        ProcessMatchingNodes pmn = new DebugProcessMatchingNodes();

        //ProcessMatch matcher = new ProcessMatch(saxon, pmn);
View Full Code Here

        StringReader inputStream = new StringReader(text);
        InputSource source = new InputSource(inputStream);
        Parser parser = new Parser();
        parser.setEntityResolver(runtime.getResolver());
        SAXSource saxSource = new SAXSource(parser, source);
        DocumentBuilder builder = runtime.getProcessor().newDocumentBuilder();
        try {
            XdmNode doc = builder.build(saxSource);
            return doc;
        } catch (Exception e) {
            throw new XProcException(e);
        }
    }
View Full Code Here

        HtmlDocumentBuilder htmlBuilder = new HtmlDocumentBuilder(XmlViolationPolicy.ALTER_INFOSET);
        htmlBuilder.setEntityResolver(runtime.getResolver());
        try {
            InputSource src = new InputSource(new StringReader(text));
            Document html = htmlBuilder.parse(src);
            DocumentBuilder builder = runtime.getProcessor().newDocumentBuilder();
            XdmNode doc = builder.build(new DOMSource(html));
            return doc;
        } catch (Exception e) {
            throw new XProcException(e);
        }
    }
View Full Code Here

                if (instream == null) {
                    throw new UnsupportedOperationException("Failed to load configuration from JAR file");
                }
                // No resolver, we don't have one yet
                SAXSource source = new SAXSource(new InputSource(instream));
                DocumentBuilder builder = cfgProcessor.newDocumentBuilder();
                builder.setLineNumbering(true);
                builder.setBaseURI(puri);
                parse(builder.build(source));
            } else {
                parse(readXML(cfg, cwd.toASCIIString()));
            }
        } catch (SaxonApiException sae) {
            throw new XProcException(sae);
View Full Code Here

        } catch (URISyntaxException use) {
            throw new XProcException(use);
        }

        // No resolver, we don't have one yet
        DocumentBuilder builder = cfgProcessor.newDocumentBuilder();
        builder.setLineNumbering(true);

        try {
            return builder.build(source);
        } catch (SaxonApiException sae) {
            throw new XProcException(XProcConstants.dynamicError(11), sae);
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.s9api.DocumentBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.