Package net.sf.saxon.style
Class XSLStylesheet
- java.lang.Object
-
- All Implemented Interfaces:
javax.xml.transform.Source,javax.xml.transform.SourceLocator,LocationProvider,SaxonLocator,Container,FingerprintedNode,Item,NodeInfo,ValueRepresentation,InstructionInfo,org.xml.sax.Locator
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
Fields Modifier and Type Field Description static intANNOTATION_PRESERVEstatic intANNOTATION_STRIP(package private) Executableexec-
Fields inherited from class net.sf.saxon.style.StyleElement
defaultCollationName, defaultXPathNamespace, extensionNamespaces, REPORT_ALWAYS, REPORT_IF_INSTANTIATED, REPORT_UNLESS_FALLBACK_AVAILABLE, REPORT_UNLESS_FORWARDS_COMPATIBLE, reportingCircumstances, staticContext, validationError, version
-
Fields inherited from class net.sf.saxon.tree.ElementWithAttributes
attributeList, namespaceList
-
Fields inherited from class net.sf.saxon.tree.ElementImpl
nameCode, root
-
Fields inherited from class net.sf.saxon.tree.ParentNodeImpl
sequence
-
Fields inherited from class net.sf.saxon.tree.NodeImpl
index, NODE_LETTER, parent
-
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
-
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
-
Constructor Summary
Constructors Constructor Description XSLStylesheet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddImportedSchema(java.lang.String targetNamespace)intallocateGlobalSlot(int fingerprint)Allocate a slot number for a global variable or parametervoidallocatePatternSlots(int n)Ensure there is enough space for local variables or parameters when evaluating the match pattern of template rulesbooleanallowsAllBuiltInTypes()Determine whether the use of non-primitive built-in types has been enabled for this stylesheet (This is relevant only for Saxon-B: such types are always permitted in Saxon-SA)Expressioncompile(Executable exec)Dummy compile() method to satisfy the interfaceExecutablecompileStylesheet()Compile the stylesheet to create an executable.protected voiddeclareJavaClass(java.lang.String uri, java.lang.Class theClass)Declare a URI that maps to a Java class containing extension functionsprotected voiddeclareXQueryFunction(XQueryFunction function)Declare an imported XQuery functionprotected java.util.ComparatorfindCollation(java.lang.String name)Find a named collation.java.util.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.CollationMapgetCollationMap()Get the collation mapDecimalFormatManagergetDecimalFormatManager()Get the DecimalFormatManager which handles decimal-format definitionsjava.lang.StringgetDefaultCollationName()Get the name of the default collationintgetDefaultValidation()Get the value of the default validation attributeExecutablegetExecutable()Get the run-time Executable objectFunctionLibrarygetFunctionLibrary()Get the function library.XSLVariableDeclarationgetGlobalVariable(int fingerprint)Get the global variable or parameter with a given fingerprint (taking precedence rules into account)protected java.util.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 definitionsLocationMapgetLocationMap()Get the locationMap objectintgetMinImportPrecedence()Get the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this oneprotected 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 stylesheetPreparedStylesheetgetPreparedStylesheet()Get the owning PreparedStylesheet objectRuleManagergetRuleManager()Get the RuleManager which handles template rulesprotected ModegetStripperRules()Get the rules determining which nodes are to be stripped from the treeNamePoolgetTargetNamePool()Get the namepool to be used at run-time, this namepool holds the names used in all XPath expressions and patternsjava.util.ListgetTopLevel()Get the top level elements in this stylesheet, after applying include/importprotected booleanhasNamespaceAliases()protected booleanisAliasResultNamespace(short uriCode)Determine if a namespace is included in the result-prefix of a namespace-aliasprotected booleanisImportedSchema(java.lang.String targetNamespace)Get an imported schema with a given namespacevoidprepareAttributes()Prepare the attributes on the stylesheet elementvoidpreprocess()Preprocess does all the processing possible before the source document is available.voidprocessAllAttributes()Process the attributes of every node in the stylesheetvoidsetCollation(java.lang.String name, java.util.Comparator collation)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 onevoidsetNeedsDynamicOutputProperties(boolean b)Set that this stylesheet needs dynamic output propertiesvoidsetPrecedence(int prec)Set the import precedence of this stylesheetvoidsetPreparedStylesheet(PreparedStylesheet sheet)Create link to the owning PreparedStylesheet objectvoidsetWasIncluded()Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:importvoidspliceIncludes()Process xsl:include and xsl:import elements.booleanstripsWhitespace()Determine whether this stylesheet does any whitespace strippingvoidvalidate()Validate this element-
Methods inherited from class net.sf.saxon.style.StyleElement
allocateLocationId, allocateSlots, backwardsCompatibleModeIsEnabled, bindVariable, checkEmpty, checkSortComesFirst, checkTopLevel, checkUnknownAttribute, checkWithinTemplate, compileError, compileError, compileError, compileSequenceConstructor, compileWarning, definesExcludedNamespace, definesExtensionElement, fallbackProcessing, fixupReferences, forwardsCompatibleModeIsEnabled, getAttributeSets, getAttributeValue, getCommonChildItemType, getConstructType, getContainingSlotManager, getContainingStylesheet, getDefaultXPathNamespace, getHostLanguage, getLastChildInstruction, getLineNumber, getLineNumber, getLocationProvider, getNamespaceResolver, getObjectFingerprint, getObjectNameCode, getPrincipalStylesheet, getProperties, getProperty, getReturnedItemType, getSchemaType, getStaticContext, getStylesheetFunction, getSystemId, getTypeAnnotation, getVersion, getWithParamInstructions, isExcludedNamespace, isExplaining, isExtensionNamespace, isInstruction, isPermittedChild, issueWarning, issueWarning, isTopLevel, makeAttributeValueTemplate, makeExpression, makeNameCode, makeNamespaceContext, makePattern, makeSequenceType, makeSortKeys, makeTraceInstruction, markTailCalls, mayContainFallback, mayContainSequenceConstructor, postValidate, processAttributes, processDefaultCollationAttribute, processDefaultXPathNamespaceAttribute, processExcludedNamespaces, processExtensionElementAttribute, processVersionAttribute, replaceSubExpression, reportAbsence, setLineNumber, setObjectNameCode, setValidationError, substituteFor, typeCheck, typeCheck, undeclaredNamespaceError, validateChildren, validateSubtree
-
Methods inherited from class net.sf.saxon.tree.ElementWithAttributes
copy, getAttributeList, getAttributeValue, getDeclaredNamespaces, getInScopeNamespaceCodes, getPrefixForURI, getURICodeForPrefix, getURIForPrefix, initialise, iteratePrefixes, sendNamespaceDeclarations, setNamespaceDeclarations
-
Methods inherited from class net.sf.saxon.tree.ElementImpl
generateId, getBaseURI, getDocumentRoot, getNameCode, getNodeKind, getRoot, getSystemId, setNameCode, setSystemId
-
Methods inherited from class net.sf.saxon.tree.ParentNodeImpl
addChild, compact, enumerateChildren, getFirstChild, getLastChild, getNthChild, getSequenceNumber, getStringValue, getStringValueCS, hasChildNodes, useChildrenArray
-
Methods inherited from class net.sf.saxon.tree.NodeImpl
atomize, compareOrder, equals, getColumnNumber, getConfiguration, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getTypeAnnotation, getTypedValue, getURI, hashCode, isSameNodeInfo, iterateAxis, iterateAxis
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.InstructionInfo
getSystemId
-
-
-
-
Field Detail
-
exec
Executable exec
-
ANNOTATION_STRIP
public static final int ANNOTATION_STRIP
- See Also:
- Constant Field Values
-
ANNOTATION_PRESERVE
public static final int ANNOTATION_PRESERVE
- See Also:
- Constant Field Values
-
-
Method Detail
-
setPreparedStylesheet
public void setPreparedStylesheet(PreparedStylesheet sheet)
Create link to the owning PreparedStylesheet object
-
getPreparedStylesheet
public PreparedStylesheet getPreparedStylesheet()
Get the owning PreparedStylesheet object- Overrides:
getPreparedStylesheetin classStyleElement- Returns:
- the PreparedStylesheet to which this stylesheet element belongs
-
getExecutable
public Executable getExecutable()
Get the run-time Executable object- Specified by:
getExecutablein interfaceContainer- Overrides:
getExecutablein classStyleElement
-
getFunctionLibrary
public FunctionLibrary getFunctionLibrary()
Get the function library. Available only on the principal stylesheet module
-
getLocationMap
public LocationMap getLocationMap()
Get the locationMap object
-
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- Overrides:
getTargetNamePoolin classStyleElement
-
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
-
stripsWhitespace
public boolean stripsWhitespace()
Determine whether this stylesheet does any whitespace stripping
-
getKeyManager
public KeyManager getKeyManager()
Get the KeyManager which handles key definitions
-
getDecimalFormatManager
public DecimalFormatManager getDecimalFormatManager()
Get the DecimalFormatManager which handles decimal-format definitions
-
getCollationMap
public CollationMap getCollationMap()
Get the collation map
-
setCollation
public void setCollation(java.lang.String name, java.util.Comparator collation)Register a named collation (actually a Comparator)
-
findCollation
protected java.util.Comparator findCollation(java.lang.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
-
getDefaultCollationName
public java.lang.String getDefaultCollationName()
Get the name of the default collation- Overrides:
getDefaultCollationNamein classStyleElement
-
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
-
setPrecedence
public void setPrecedence(int prec)
Set the import precedence of this stylesheet
-
getPrecedence
public int getPrecedence()
Get the import precedence of this stylesheet- Overrides:
getPrecedencein classStyleElement
-
getMinImportPrecedence
public int getMinImportPrecedence()
Get the minimum import precedence of this stylesheet, that is, the lowest precedence of any stylesheet imported by this one
-
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
-
setImporter
public void setImporter(XSLStylesheet importer)
Set the StyleSheet that included or imported this one.
-
getImporter
public XSLStylesheet getImporter()
Get the StyleSheet that included or imported this one.- Returns:
- null if this is the principal stylesheet
-
setWasIncluded
public void setWasIncluded()
Indicate that this stylesheet was included (by its "importer") using an xsl:include statement as distinct from xsl:import
-
getTopLevel
public java.util.List getTopLevel()
Get the top level elements in this stylesheet, after applying include/import
-
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
-
prepareAttributes
public void prepareAttributes() throws XPathExceptionPrepare the attributes on the stylesheet element- Specified by:
prepareAttributesin classStyleElement- Throws:
XPathException
-
getDefaultValidation
public int getDefaultValidation()
Get the value of the default validation attribute
-
getInputTypeAnnotationsAttribute
public int getInputTypeAnnotationsAttribute() throws XPathExceptionGet the value of the input-type-annotations attribute, for this module alone. The value is an or-ed combination of the two bitsANNOTATION_STRIPandANNOTATION_PRESERVE- Throws:
XPathException
-
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 bitsANNOTATION_STRIPandANNOTATION_PRESERVE
-
setInputTypeAnnotations
public void setInputTypeAnnotations(int annotations) throws XPathExceptionSet 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 bitsANNOTATION_STRIPandANNOTATION_PRESERVE- Throws:
XPathException
-
allowsAllBuiltInTypes
public boolean allowsAllBuiltInTypes()
Determine whether the use of non-primitive built-in types has been enabled for this stylesheet (This is relevant only for Saxon-B: such types are always permitted in Saxon-SA)
-
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
-
isAliasResultNamespace
protected boolean isAliasResultNamespace(short uriCode)
Determine if a namespace is included in the result-prefix of a namespace-alias
-
validate
public void validate() throws XPathExceptionValidate this element- Overrides:
validatein classStyleElement- Throws:
XPathException
-
preprocess
public void preprocess() throws XPathExceptionPreprocess 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- Throws:
XPathException
-
spliceIncludes
public void spliceIncludes() throws XPathExceptionProcess xsl:include and xsl:import elements.- Throws:
XPathException
-
hasNamespaceAliases
protected boolean hasNamespaceAliases()
-
processAllAttributes
public void processAllAttributes() throws XPathExceptionProcess the attributes of every node in the stylesheet- Overrides:
processAllAttributesin classStyleElement- Throws:
XPathException
-
getGlobalVariable
public XSLVariableDeclaration getGlobalVariable(int fingerprint)
Get the global variable or parameter with a given fingerprint (taking precedence rules into account)
-
setNeedsDynamicOutputProperties
public void setNeedsDynamicOutputProperties(boolean b)
Set that this stylesheet needs dynamic output properties
-
gatherOutputProperties
public java.util.Properties gatherOutputProperties(int fingerprint) throws XPathExceptionCreate 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
-
declareXQueryFunction
protected void declareXQueryFunction(XQueryFunction function) throws XPathException
Declare an imported XQuery function- Throws:
XPathException
-
declareJavaClass
protected void declareJavaClass(java.lang.String uri, java.lang.Class theClass)Declare a URI that maps to a Java class containing extension functions
-
isImportedSchema
protected boolean isImportedSchema(java.lang.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
-
addImportedSchema
protected void addImportedSchema(java.lang.String targetNamespace)
-
getImportedSchemaTable
protected java.util.HashSet getImportedSchemaTable()
-
compileStylesheet
public Executable compileStylesheet() throws XPathException
Compile the stylesheet to create an executable.- Throws:
XPathException
-
compile
public Expression compile(Executable exec)
Dummy compile() method to satisfy the interface- Specified by:
compilein classStyleElement- Returns:
- either a ComputedExpression, or null. The value null is returned when compiling an instruction that returns a no-op, or when compiling a top-level object such as an xsl:template that compiles into something other than an instruction.
-
-