Class StylesheetPackage

  • Direct Known Subclasses:
    StylesheetPackageEE

    public class StylesheetPackage
    extends PackageData
    A (compiled) stylesheet package. This may be created either by compiling a source XSLT package, or by loading a saved package from disk. It therefore has no references to source XSLT documents.
    • Field Detail

      • defaultOutputProperties

        protected java.util.Properties defaultOutputProperties
      • namedOutputProperties

        protected java.util.Map<StructuredQName,​java.util.Properties> namedOutputProperties
      • schemaIndex

        protected java.util.Set<NamespaceUri> schemaIndex
      • hiddenComponents

        protected java.util.List<Component> hiddenComponents
    • Constructor Detail

      • StylesheetPackage

        public StylesheetPackage​(Configuration config)
        Create a stylesheet package
        Parameters:
        config - the Saxon Configuration
    • Method Detail

      • getComponentIndex

        public java.util.HashMap<SymbolicName,​Component> getComponentIndex()
        Get a map containing all the components in this package, indexed by symbolic name
        Returns:
        a map containing all the components in the package. This does not include components in used packages, except to the extent that they have been copied into this package.
      • getUsedPackages

        public java.lang.Iterable<StylesheetPackage> getUsedPackages()
        Get the packages referenced from this package in an xsl:use-package declaration
        Returns:
        the packages used by this package
      • addUsedPackage

        public void addUsedPackage​(StylesheetPackage pack)
        Add a package to the list of packages directly used by this one
        Parameters:
        pack - the used package
      • contains

        public boolean contains​(StylesheetPackage pack)
        Ask whether a given library package is within the package subtree rooted at this package
        Parameters:
        pack - the library package
        Returns:
        true if the given library package is in the transitive contents of this package
      • setLanguageVersion

        public void setLanguageVersion​(int version)
        Set the version of the XSLT language specification to which the package manifest conforms
        Parameters:
        version - the version (times ten) as an integer
      • setPackageName

        public void setPackageName​(java.lang.String packageName)
        Set the name of the package
        Parameters:
        packageName - the name of the package. This is supposed to be an absolute URI, but Saxon accepts any string.
      • getPackageVersion

        public PackageVersion getPackageVersion()
        Get the package-version identifier appearing on the xsl:package element
        Returns:
        the version identifier as a structured entity
      • setPackageVersion

        public void setPackageVersion​(PackageVersion version)
        Set the package-version identifier appearing on the xsl:package element
        Parameters:
        version - the version identifier as a structured entity
      • getPackageName

        public java.lang.String getPackageName()
        Get the name identifier of the xsl:package as an absolute URI
        Returns:
        a string value. This is supposed to be an absolute URI, but Saxon accepts any string.
      • isImplicitPackage

        public boolean isImplicitPackage()
        Ask if this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:package
        Returns:
        true if this package was rooted at an xsl:stylesheet or xsl:transform element
      • setImplicitPackage

        public void setImplicitPackage​(boolean implicitPackage)
        Say whether this is an implicit package (one rooted at xsl:stylesheet or xsl:transform rather than xsl:package
        Parameters:
        implicitPackage - true if this package was rooted at an xsl:stylesheet or xsl:transform element
      • isJustInTimeCompilation

        public boolean isJustInTimeCompilation()
        Ask whether the package was compiled with just-in-time compilation of template rules enabled
        Returns:
        false (always) for Saxon-HE
      • setJustInTimeCompilation

        public void setJustInTimeCompilation​(boolean justInTimeCompilation)
        Say whether the package was compiled with just-in-time compilation of template rules enabled. This method is called by the compiler itself and should not be called by users. The setting is ignored in Saxon-HE.
        Parameters:
        justInTimeCompilation - set to true if just-in-time compilation was enabled when the package was compiled
      • getRuleManager

        public RuleManager getRuleManager()
        Get the rule manager, which knows about all the modes present in the package
        Returns:
        the rule manager
      • setRuleManager

        public void setRuleManager​(RuleManager ruleManager)
        Set the rule manager, which knows about all the modes present in the package
        Parameters:
        ruleManager - the rule manager
      • getDefaultMode

        public StructuredQName getDefaultMode()
        Get the default mode for the package
        Returns:
        the default mode for the package as a whole (this may change for individual elements/subtrees within the package)
      • setDefaultMode

        public void setDefaultMode​(StructuredQName defaultMode)
        Set the default mode for the package
        Parameters:
        defaultMode - the default mode for the package
      • setDeclaredModes

        public void setDeclaredModes​(boolean declared)
        Say whether it is required that modes be explicitly declared
        Parameters:
        declared - true if modes referenced within this package must be explicitly declared
      • isDeclaredModes

        public boolean isDeclaredModes()
        Ask whether it is required that modes be explicitly declared
        Returns:
        true if modes referenced within this package must be explicitly declared
      • getSpaceStrippingRule

        public SpaceStrippingRule getSpaceStrippingRule()
        Get the whitespace stripping rules for this package
        Returns:
        the whitespace stripping rules (based on xsl:strip-space and xsl:preserve-space)
      • getCharacterMapIndex

        public CharacterMapIndex getCharacterMapIndex()
        Get the index of named character maps defined in this package
        Returns:
        the index of character maps
      • setCharacterMapIndex

        public void setCharacterMapIndex​(CharacterMapIndex characterMapIndex)
        Set the index of named character maps defined in this package
        Parameters:
        characterMapIndex - the index of named character maps
      • isCreatesSecondaryResultDocuments

        public boolean isCreatesSecondaryResultDocuments()
        Ask whether the package contains an xsl:result-document instruction
        Returns:
        true if the package contains an xsl:result-document instruction
      • setCreatesSecondaryResultDocuments

        public void setCreatesSecondaryResultDocuments​(boolean createsSecondaryResultDocuments)
        Say whether the package contains an xsl:result-document instruction
        Parameters:
        createsSecondaryResultDocuments - true if the package contains an xsl:result-document instruction
      • isStripsTypeAnnotations

        public boolean isStripsTypeAnnotations()
        Ask whether the package defines that type annotations should be stripped from input documents loaded from within this package
        Returns:
        true if documents loaded by this package should have any type annotations stripped.
      • setStripsTypeAnnotations

        public void setStripsTypeAnnotations​(boolean stripsTypeAnnotations)
        Say whether the package defines that type annotations should be stripped from input documents loaded from within this package
        Parameters:
        stripsTypeAnnotations - set to true if documents loaded by this package should have any type annotations stripped.
      • getStripperRules

        public SpaceStrippingRule getStripperRules()
        Get the whitespace stripping rules for source documents loaded from within this package
        Returns:
        the whitespace stripping rules for this package
      • setStripperRules

        public void setStripperRules​(SpaceStrippingRule stripperRules)
        Set the whitespace stripping rules for source documents loaded from within this package
        Parameters:
        stripperRules - the whitespace stripping rules for this package
      • setDefaultOutputProperties

        public void setDefaultOutputProperties​(java.util.Properties props)
        Set the default (unnamed) serialization properties to be used for documents output using xsl:result-document instructions within this package
        Parameters:
        props - the default serialization properties for this package
      • setNamedOutputProperties

        public void setNamedOutputProperties​(StructuredQName name,
                                             java.util.Properties props)
        Define a named set serialization properties to be used for documents output using xsl:result-document instructions within this package
        Parameters:
        name - the name of the serialization property set
        props - the serialization properties
      • getNamedOutputProperties

        public java.util.Properties getNamedOutputProperties​(StructuredQName name)
        Get a set of named output properties
        Parameters:
        name - the output declaration name
        Returns:
        the corresponding properties; or null if the name is unknown
      • getSchemaNamespaces

        public java.util.Set<NamespaceUri> getSchemaNamespaces()
        Get the set of namespaces of schema declarations imported into this package
        Returns:
        the set of imported namespaces
      • setContextItemRequirements

        public void setContextItemRequirements​(GlobalContextRequirement requirement)
                                        throws XPathException
        Set the required context item type. Used when there is an xsl:global-context-item child element
        Parameters:
        requirement - details of the requirement for the global context item
        Throws:
        XPathException - if there are conflicts
      • getContextItemRequirements

        public GlobalContextRequirement getContextItemRequirements()
        Get the required context item type and other details of the global context item. Used when there is an xsl:global-context-item child element
        Returns:
        details of the requirement for the global context item
      • setStripsWhitespace

        public void setStripsWhitespace​(boolean strips)
        Say whether there is an xsl:strip-space declaration in the stylesheet package
        Parameters:
        strips - true if an xsl:strip-space declaration has been found
      • isStripsWhitespace

        public boolean isStripsWhitespace()
        Ask whether there is an xsl:strip-space declaration in the stylesheet package
        Returns:
        true if an xsl:strip-space declaration has been found
      • addCompletionAction

        public void addCompletionAction​(Action action)
        Register a callback action to be performed during the completion phase of building the package
        Parameters:
        action - the callback action
      • complete

        protected void complete()
                         throws XPathException
        Perform all registered completion actions for the package
        Throws:
        XPathException - if any of these completion actions fails
      • allocateBinderySlots

        public void allocateBinderySlots()
        Allocate slots to global variables. Slot numbers are unique within a package
      • addComponent

        public void addComponent​(Component component)
        Add a component to the package
        Parameters:
        component - the component to be added
      • addGlobalVariable

        public void addGlobalVariable​(GlobalVariable variable)
        Description copied from class: PackageData
        Add a global variable to the list of global variables contained in this package
        Overrides:
        addGlobalVariable in class PackageData
        Parameters:
        variable - the global variable to be added
      • getMaxFunctionArity

        public int getMaxFunctionArity()
        Get the maximum arity of functions in this package
        Returns:
        the maximum arity
      • getComponent

        public Component getComponent​(SymbolicName name)
        Get the component within this package having a given symbolic name
        Parameters:
        name - the symbolic name of the required component
        Returns:
        the requested component, or null if it does not exist in the package
      • addHiddenComponent

        public void addHiddenComponent​(Component component)
      • getOverriddenComponent

        public Component getOverriddenComponent​(SymbolicName name)
        If this component overrides a component named N, get the component that N overrides (that is, the component identified by xsl:original appearing within the overriding declaration of N)
        Parameters:
        name - the name N
        Returns:
        if there is an overriding declaration of N, then the original declaration of N from the used package; otherwise null
      • addOverriddenComponent

        public void addOverriddenComponent​(Component comp)
      • addComponentsFromUsedPackage

        public void addComponentsFromUsedPackage​(StylesheetPackage usedPackage,
                                                 java.util.List<XSLAccept> acceptors,
                                                 java.util.Set<SymbolicName> overrides)
                                          throws XPathException
        Add modified copies of components from a package that is referenced from this one in an xsl:use-package declaration
        Parameters:
        usedPackage - the used package
        acceptors - abstraction of a list of xsl:accept declarations, which can modify the visibility of accepted components
        overrides - the set of names of components from the used package that are overridden in the using package
        Throws:
        XPathException - if duplicate components are found
      • createFunctionLibrary

        public void createFunctionLibrary()
        Create the function library containing stylesheet functions declared in this package
      • addIxslFunctionLibrary

        protected void addIxslFunctionLibrary​(FunctionLibraryList functionLibrary)
      • addIxsl3FunctionLibrary

        protected void addIxsl3FunctionLibrary​(FunctionLibraryList functionLibrary)
      • addStubFunctionLibrary

        protected void addStubFunctionLibrary​(FunctionLibrary stubFunctions)
      • getFunctionLibrary

        public FunctionLibraryList getFunctionLibrary()
        Get the function library.
        Returns:
        the function library
      • getPublicFunctions

        public FunctionLibrary getPublicFunctions()
        Get the library of functions exposed by this stylesheet package, that is, functions whose visibility is public or final
        Returns:
        a function library containing only the functions that are exposed as public
      • getXQueryFunctionLibrary

        public XQueryFunctionLibrary getXQueryFunctionLibrary()
        Get the library of functions imported from XQuery
        Returns:
        the XQuery function library
      • setFunctionLibraryDetails

        public void setFunctionLibraryDetails​(FunctionLibraryList library,
                                              ExecutableFunctionLibrary overriding,
                                              ExecutableFunctionLibrary underriding)
        Set details of functions available for calling anywhere in this package. This is the function library used for resolving run-time references to functions, for example from xsl:evaluate, function-available(), or function-lookup().
        Parameters:
        library - the main function library (as a list of sub-libraries)
        overriding - library of stylesheet functions declared with override=yes
        underriding - library of stylesheet functions declared with override=no
      • getFunction

        public UserFunction getFunction​(SymbolicName.F name)
        Get the function with a given name and arity
        Parameters:
        name - the symbolic name of the function (QName plus arity)
        Returns:
        the requested function, or null if none can be found
      • isRetainUnusedFunctions

        public boolean isRetainUnusedFunctions()
        Ask whether private functions for which there are no static references need to be retained
        Returns:
        true if such functions need to be retained, typically because the stylesheet package uses xsl:evaluate or fn:function-lookup
      • setRetainUnusedFunctions

        public void setRetainUnusedFunctions()
        Say that private functions need to be retained, typically because the stylesheet package uses xsl:evaluate or fn:function-lookup
      • updatePreparedStylesheet

        public void updatePreparedStylesheet​(PreparedStylesheet pss)
                                      throws XPathException
        Copy information from this package to the PreparedStylesheet.
        Parameters:
        pss - the PreparedStylesheet to be updated
        Throws:
        XPathException - if the PreparedStylesheet cannot be updated
      • markNonExportable

        public void markNonExportable​(java.lang.String message,
                                      java.lang.String errorCode)
        Mark the package as non-exportable, supplying an error message to be reported if export is attempted
        Parameters:
        message - the error message to report indicating why export is not possible
        errorCode - the error code to report if export is attempted
      • export

        public void export​(ExpressionPresenter presenter)
                    throws XPathException
        Output the abstract expression tree to the supplied destination.
        Parameters:
        presenter - the expression presenter used to display the structure
        Throws:
        XPathException - if exporting fails or is not permitted (it requires Saxon-EE)
      • isFallbackToNonStreaming

        public boolean isFallbackToNonStreaming()
        Ask whether a non-streamable construct has been found, forcing the entire stylesheet to fall back to unstreamed processing
        Returns:
        true if the stylesheet must fall back to unstreamed processing
      • setFallbackToNonStreaming

        public void setFallbackToNonStreaming()