Package net.sf.saxon.style
Class StylesheetModule
java.lang.Object
net.sf.saxon.style.StylesheetModule
- Direct Known Subclasses:
PrincipalStylesheetModule
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Source
getAssociatedStylesheet
(Configuration config, ResourceResolver resolver, Source source, String media, String title, String charset) 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.int
Get the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules.int
Get the minimum import precedence of this module, that is, the lowest import precedence of the modules that it imports.int
static PreparedStylesheet
loadStylesheet
(Source styleSource, Compilation compilation) Build the tree representation of a stylesheet modulestatic DocumentImpl
loadStylesheetModule
(Source styleSource, boolean topLevelModule, Compilation compilation, NestedIntegerValue precedence) Build the tree representation of a stylesheet modulevoid
setImporter
(StylesheetModule importer) void
setInputTypeAnnotations
(int annotations) Set the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules.void
setMinImportPrecedence
(int min) Set the minimum import precedence of this module, that is, the lowest import precedence of the modules that it imports.void
Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:importvoid
Process xsl:include and xsl:import elements.
-
Field Details
-
topLevel
-
-
Constructor Details
-
StylesheetModule
-
-
Method Details
-
loadStylesheetModule
public static DocumentImpl loadStylesheetModule(Source styleSource, boolean topLevelModule, Compilation compilation, NestedIntegerValue precedence) throws XPathException Build the tree representation of a stylesheet module- Parameters:
styleSource
- the source of the moduletopLevelModule
- true if this module is the outermost module of a packagecompilation
- the XSLT compilation episodeprecedence
- 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(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 Source getAssociatedStylesheet(Configuration config, ResourceResolver resolver, Source source, String media, String title, 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 Configurationresolver
- a URIResolver to be used for dereferencing URIssource
- 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 methodConfiguration.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
-
setImporter
-
getImporter
-
getPrincipalStylesheetModule
-
getRootElement
-
getStylesheetElement
-
getConfiguration
-
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
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 bitsXSLModuleRoot.ANNOTATION_STRIP
andXSLModuleRoot.ANNOTATION_PRESERVE
- Returns:
- the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules
-
setInputTypeAnnotations
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 bitsXSLModuleRoot.ANNOTATION_STRIP
andXSLModuleRoot.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
-