Package net.sf.saxon

Examples of net.sf.saxon.Configuration.buildDocument()


                if (source == null) {
                    // indicate it was not possible to convert to a Source type
                    throw new NoTypeConversionAvailableException(body, Source.class);
                }

                DocumentInfo doc = config.buildDocument(source);
                dynamicQueryContext.setContextItem(doc);
            } finally {
                // can deal if is is null
                IOHelper.close(is);
            }
View Full Code Here


     * @throws Exception
     */

    public static void main(String[] args) throws Exception {
        Configuration config = new Configuration();
        DocumentInfo doc = config.buildDocument(new StreamSource(new File("c:/MyJava/samples/data/books.xml")));
        EventIterator e = new Decomposer(new SingletonEventIterator(doc), config);
        e = EventStackIterator.flatten(e);
        e = new PullEventTracer(e, config);
        while (true) {
            PullEvent pe = e.next();
View Full Code Here

     * @throws Exception
     */

    public static void main(String[] args) throws Exception {
        Configuration config = new Configuration();
        DocumentInfo doc = config.buildDocument(new StreamSource(new File("c:/MyJava/samples/data/books.xml")));
        EventIterator e = new Decomposer(new SingletonEventIterator(doc), config);
        SequenceIterator iter = new SequenceComposer(e, config.makePipelineConfiguration());
        while (true) {
            NodeInfo item = (NodeInfo)iter.next();
            if (item == null) {
View Full Code Here

                if (source == null) {
                    // indicate it was not possible to convert to a Source type
                    throw new NoTypeConversionAvailableException(body, Source.class);
                }

                DocumentInfo doc = config.buildDocument(source);
                dynamicQueryContext.setContextItem(doc);
            } finally {
                // can deal if is is null
                IOHelper.close(is);
            }
View Full Code Here

                if (source == null) {
                    // indicate it was not possible to convert to a Source type
                    throw new NoTypeConversionAvailableException(body, Source.class);
                }

                DocumentInfo doc = config.buildDocument(source);
                dynamicQueryContext.setContextItem(doc);
            } finally {
                // can deal if is is null
                IOHelper.close(is);
            }
View Full Code Here

    public static NodeInfo exampleSaxonToSaxon(String sourceID, String xslID)
            throws TransformerException {

        TransformerFactory tfactory = TransformerFactory.newInstance();
        Configuration config = ((TransformerFactoryImpl)tfactory).getConfiguration();
        NodeInfo doc = config.buildDocument(new StreamSource(new File(xslID)));
        Templates templates = tfactory.newTemplates(doc);
        System.err.println("Stylesheet built OK");

        Transformer transformer = templates.newTransformer();
        doc = config.buildDocument(new StreamSource(new File(sourceID)));
View Full Code Here

        NodeInfo doc = config.buildDocument(new StreamSource(new File(xslID)));
        Templates templates = tfactory.newTemplates(doc);
        System.err.println("Stylesheet built OK");

        Transformer transformer = templates.newTransformer();
        doc = config.buildDocument(new StreamSource(new File(sourceID)));
        System.err.println("Source document built OK");

        Builder builder = TreeModel.TINY_TREE.makeBuilder(config.makePipelineConfiguration());
        transformer.transform(doc, builder);
        System.err.println("Transformation done OK");
View Full Code Here

    public static NodeInfo exampleSaxonToSaxonNonRoot(String sourceID, String xslID)
            throws TransformerException, IOException {

        TransformerFactory tfactory = TransformerFactory.newInstance();
        Configuration config = ((TransformerFactoryImpl)tfactory).getConfiguration();
        NodeInfo sdoc = config.buildDocument(new StreamSource(new File(xslID).toURI().toString()));
        Templates templates = tfactory.newTemplates(sdoc);
        System.err.println("Stylesheet built OK");

        NodeInfo doc = config.buildDocument(new StreamSource(new File(sourceID).toURI().toString()));
        System.err.println("Source document built OK");
View Full Code Here

        Configuration config = ((TransformerFactoryImpl)tfactory).getConfiguration();
        NodeInfo sdoc = config.buildDocument(new StreamSource(new File(xslID).toURI().toString()));
        Templates templates = tfactory.newTemplates(sdoc);
        System.err.println("Stylesheet built OK");

        NodeInfo doc = config.buildDocument(new StreamSource(new File(sourceID).toURI().toString()));
        System.err.println("Source document built OK");
        net.sf.saxon.sxpath.XPathEvaluator xpath = new net.sf.saxon.sxpath.XPathEvaluator(config);
        XPathExpression xpe = xpath.createExpression("/*/*[1]");
        NodeInfo start = (NodeInfo)xpe.evaluateSingle(doc);

View Full Code Here

    public static void exampleToHTMLFile() throws XPathException, IOException {
        final Configuration config = new Configuration();
        final StaticQueryContext sqc = config.newStaticQueryContext();
        final XQueryExpression exp = sqc.compileQuery(new FileReader("query/books-to-html.xq"));
        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        dynamicContext.setContextItem(config.buildDocument(new StreamSource("data/books.xml")));
        final Properties props = new Properties();
        props.setProperty(OutputKeys.METHOD, "html");
        props.setProperty(OutputKeys.DOCTYPE_PUBLIC, "-//W3C//DTD HTML 4.01 Transitional//EN");
        exp.run(dynamicContext, new StreamResult(new File("booklist.html")), props);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.