Class StylesheetModule

  • Direct Known Subclasses:
    PrincipalStylesheetModule

    public class StylesheetModule
    extends java.lang.Object
    A stylesheet module represents a module of a stylesheet. It is possible for two modules to share the same stylesheet tree in the case where two includes or imports reference the same URI; in this case the two modules will typically have a different import precedence.
    • Constructor Detail

      • StylesheetModule

        public StylesheetModule​(StyleElement rootElement,
                                int precedence)
    • Method Detail

      • loadStylesheetModule

        public static DocumentImpl loadStylesheetModule​(javax.xml.transform.Source styleSource,
                                                        boolean topLevelModule,
                                                        Compilation compilation,
                                                        NestedIntegerValue precedence)
                                                 throws XPathException
        Build the tree representation of a stylesheet module
        Parameters:
        styleSource - the source of the module
        topLevelModule - true if this module is the outermost module of a package
        compilation - the XSLT compilation episode
        precedence - the import precedence for static variables declared in the module. (This is handled differently from the precedence of other components because it needs to be allocated purely sequentially).
        Returns:
        the tree representation of the XML document containing the stylesheet module
        Throws:
        XPathException - if XML parsing or tree construction fails
      • loadStylesheet

        public static PreparedStylesheet loadStylesheet​(javax.xml.transform.Source styleSource,
                                                        Compilation compilation)
                                                 throws XPathException
        Build the tree representation of a stylesheet module
        Parameters:
        styleSource - the source of the module. This must contain either XSLT source code of a top-level module (which may contains xsl:include, xsl:import, or xsl:use-package), or it must contain a package in export format. This method is not used when compiling subsidiary modules or library packages.
        compilation - the XSLT compilation episode
        Returns:
        the tree representation of the XML document containing the stylesheet module
        Throws:
        XPathException - if XML parsing or tree construction fails
      • getAssociatedStylesheet

        public static javax.xml.transform.Source getAssociatedStylesheet​(Configuration config,
                                                                         ResourceResolver resolver,
                                                                         javax.xml.transform.Source source,
                                                                         java.lang.String media,
                                                                         java.lang.String title,
                                                                         java.lang.String charset)
                                                                  throws XPathException
        Get the stylesheet specification(s) associated via the xml-stylesheet processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with the document document specified in the source parameter, and that match the given criteria. Note that it is possible to return several stylesheets, in which case they are applied as if they were a list of imports or cascades.
        Parameters:
        config - The Saxon Configuration
        resolver - a URIResolver to be used for dereferencing URIs
        source - The XML source document.
        media - The media attribute to be matched. May be null, in which case the prefered templates will be used (i.e. alternate = no). Note that Saxon does not implement the complex CSS3-based syntax for media queries. By default, the media value is simply ignored. An algorithm for comparing the requested media with the declared media can be defined using the method Configuration.setMediaQueryEvaluator(Comparator).
        title - The value of the title attribute to match. May be null.
        charset - The value of the charset attribute to match. May be null.
        Returns:
        A Source object suitable for passing to the TransformerFactory.
        Throws:
        XPathException - if any problems occur
      • getStylesheetElement

        public XSLModuleRoot getStylesheetElement()
      • getPrecedence

        public int getPrecedence()
      • setWasIncluded

        public void setWasIncluded()
        Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:import
      • setMinImportPrecedence

        public void setMinImportPrecedence​(int min)
        Set the minimum import precedence of this module, that is, the lowest import precedence of the modules that it imports. This information is used to decide which template rules are eligible for consideration by xsl:apply-imports
        Parameters:
        min - the minimum import precedence
      • getMinImportPrecedence

        public int getMinImportPrecedence()
        Get the minimum import precedence of this module, that is, the lowest import precedence of the modules that it imports. This information is used to decide which template rules are eligible for consideration by xsl:apply-imports
        Returns:
        the minimum import precedence
      • spliceIncludes

        public void spliceIncludes()
                            throws XPathException
        Process xsl:include and xsl:import elements.
        Throws:
        XPathException - if the included/imported module is invalid
      • getInputTypeAnnotations

        public int getInputTypeAnnotations()
        Get the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules. The value is an or-ed combination of the two bits XSLModuleRoot.ANNOTATION_STRIP and XSLModuleRoot.ANNOTATION_PRESERVE
        Returns:
        the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules
      • setInputTypeAnnotations

        public void setInputTypeAnnotations​(int annotations)
                                     throws XPathException
        Set the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules. The value is an or-ed combination of the two bits XSLModuleRoot.ANNOTATION_STRIP and XSLModuleRoot.ANNOTATION_PRESERVE
        Parameters:
        annotations - the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules.
        Throws:
        XPathException - if the values of the attribute in different modules are inconsistent