net.sf.saxon.style

Class XSLStylesheet

public class XSLStylesheet extends StyleElement

An xsl:stylesheet or xsl:transform element in the stylesheet.
Note this element represents a stylesheet module, not necessarily the whole stylesheet.
Field Summary
static intANNOTATION_PRESERVE
static intANNOTATION_STRIP
Executableexec
Method Summary
protected voidaddImportedSchema(String targetNamespace)
intallocateGlobalSlot(int fingerprint)
Allocate a slot number for a global variable or parameter
voidallocatePatternSlots(int n)
Ensure there is enough space for local variables or parameters when evaluating the match pattern of template rules
Expressioncompile(Executable exec)
Dummy compile() method to satisfy the interface
ExecutablecompileStylesheet()
Compile the stylesheet to create an executable.
protected voiddeclareJavaClass(String uri, Class theClass)
Declare a URI that maps to a Java class containing extension functions
protected voiddeclareXQueryFunction(XQueryFunction function)
Declare an imported XQuery function
protected ComparatorfindCollation(String name)
Find a named collation.
PropertiesgatherOutputProperties(int fingerprint)
Create an output properties object representing the xsl:output elements in the stylesheet.
XSLCharacterMapgetCharacterMap(int fingerprint)
Get a character map, identified by the fingerprint of its name.
DecimalFormatManagergetDecimalFormatManager()
Get the DecimalFormatManager which handles decimal-format definitions
StringgetDefaultCollationName()
Get the name of the default collation
intgetDefaultValidation()
Get the value of the default validation attribute
ExecutablegetExecutable()
Get the run-time Executable object
FunctionLibrarygetFunctionLibrary()
Get the function library.
XSLVariableDeclarationgetGlobalVariable(int fingerprint)
Get the global variable or parameter with a given fingerprint (taking precedence rules into account)
protected HashSetgetImportedSchemaTable()
XSLStylesheetgetImporter()
Get the StyleSheet that included or imported this one.
intgetInputTypeAnnotations()
Get the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules.
intgetInputTypeAnnotationsAttribute()
Get the value of the input-type-annotations attribute, for this module alone.
KeyManagergetKeyManager()
Get the KeyManager which handles key definitions
LocationMapgetLocationMap()
Get the locationMap object
intgetMinImportPrecedence()
Get the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
protected intgetNamespaceAlias(short uriCode)
Get the declared namespace alias for a given namespace URI code if there is one.
intgetPrecedence()
Get the import precedence of this stylesheet
PreparedStylesheetgetPreparedStylesheet()
Get the owning PreparedStylesheet object
RuleManagergetRuleManager()
Get the RuleManager which handles template rules
protected ModegetStripperRules()
Get the rules determining which nodes are to be stripped from the tree
NamePoolgetTargetNamePool()
Get the namepool to be used at run-time, this namepool holds the names used in all XPath expressions and patterns
ListgetTopLevel()
Get the top level elements in this stylesheet, after applying include/import
protected booleanhasNamespaceAliases()
protected booleanisAliasResultNamespace(short uriCode)
Determine if a namespace is included in the result-prefix of a namespace-alias
protected booleanisImportedSchema(String targetNamespace)
Get an imported schema with a given namespace
voidprepareAttributes()
Prepare the attributes on the stylesheet element
voidpreprocess()
Preprocess does all the processing possible before the source document is available.
voidprocessAllAttributes()
Process the attributes of every node in the stylesheet
voidsetCollation(String name, Comparator collation, boolean isDefault)
Register a named collation (actually a Comparator)
voidsetImporter(XSLStylesheet importer)
Set the StyleSheet that included or imported this one.
voidsetInputTypeAnnotations(int annotations)
Set the value of the input-type-annotations attribute, for this module combined with that of all included/imported modules.
voidsetMinImportPrecedence(int precedence)
Set the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
voidsetNeedsDynamicOutputProperties(boolean b)
Set that this stylesheet needs dynamic output properties
voidsetPrecedence(int prec)
Set the import precedence of this stylesheet
voidsetPreparedStylesheet(PreparedStylesheet sheet)
Create link to the owning PreparedStylesheet object
voidsetWasIncluded()
Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:import
voidspliceIncludes()
Process xsl:include and xsl:import elements.
booleanstripsWhitespace()
Determine whether this stylesheet does any whitespace stripping
voidvalidate()
Validate this element

Field Detail

ANNOTATION_PRESERVE

public static final int ANNOTATION_PRESERVE

ANNOTATION_STRIP

public static final int ANNOTATION_STRIP

exec

Executable exec

Method Detail

addImportedSchema

protected void addImportedSchema(String targetNamespace)

allocateGlobalSlot

public int allocateGlobalSlot(int fingerprint)
Allocate a slot number for a global variable or parameter

allocatePatternSlots

public void allocatePatternSlots(int n)
Ensure there is enough space for local variables or parameters when evaluating the match pattern of template rules

compile

public Expression compile(Executable exec)
Dummy compile() method to satisfy the interface

compileStylesheet

public Executable compileStylesheet()
Compile the stylesheet to create an executable.

declareJavaClass

protected void declareJavaClass(String uri, Class theClass)
Declare a URI that maps to a Java class containing extension functions

declareXQueryFunction

protected void declareXQueryFunction(XQueryFunction function)
Declare an imported XQuery function

