Package net.sf.saxon.tree

Examples of net.sf.saxon.tree.TreeBuilder


        }
    }

    private static class LinkedTree extends TreeModel {
        public Builder makeBuilder() {
            return new TreeBuilder();
        }
View Full Code Here


            throw err;
        }

        try {
            DocumentImpl oldRoot = (DocumentImpl)getDocumentRoot();
            TreeBuilder builder = new TreeBuilder();
            builder.setPipelineConfiguration(pss.getConfiguration().makePipelineConfiguration());
            builder.setNodeFactory(nodeFactory);
            builder.setSystemId(this.getSystemId());

            builder.open();
            builder.startDocument(0);

            int st = StandardNames.XSL_STYLESHEET;
            builder.startElement(st, StandardNames.XS_UNTYPED, 0, 0);
            builder.namespace(NamespaceConstant.XSLT_CODE, 0);
            builder.attribute(pool.allocate("", "", "version"), StandardNames.XS_UNTYPED_ATOMIC, version, 0, 0);
            builder.startContent();

            int te = StandardNames.XSL_TEMPLATE;
            builder.startElement(te, StandardNames.XS_UNTYPED, 0, 0);
            builder.attribute(pool.allocate("", "", "match"), StandardNames.XS_UNTYPED_ATOMIC, "/", 0, 0);
            builder.startContent();

            builder.graftElement(this);

            builder.endElement();
            builder.endElement();
            builder.endDocument();
            builder.close();

            DocumentImpl newRoot = (DocumentImpl)builder.getCurrentRoot();
            newRoot.graftLocationMap(oldRoot);
            return newRoot;
        } catch (XPathException err) {
            //TransformerConfigurationException e = new TransformerConfigurationException(err);
            err.setLocator(this);
View Full Code Here

        setPipelineConfiguration(config.makePipelineConfiguration());

        nodeFactory = config.getStyleNodeFactory();

        builder = new TreeBuilder();
        builder.setPipelineConfiguration(getPipelineConfiguration());
        builder.setNodeFactory(nodeFactory);
        builder.setLineNumbering(true);

        StartTagBuffer startTagBuffer = new StartTagBuffer();
View Full Code Here

     *     module
     */
    public DocumentImpl loadStylesheetModule(Source styleSource, StyleNodeFactory nodeFactory)
    throws XPathException {

        TreeBuilder styleBuilder = new TreeBuilder();
        PipelineConfiguration pipe = config.makePipelineConfiguration();
        pipe.setURIResolver(compilerInfo.getURIResolver());
        styleBuilder.setPipelineConfiguration(pipe);
        styleBuilder.setSystemId(styleSource.getSystemId());
        styleBuilder.setNodeFactory(nodeFactory);
        styleBuilder.setLineNumbering(true);

        StartTagBuffer startTagBuffer = new StartTagBuffer();

        UseWhenFilter useWhenFilter = new UseWhenFilter(startTagBuffer);
        useWhenFilter.setUnderlyingReceiver(styleBuilder);

        startTagBuffer.setUnderlyingReceiver(useWhenFilter);

        StylesheetStripper styleStripper = new StylesheetStripper();
        styleStripper.setUnderlyingReceiver(startTagBuffer);

        CommentStripper commentStripper = new CommentStripper();
        commentStripper.setUnderlyingReceiver(styleStripper);

        // build the stylesheet document

        DocumentImpl doc;

        Sender sender = new Sender(pipe);
        AugmentedSource aug = AugmentedSource.makeAugmentedSource(styleSource);
        aug.setSchemaValidationMode(Validation.STRIP);
        aug.setDTDValidationMode(Validation.STRIP);
        aug.setLineNumbering(true);
        if (aug.getXMLReader() == null && Configuration.getPlatform().isJava()) {
            XMLReader styleParser = config.getStyleParser();
            aug.setXMLReader(styleParser);
            sender.send(aug, commentStripper, new ParseOptions());
            config.reuseStyleParser(styleParser);
        } else {
            sender.send(aug, commentStripper, new ParseOptions());
        }
        doc = (DocumentImpl)styleBuilder.getCurrentRoot();
        styleBuilder.reset();

        if (aug.isPleaseCloseAfterUse()) {
            aug.close();
        }

View Full Code Here

    /**
     * Build a Saxon "standard" tree from input supplied via the pull interface
     */

    public NodeInfo buildStandardTree(PullProvider in) throws XPathException {
        TreeBuilder builder = new TreeBuilder();
        builder.setPipelineConfiguration(in.getPipelineConfiguration());
        builder.open();
        new PullPushCopier(in, builder).copy();
        builder.close();
        return builder.getCurrentRoot();
    }
View Full Code Here

                        if (resultNode.getFirstChild() != null) {
                            throw new DynamicError("Target document must be empty");
                        } else {
                            Builder builder;
                            if (doc instanceof DocumentImpl) {
                                builder = new TreeBuilder();
                            } else {
                                builder = new TinyBuilder();
                            }
                            builder.setRootNode(doc);
                            builder.setSystemId(result.getSystemId());
View Full Code Here

            // we have a SAXSource or StreamSource
            Builder b;
            if (config.getTreeModel() == Builder.TINY_TREE) {
                b = new TinyBuilder();
            } else {
                b = new TreeBuilder();
            }
            b.setConfiguration(config);
            b.setLineNumbering(config.isLineNumbering());
            Receiver receiver = b;
            if (stripper != null) {
View Full Code Here

        nodeFactory = new StyleNodeFactory(config.getNamePool(), config.isAllowExternalFunctions());

        StylesheetStripper styleStripper = new StylesheetStripper();
        styleStripper.setStylesheetRules(config.getNamePool());

        builder = new TreeBuilder();
        builder.setConfiguration(config);
        builder.setNodeFactory(nodeFactory);
        builder.setLineNumbering(true);

        styleStripper.setUnderlyingReceiver(builder);
View Full Code Here

    public Builder makeBuilder() {
        Builder b;
        if (treeModel==Builder.TINY_TREE)  {
            b = new TinyBuilder();
        } else {
            b = new TreeBuilder();
        }
        b.setTiming(config.isTiming());
        b.setLineNumbering(config.isLineNumbering());
        b.setConfiguration(config);
        return b;
View Full Code Here

    throws TransformerConfigurationException {

        StylesheetStripper styleStripper = new StylesheetStripper();
        styleStripper.setStylesheetRules(localNamePool);

        TreeBuilder styleBuilder = new TreeBuilder();
        styleBuilder.setConfiguration(config);
        styleBuilder.setSystemId(styleSource.getSystemId());
        styleBuilder.setNodeFactory(nodeFactory);
        styleBuilder.setLineNumbering(true);

        styleStripper.setUnderlyingReceiver(styleBuilder);

        CommentStripper commentStripper = new CommentStripper();
        commentStripper.setUnderlyingReceiver(styleStripper);

        // build the stylesheet document

        DocumentImpl doc;
        try {
            Sender sender = new Sender(config);
            AugmentedSource aug = AugmentedSource.makeAugmentedSource(styleSource);
            aug.setSchemaValidation(Boolean.FALSE);
            if (aug.getXMLReader() == null) {
                aug.setXMLReader(config.getStyleParser());
            }
            sender.send(aug, commentStripper);
            doc = (DocumentImpl)styleBuilder.getCurrentDocument();
        } catch (XPathException err) {
            Throwable cause = err.getException();
            if (cause != null) {
                if (cause instanceof SAXParseException) {
                    // This normally means there was an XML parsing error, in which
View Full Code Here

TOP

Related Classes of net.sf.saxon.tree.TreeBuilder

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.