Package net.sf.saxon

Examples of net.sf.saxon.PreparedStylesheet


            if (namespace==null) {
                namespace = "";
            } else {
                namespace = namespace.trim();
            }
            PreparedStylesheet preparedStylesheet = getPreparedStylesheet();
            Configuration config = preparedStylesheet.getConfiguration();
            if (!config.isLicensedFeature(Configuration.LicenseFeature.SCHEMA_AWARE_XSLT)) {
                compileError("To use xsl:import-schema, you need the schema-aware " +
                        "version of Saxon from http://www.saxonica.com/", "XTSE1650");
                return;
            }
            AxisIterator kids = iterateAxis(Axis.CHILD);
            NodeInfo inlineSchema = null;
            while (true) {
                Item child = kids.next();
                if (child==null) {
                    break;
                }
                if (inlineSchema != null) {
                    compileError(getDisplayName() + " must not have more than one child element");
                }
                inlineSchema = (NodeInfo)child;
                if (inlineSchema.getFingerprint() != StandardNames.XS_SCHEMA) {
                    compileError("The only child element permitted for " + getDisplayName() + " is xs:schema");
                }
                if (schemaLoc != null) {
                    compileError("The schema-location attribute must be absent if an inline schema is present");
                }

                namespace = config.readInlineSchema(inlineSchema, namespace,
                        preparedStylesheet.getCompilerInfo().getErrorListener());
                getPrincipalStylesheet().addImportedSchema(namespace);
            }
            if (inlineSchema != null) {
                return;
            }
