Package net.sf.saxon.tree

Examples of net.sf.saxon.tree.DocumentImpl


            }
            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);
            throw err;
View Full Code Here


    * Get the Templates object to be used for a transformation
    */

    public Templates getTemplates() {
        if (templates==null) {
            DocumentImpl doc = (DocumentImpl)builder.getCurrentRoot();
            builder.reset();
            if (doc==null) {
                return null;
            }

View Full Code Here

     *     stylesheet fails for any reason
     */

    protected void prepare(Source styleSource) throws TransformerConfigurationException {
        nodeFactory = config.getStyleNodeFactory();
        DocumentImpl doc;
        try {
            doc = loadStylesheetModule(styleSource, nodeFactory);
            setStylesheetDocument(doc, nodeFactory);
        } catch (XPathException e) {
            try {
View Full Code Here

        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);
View Full Code Here

     */

    protected void setStylesheetDocument(DocumentImpl doc, StyleNodeFactory snFactory)
    throws XPathException {

        DocumentImpl styleDoc = doc;
    nodeFactory = snFactory;

        // If top-level node is a literal result element, stitch it into a skeleton stylesheet

        StyleElement topnode = (StyleElement)styleDoc.getDocumentElement();
        if (topnode instanceof LiteralResultElement) {
            styleDoc = ((LiteralResultElement)topnode).makeStylesheet(this, snFactory);
        }

        if (!(styleDoc.getDocumentElement() instanceof XSLStylesheet)) {
            throw new XPathException(
                        "Outermost element of stylesheet is not xsl:stylesheet or xsl:transform or literal result element");
        }

        XSLStylesheet top = (XSLStylesheet)styleDoc.getDocumentElement();
        if (compilerInfo.isVersionWarning() && top.getVersion().equals(BigDecimal.valueOf(1))) {
            try {
                TransformerException w = new TransformerException(
                        "Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor");
                w.setLocator(topnode);
View Full Code Here

    * Get the Templates object to used for a transformation
    */

    public Templates getTemplates() {
        if (templates==null) {
            DocumentImpl doc = (DocumentImpl)builder.getCurrentDocument();
            if (doc==null) {
                return null;
            }
            PreparedStylesheet sheet = new PreparedStylesheet(getConfiguration());
            try {
View Full Code Here

     *     stylesheet fails for any reason
     */

    protected void prepare(Source styleSource) throws TransformerConfigurationException {
        nodeFactory = new StyleNodeFactory(config.getNamePool(), config.isAllowExternalFunctions());
        DocumentImpl doc = loadStylesheetModule(styleSource, config, config.getNamePool(), nodeFactory);
        setStylesheetDocument(doc, nodeFactory);

        if (errorCount > 0) {
            throw new TransformerConfigurationException(
                            "Failed to compile stylesheet. " +
View Full Code Here

        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
                    // case it has already been reported. But in the case of Crimson,
                    // the SAXParseException might wrap an exception that happened
                    // within callback code in Saxon.
                    SAXParseException spe = (SAXParseException)cause;
                    cause = spe.getException();
                    if (cause != null)  {
                        if (cause instanceof TransformerConfigurationException) {
                            throw (TransformerConfigurationException)cause;
                        } else {
                            if (cause instanceof RuntimeException) {
                                // A RunTimeException during stylesheet compilation is bad news...
                                cause.printStackTrace();
                            }
                            throw new TransformerConfigurationException(cause);
                        }
                    }
                    // details already reported, don't repeat them
                    throw new TransformerConfigurationException("Failed to parse stylesheet");
                } else if (cause instanceof TransformerConfigurationException) {
                    throw (TransformerConfigurationException)cause;
                } else {
                    throw new TransformerConfigurationException(cause);
                }
            }
            throw new TransformerConfigurationException(err);
        }

        if (doc.getDocumentElement()==null) {
            throw new TransformerConfigurationException("Stylesheet is empty or absent");
        }

        return doc;
View Full Code Here

     */

    protected void setStylesheetDocument(DocumentImpl doc, StyleNodeFactory snFactory)
    throws TransformerConfigurationException {

        DocumentImpl styleDoc = doc;
    nodeFactory = snFactory;

//        if (targetNamePool==null) {
//          targetNamePool = NamePool.getDefaultNamePool();
//        }

        // If top-level node is a literal result element, stitch it into a skeleton stylesheet

        StyleElement topnode = (StyleElement)styleDoc.getDocumentElement();
        if (topnode instanceof LiteralResultElement) {
            styleDoc = ((LiteralResultElement)topnode).makeStylesheet(this, snFactory);
        }

        if (!(styleDoc.getDocumentElement() instanceof XSLStylesheet)) {
            throw new TransformerConfigurationException(
                        "Outermost element of stylesheet is not xsl:stylesheet or xsl:transform or literal result element");
        }

        XSLStylesheet top = (XSLStylesheet)styleDoc.getDocumentElement();

        // Preprocess the stylesheet, performing validation and preparing template definitions

        top.setPreparedStylesheet(this);
        top.preprocess();
View Full Code Here

    * Get the Templates object to used for a transformation
    */

    public Templates getTemplates() {
        if (templates==null) {
            DocumentImpl doc = (DocumentImpl)builder.getCurrentRoot();
            if (doc==null) {
                return null;
            }

            final Configuration config = getConfiguration();
View Full Code Here

TOP

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

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.