findCollation

protected Comparator findCollation(String name)
Find a named collation. Note this method should only be used at compile-time, before declarations have been pre-processed. After that time, use getCollation().

Parameters: name identifies the name of the collation required; null indicates that the default collation is required

Returns: null if the collation is not found

gatherOutputProperties

public Properties gatherOutputProperties(int fingerprint)
Create an output properties object representing the xsl:output elements in the stylesheet.

Parameters: fingerprint The name of the output format required. If set to -1, gathers information for the unnamed output format

Returns: the Properties object containing the details of the specified output format

Throws: XPathException if a named output format does not exist in the stylesheet

getCharacterMap

public XSLCharacterMap getCharacterMap(int fingerprint)
Get a character map, identified by the fingerprint of its name. Search backwards through the stylesheet.

Parameters: fingerprint The fingerprint of the character map name, in the target namepool.

Returns: the identified character map, or null if not found

getDecimalFormatManager

public DecimalFormatManager getDecimalFormatManager()
Get the DecimalFormatManager which handles decimal-format definitions

getDefaultCollationName

public String getDefaultCollationName()
Get the name of the default collation

getDefaultValidation

public int getDefaultValidation()
Get the value of the default validation attribute

getExecutable

public Executable getExecutable()
Get the run-time Executable object

getFunctionLibrary

public FunctionLibrary getFunctionLibrary()
Get the function library. Available only on the principal stylesheet module

getGlobalVariable

public XSLVariableDeclaration getGlobalVariable(int fingerprint)
Get the global variable or parameter with a given fingerprint (taking precedence rules into account)

getImportedSchemaTable

protected HashSet getImportedSchemaTable()

getImporter

public XSLStylesheet getImporter()
Get the StyleSheet that included or imported this one.

Returns: null if this is the principal stylesheet

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 ANNOTATION_STRIP and ANNOTATION_PRESERVE

getInputTypeAnnotationsAttribute

public int getInputTypeAnnotationsAttribute()
Get the value of the input-type-annotations attribute, for this module alone. The value is an or-ed combination of the two bits ANNOTATION_STRIP and ANNOTATION_PRESERVE

getKeyManager

public KeyManager getKeyManager()
Get the KeyManager which handles key definitions

getLocationMap

public LocationMap getLocationMap()
Get the locationMap object

getMinImportPrecedence

public int getMinImportPrecedence()
Get the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one

getNamespaceAlias

protected int getNamespaceAlias(short uriCode)
Get the declared namespace alias for a given namespace URI code if there is one. If there is more than one, we get the last.

Parameters: uriCode The code of the uri used in the stylesheet.

Returns: The namespace code to be used (prefix in top half, uri in bottom half): return -1 if no alias is defined

getPrecedence

public int getPrecedence()
Get the import precedence of this stylesheet

getPreparedStylesheet

public PreparedStylesheet getPreparedStylesheet()
Get the owning PreparedStylesheet object

getRuleManager

public RuleManager getRuleManager()
Get the RuleManager which handles template rules

getStripperRules

protected Mode getStripperRules()
Get the rules determining which nodes are to be stripped from the tree

getTargetNamePool

public NamePool getTargetNamePool()
Get the namepool to be used at run-time, this namepool holds the names used in all XPath expressions and patterns

getTopLevel

public List getTopLevel()
Get the top level elements in this stylesheet, after applying include/import

hasNamespaceAliases

protected boolean hasNamespaceAliases()

isAliasResultNamespace

protected boolean isAliasResultNamespace(short uriCode)
Determine if a namespace is included in the result-prefix of a namespace-alias

isImportedSchema

protected boolean isImportedSchema(String targetNamespace)
Get an imported schema with a given namespace

Parameters: targetNamespace The target namespace of the required schema. Supply an empty string for the default namespace

Returns: the required Schema, or null if no such schema has been imported

prepareAttributes

public void prepareAttributes()
Prepare the attributes on the stylesheet element

preprocess

public void preprocess()
Preprocess does all the processing possible before the source document is available. It is done once per stylesheet, so the stylesheet can be reused for multiple source documents. The method is called only on the XSLStylesheet element representing the principal stylesheet module

processAllAttributes

public void processAllAttributes()
Process the attributes of every node in the stylesheet

setCollation

public void setCollation(String name, Comparator collation, boolean isDefault)
Register a named collation (actually a Comparator)

setImporter

public void setImporter(XSLStylesheet importer)
Set the StyleSheet that included or imported this one.

setInputTypeAnnotations

public void setInputTypeAnnotations(int annotations)
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 ANNOTATION_STRIP and ANNOTATION_PRESERVE

setMinImportPrecedence

public void setMinImportPrecedence(int precedence)
Set the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one

setNeedsDynamicOutputProperties

public void setNeedsDynamicOutputProperties(boolean b)
Set that this stylesheet needs dynamic output properties

setPrecedence

public void setPrecedence(int prec)
Set the import precedence of this stylesheet

setPreparedStylesheet

public void setPreparedStylesheet(PreparedStylesheet sheet)
Create link to the owning PreparedStylesheet object

setWasIncluded

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

spliceIncludes

public void spliceIncludes()
Process xsl:include and xsl:import elements.

stripsWhitespace

public boolean stripsWhitespace()
Determine whether this stylesheet does any whitespace stripping

validate

public void validate()
Validate this element