Examples of PreparedStylesheet


Examples of client.net.sf.saxon.ce.PreparedStylesheet

        // Note: this requires the compile-time classes to be available at run-time; it will need
        // changing if we ever want to build a run-time JAR file.

        try {
            PreparedStylesheet pss = (PreparedStylesheet)context.getController().getExecutable();
            return pss.getStyleNodeFactory().isElementAvailable(uri, localname);
        } catch (Exception err) {
            //err.printStackTrace();
            return false;
        }
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.PreparedStylesheet

            throws XPathException {
        error.setIsStaticError(true);
        if (error.getLocator() == null) {
          error.setLocator(this);
        }
        PreparedStylesheet pss = getPreparedStylesheet();
        if (pss == null) {
            // it is null before the stylesheet has been fully built
            throw error;
        } else {
            pss.reportError(error);
        }
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.PreparedStylesheet

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

        try {
            PrincipalStylesheetModule psm = importer.getPrincipalStylesheetModule();
            PreparedStylesheet pss = psm.getPreparedStylesheet();
            XSLStylesheet includedSheet;
            StylesheetModule incModule;

            DocumentURI key = DocumentFn.computeDocumentKey(href, getBaseURI());
            includedSheet = psm.getStylesheetDocument(key);
            if (includedSheet != null) {
                // we already have the stylesheet document in cache; but we need to create a new module,
                // because the import precedence might be different. See test impincl30.
                incModule = new StylesheetModule(includedSheet, precedence);
                incModule.setImporter(importer);

            } else {

                //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);
                }

                String source;
                try {
                    URI base = new URI(getBaseURI());
                    URI abs = base.resolve(relative);
                    source = abs.toString();
                } catch (URI.URISyntaxException e) {
                    throw new XPathException(e);
                }

                // check for recursion

                StylesheetModule anc = importer;

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

                DocumentInfo rawDoc = getConfiguration().buildDocument(source);
                getConfiguration().getDocumentPool().add(rawDoc, key);
                DocumentImpl includedDoc = pss.loadStylesheetModule(rawDoc);

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

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

Examples of client.net.sf.saxon.ce.PreparedStylesheet

    public void compileStylesheet() throws XPathException {

        try {

            PreparedStylesheet pss = getPreparedStylesheet();
            //Configuration config = pss.getConfiguration();
            Executable exec = pss.getExecutable();

            // Register template rules with the rule manager

            for (int i = 0; i < topLevel.size(); i++) {
                Declaration decl = topLevel.get(i);
                StyleElement snode = decl.getSourceElement();
                if (snode instanceof XSLTemplate) {
                    ((XSLTemplate)snode).register(decl);
                }
            }

            // Call compile method for each top-level object in the stylesheet
            // Note, some declarations (templates) need to be compiled repeatedly if the module
            // is imported repeatedly; others (variables, functions) do not

            for (int i = 0; i < topLevel.size(); i++) {
                Declaration decl = topLevel.get(i);
                StyleElement snode = decl.getSourceElement();
                if (!snode.isActionCompleted(StyleElement.ACTION_COMPILE)) {
                    snode.setActionCompleted(StyleElement.ACTION_COMPILE);
                    Expression inst = snode.compile(exec, decl);
                    if (inst != null) {
                        inst.setSourceLocator(snode);
                    }
                }
            }

            // Call type-check method for each user-defined function in the stylesheet. This is no longer
            // done during the optimize step, to avoid functions being inlined before they are type-checked.

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

            for (Iterator<Integer> arities = functionIndex.keySet().iterator(); arities.hasNext();) {
                for (Iterator<Declaration> fi = functionIndex.get(arities.next()).values().iterator(); fi.hasNext();) {
                    Declaration decl = fi.next();
                    StyleElement node = decl.getSourceElement();
                    if (!node.isActionCompleted(StyleElement.ACTION_TYPECHECK)) {
                            node.setActionCompleted(StyleElement.ACTION_TYPECHECK);
                        ((XSLFunction)node).typeCheckBody();
                    }
                }
            }

            if (getPreparedStylesheet().getErrorCount() > 0) {
                // not much point carrying on
                return;
            }

            // Call optimize method for each top-level object in the stylesheet
            // But for functions, do it only for those of highest precedence.

            for (int i = 0; i < topLevel.size(); i++) {
                Declaration decl = topLevel.get(i);
                StyleElement node = decl.getSourceElement();
                if (node instanceof StylesheetProcedure && !(node instanceof XSLFunction) &&
                        !node.isActionCompleted(StyleElement.ACTION_OPTIMIZE)) {
                    node.setActionCompleted(StyleElement.ACTION_OPTIMIZE);
                    ((StylesheetProcedure) node).optimize(decl);
                }
            }

            for (Iterator<Integer> arities = functionIndex.keySet().iterator(); arities.hasNext();) {
                for (Iterator<Declaration> fi = functionIndex.get(arities.next()).values().iterator(); fi.hasNext();) {
                    Declaration decl = fi.next();
                    StyleElement node = decl.getSourceElement();
                    if (!node.isActionCompleted(StyleElement.ACTION_OPTIMIZE)) {
                        node.setActionCompleted(StyleElement.ACTION_OPTIMIZE);
                        ((StylesheetProcedure) node).optimize(decl);
                    }
                }
            }

            // Fix up references to the default default decimal format

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

Examples of client.net.sf.saxon.ce.PreparedStylesheet

     */

    protected void compileError(XPathException error)
            throws XPathException {
        error.setIsStaticError(true);
        PreparedStylesheet pss = getPreparedStylesheet();
        if (pss == null) {
            // it is null before the stylesheet has been fully built
            throw error;
        } else {
            pss.reportError(error);
        }
    }
View Full Code Here

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

Examples of net.sf.saxon.PreparedStylesheet

        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

Examples of net.sf.saxon.PreparedStylesheet

        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

Examples of net.sf.saxon.PreparedStylesheet

    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

Examples of net.sf.saxon.PreparedStylesheet

    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
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.