Class StylesheetPackage

java.lang.Object
net.sf.saxon.expr.PackageData
net.sf.saxon.style.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 Details Link icon

  • Constructor Details Link icon

    • StylesheetPackage Link icon

      public StylesheetPackage(Configuration config)
      Create a stylesheet package
      Parameters:
      config - the Saxon Configuration
  • Method Details Link icon

    • getComponentIndex Link icon

      public 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 Link icon

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

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

      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 Link icon

      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 Link icon

      public void setPackageName(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 Link icon

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

      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 Link icon

      public 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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      public void setDefaultOutputProperties(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 Link icon

      public void setNamedOutputProperties(StructuredQName name, 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 Link icon

      public 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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

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

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

      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 Link icon

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

      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 Link icon

      public void addHiddenComponent(Component component)
    • getOverriddenComponent Link icon

      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 Link icon

      public void addOverriddenComponent(Component comp)
    • addComponentsFromUsedPackage Link icon

      public void addComponentsFromUsedPackage(StylesheetPackage usedPackage, List<XSLAccept> acceptors, 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 Link icon

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

      protected void addIxslFunctionLibrary(FunctionLibraryList functionLibrary)
    • addIxsl3FunctionLibrary Link icon

      protected void addIxsl3FunctionLibrary(FunctionLibraryList functionLibrary)
    • addStubFunctionLibrary Link icon

      protected void addStubFunctionLibrary(FunctionLibrary stubFunctions)
    • getFunctionLibrary Link icon

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

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

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

      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
    • getAbstractComponents Link icon

      public Map<SymbolicName,Component> getAbstractComponents()
    • markNonExportable Link icon

      public void markNonExportable(String message, 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 Link icon

      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)
    • checkForAbstractComponents Link icon

      public void checkForAbstractComponents() throws XPathException
      Throws:
      XPathException
    • isFallbackToNonStreaming Link icon

      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 Link icon

      public void setFallbackToNonStreaming()