View Full Code Here


        checkEmpty();
        checkTopLevel((this instanceof XSLInclude ? "XTSE0170" : "XTSE0190"));

        try {
            XSLStylesheet thisSheet = (XSLStylesheet)getParent();
            PreparedStylesheet pss = getPreparedStylesheet();
            URIResolver resolver = pss.getCompilerInfo().getURIResolver();
            Configuration config = pss.getConfiguration();

            //System.err.println("GeneralIncorporate: href=" + href + " base=" + getBaseURI());
            String relative = href;
            String fragment = null;
            int hash = relative.indexOf('#');
            if (hash == 0 || relative.length() == 0) {
                compileError("A stylesheet cannot " + getLocalPart() + " itself",
                                (this instanceof XSLInclude ? "XTSE0180" : "XTSE0210"));
                return null;
            } else if (hash == relative.length() - 1) {
                relative = relative.substring(0, hash);
            } else if (hash > 0) {
                if (hash+1 < relative.length()) {
                    fragment = relative.substring(hash+1);
                }
                relative = relative.substring(0, hash);
            }
            Source source;
            try {
                source = resolver.resolve(relative, getBaseURI());
            } catch (TransformerException e) {
                throw XPathException.makeXPathException(e);
            }

            // if a user URI resolver returns null, try the standard one
            // (Note, the standard URI resolver never returns null)
            if (source==null) {
                source = config.getSystemURIResolver().resolve(relative, getBaseURI());
            }

            if (fragment != null) {
                IDFilter filter = new IDFilter(fragment);
                source = AugmentedSource.makeAugmentedSource(source);
                ((AugmentedSource)source).addFilter(filter);
            }

            // check for recursion

            XSLStylesheet anc = thisSheet;

            if (source.getSystemId() != null) {
                while(anc!=null) {
                    if (source.getSystemId().equals(anc.getSystemId())) {
                        compileError("A stylesheet cannot " + getLocalPart() + " itself",
                                (this instanceof XSLInclude ? "XTSE0180" : "XTSE0210"));
                        return null;
                    }
                    anc = anc.getImporter();
                }
            }

            StyleNodeFactory snFactory = config.getStyleNodeFactory();
            includedDoc = pss.loadStylesheetModule(source, snFactory);

            // allow the included document to use "Literal Result Element as Stylesheet" syntax

            ElementImpl outermost = includedDoc.getDocumentElement();
View Full Code Here

        if (error.getLocator() == null ||
                ((error.getLocator() instanceof ExpressionLocation ||
                error.getLocator() instanceof Expression) && !(this instanceof StylesheetProcedure))) {
            error.setLocator(this);
        }
        PreparedStylesheet pss = getPreparedStylesheet();
        try {
            if (pss == null) {
                // it is null before the stylesheet has been fully built
                throw error;
            } else {
                pss.reportError(error);
            }
        } catch (TransformerException err2) {
            if (err2.getLocator() == null) {
                err2.setLocator(this);
            }
View Full Code Here

    protected void compileWarning(String message, StructuredQName errorCode)
            throws XPathException {
        XPathException tce = new XPathException(message);
        tce.setErrorCodeQName(errorCode);
        tce.setLocator(this);
        PreparedStylesheet pss = getPreparedStylesheet();
        if (pss != null) {
            pss.reportWarning(tce);
        }
    }
View Full Code Here

    protected void compileWarning(String message, String errorCode)
            throws XPathException {
        XPathException tce = new XPathException(message);
        tce.setErrorCode(errorCode);
        tce.setLocator(this);
        PreparedStylesheet pss = getPreparedStylesheet();
        if (pss != null) {
            pss.reportWarning(tce);
        }
    }
View Full Code Here

    protected void issueWarning(TransformerException error) {
        if (error.getLocator() == null) {
            error.setLocator(this);
        }
        PreparedStylesheet pss = getPreparedStylesheet();
        if (pss != null) {
            // it is null before the stylesheet has been fully built - ignore it
            pss.reportWarning(error);
        }
    }
View Full Code Here

    public void compileStylesheet() throws XPathException {

        try {

            PreparedStylesheet pss = getPreparedStylesheet();
            // If any XQuery functions were imported, fix up all function calls
            // registered against these functions.
            try {
                //queryFunctions.bindUnboundFunctionCalls();
                Iterator qf = queryFunctions.getFunctionDefinitions();
                while (qf.hasNext()) {
                    XQueryFunction f = (XQueryFunction) qf.next();
                    f.fixupReferences(getStaticContext());
                }
            } catch (XPathException e) {
                compileError(e);
            }

            // Call compile method for each top-level object in the stylesheet

            for (int i = 0; i < topLevel.size(); i++) {
                NodeInfo node = (NodeInfo) topLevel.get(i);
                if (node instanceof StyleElement) {
                    StyleElement snode = (StyleElement) node;
                    //int module = putModuleNumber(snode.getSystemId());
                    Expression inst = snode.compile(exec);
                    if (inst != null) {
                        inst.setLocationId(allocateLocationId(getSystemId(), snode.getLineNumber()));
                    }
                }
            }

            // Call optimize method for each top-level object in the stylesheet

            for (int i = 0; i < topLevel.size(); i++) {
                NodeInfo node = (NodeInfo) topLevel.get(i);
                if (node instanceof StylesheetProcedure) {
                    ((StylesheetProcedure) node).optimize();
                }
            }

            // Fix up references to the default default decimal format

            if (pss.getDecimalFormatManager() != null) {
                try {
                    pss.getDecimalFormatManager().fixupDefaultDefault();
                } catch (XPathException err) {
                    compileError(err.getMessage(), err.getErrorCodeQName());
                }
            }
View Full Code Here

     * on the standard error output.
     */

    public XsltExecutable compile(Source source) throws SaxonApiException {
        try {
            PreparedStylesheet pss = PreparedStylesheet.compile(source, config, compilerInfo);
            return new XsltExecutable(processor, pss);
        } catch (TransformerConfigurationException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

        // Set the location of the error if there is not current location information,
        // or if the current location information is local to the XPath expression
        if (error.getLocator()==null || error.getLocator() instanceof ExpressionLocation) {
            error.setLocator(this);
        }
        PreparedStylesheet pss = getPreparedStylesheet();
        try {
            if (pss==null) {
                // it is null before the stylesheet has been fully built
                throw error;
            } else {
                pss.reportError(error);
            }
        } catch (TransformerException err2) {
            if (err2 instanceof TransformerConfigurationException) {
                throw (TransformerConfigurationException)err2;
            }
View Full Code Here

    protected void compileWarning(String message)
    throws TransformerConfigurationException {
        TransformerConfigurationException tce =
            new TransformerConfigurationException(message);
        tce.setLocator(this);
        PreparedStylesheet pss = getPreparedStylesheet();
        if (pss!=null) {
            pss.reportWarning(tce);
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.PreparedStylesheet

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.