Package net.sf.saxon.style
Class XSLTemplate
- All Implemented Interfaces:
Source
,SourceLocator
,ActiveSource
,GroundedValue
,Item
,MutableNodeInfo
,NamespaceResolver
,NodeInfo
,Sequence
,Location
,StylesheetComponent
,SteppingNode
,SiblingCountingNode
,Locator
An xsl:template element in the style sheet.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.style.StyleElement
StyleElement.OnFailure
-
Field Summary
Fields inherited from class net.sf.saxon.style.StyleElement
ACTION_COMPILE, ACTION_FIXUP, ACTION_OPTIMIZE, ACTION_PROCESS_ATTRIBUTES, ACTION_TYPECHECK, ACTION_VALIDATE, actionsCompleted, defaultCollationName, defaultMode, defaultXPathNamespace, expandText, extensionNamespaces, reportingCircumstances, staticContext, validationError, version, YES_NO
Fields inherited from class net.sf.saxon.tree.linked.NodeImpl
NODE_LETTER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Allocate slot numbers to any local variables declared within a predicate within the match patternboolean
Ask whether this is a template rule with mode="#all"void
checkCompatibility
(Component component) Check the compatibility of this component with another component that it is overridingvoid
compileDeclaration
(Compilation compilation, ComponentDeclaration decl) Compile: creates the executable form of the templatevoid
compileTemplateRule
(Compilation compilation, Expression body) getActor()
Get the corresponding NamedTemplate object that results from the compilation of this StylesheetComponentGet the modes to which this template rule appliesGet the compiled templategetMatch()
Return the list of mode names to which this template rule is applicable.getParam
(StructuredQName name) Get associated Procedure (for details of stack frame)Get the symbolic name of the component, that is, the combination of the component kind and the qualified nameReturn the name of this template.void
index
(ComponentDeclaration decl, PrincipalStylesheetModule top) If this is a named template, then add it to the stylesheet-level component indexboolean
Ask whether this node is a declaration, that is, a permitted child of xsl:stylesheet (including xsl:include and xsl:import).boolean
isDeferredCompilation
(Compilation compilation) Ask whether the compilation of the template should be deferredboolean
protected boolean
isPermittedChild
(StyleElement child) Specify that xsl:param and xsl:context-item are permitted childrenprotected boolean
void
jitCompile
(Compilation compilation, ComponentDeclaration decl) Code executed when the template is first executed under JIT.protected boolean
Mark tail-recursive calls on templates and functions.protected boolean
Determine whether this type of element is allowed to contain an xsl:param elementprotected boolean
Determine whether this type of element is allowed to contain a template-bodyvoid
optimize
(ComponentDeclaration declaration) This method is a bit of a misnomer, because it does more than invoke optimization of the template body.protected void
Set the attribute list for the element.void
Process the attributes of this element and all its childrenvoid
register
(ComponentDeclaration declaration) Registers the template rule with each Mode that it belongs to.void
setCompilation
(Compilation compilation) void
setContextItemRequirements
(ItemType type, boolean mayBeOmitted, boolean absentFocus) Set the required context item type.void
validate
(ComponentDeclaration decl) Check that the stylesheet element is valid.void
validateSubtree
(ComponentDeclaration decl, boolean excludeStylesheet) Recursive walk through the stylesheet to validate all nodesMethods inherited from class net.sf.saxon.style.StyleElement
allocateLocation, bindLocalVariable, bindVariable, checkEmpty, checkTopLevel, checkUnknownAttribute, compile, compileError, compileError, compileError, compileError, compileError, compileError, compileErrorInAttribute, compileErrorInAttribute, compileSequenceConstructor, compileSequenceConstructor, compileWarning, compileWarning, fixupReferences, generateId, getAttributeValue, getBaseURI, getBindingInformation, getCompilation, getConfiguration, getContainingPackage, getContainingSlotManager, getDeclaredVisibility, getDefaultCollationName, getDefaultXPathNamespace, getNamespaceResolver, getObjectName, getPackageData, getPrincipalStylesheetModule, getProperties, getSchemaType, getStaticContext, getStaticContext, getTypeAnnotation, getUsedPackage, getVisibility, getWithParamInstructions, getXslOriginal, hasImplicitBinding, invalidAttribute, isExtensionAttributeAllowed, isExtensionNamespace, isInstruction, isInXsltNamespace, isNo, isSchemaAware, issueWarning, issueWarning, isTopLevel, isYes, makeAttributeValueTemplate, makeExpression, makeExpressionVisitor, makeQName, makeRetainedStaticContext, makeSequenceType, mapToSequence, mayContainFallback, postValidate, processAttributes, processBooleanAttribute, processStandardAttributes, processVersionAttribute, reportAbsence, requireXslt40Attribute, requireXslt40Element, seesAvuncularVariables, setInstructionLocation, setObjectName, setValidationError, substituteFor, typeCheck, typeCheck, validateChildren, validateValidationAttribute
Methods inherited from class net.sf.saxon.tree.linked.ElementImpl
addAttribute, addNamespace, addNamespace, attributes, checkNotNamespaceSensitiveElement, copy, delete, fixupInsertedNamespaces, generateId, getAllNamespaces, getAttributeValue, getColumnNumber, getDeclaredNamespaces, getLineNumber, getNodeKind, getNodeName, getRoot, getSchemaType, getSystemId, getURIForPrefix, initialise, isId, isIdref, isIdRefNode, isInScopeNamespace, isNilled, iteratePrefixes, removeAttribute, removeNamespace, removeTypeAnnotation, rename, replaceStringValue, setAttributeInfo, setAttributes, setLocation, setNamespaceMap, setNilled, setNodeName, setSystemId, setTypeAnnotation
Methods inherited from class net.sf.saxon.tree.linked.ParentNodeImpl
addChild, compact, getFirstChild, getLastChild, getNthChild, getNumberOfChildren, getRawSequenceNumber, getSequenceNumber, getUnicodeStringValue, hasChildNodes, insertChildren, insertChildrenAt, iterateChildren, removeChild, replaceChildrenAt, setChildren, setRawSequenceNumber
Methods inherited from class net.sf.saxon.tree.linked.NodeImpl
atomize, compareOrder, effectiveBooleanValue, equals, getDisplayName, getFingerprint, getLocalPart, getNamePool, getNamespaceUri, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getRawParent, getSiblingPosition, getSuccessorElement, getTreeInfo, hasFingerprint, hashCode, head, insertSiblings, isDeleted, iterateAxis, iterateAxis, newBuilder, replace, saveLocation, setRawParent, setSiblingPosition
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.NodeInfo
asActiveSource, children, children, deliver, getAttributeValue, getGenre, getPublicId, getURI, isSameNodeInfo, isStreamed, toShortString
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
XSLTemplate
public XSLTemplate()
-
-
Method Details
-
getActor
Get the corresponding NamedTemplate object that results from the compilation of this StylesheetComponent- Specified by:
getActor
in interfaceStylesheetComponent
- Returns:
- the compiled ComponentCode
-
setCompilation
- Overrides:
setCompilation
in classStyleElement
-
isDeclaration
public boolean isDeclaration()Ask whether this node is a declaration, that is, a permitted child of xsl:stylesheet (including xsl:include and xsl:import).- Overrides:
isDeclaration
in classStyleElement
- Returns:
- true for this element
-
isDeferredCompilation
Ask whether the compilation of the template should be deferred- Parameters:
compilation
- the compilation- Returns:
- true if compilation should be deferred
-
mayContainSequenceConstructor
protected boolean mayContainSequenceConstructor()Determine whether this type of element is allowed to contain a template-body- Overrides:
mayContainSequenceConstructor
in classStyleElement
- Returns:
- true: yes, it may contain a template-body
-
mayContainParam
protected boolean mayContainParam()Description copied from class:StyleElement
Determine whether this type of element is allowed to contain an xsl:param element- Overrides:
mayContainParam
in classStyleElement
- Returns:
- true if this element is allowed to contain an xsl:param
-
isWithinDeclaredStreamableConstruct
protected boolean isWithinDeclaredStreamableConstruct()- Overrides:
isWithinDeclaredStreamableConstruct
in classStyleElement
-
setContextItemRequirements
Set the required context item type. Used when there is an xsl:context-item child element- Parameters:
type
- the required context item typemayBeOmitted
- true if the context item may be absentabsentFocus
- true if use=absent is specified
-
isPermittedChild
Specify that xsl:param and xsl:context-item are permitted children- Overrides:
isPermittedChild
in classStyleElement
- Parameters:
child
- the child that may or may not be permitted- Returns:
- true if the child is permitted.
-
getTemplateName
Return the name of this template. Note that this may be called before prepareAttributes has been called.- Returns:
- the name of the template as a Structured QName.
-
getSymbolicName
Description copied from interface:StylesheetComponent
Get the symbolic name of the component, that is, the combination of the component kind and the qualified name- Specified by:
getSymbolicName
in interfaceStylesheetComponent
- Returns:
- the component's symbolic name
-
getRequiredContextItemType
-
isMayOmitContextItem
public boolean isMayOmitContextItem() -
checkCompatibility
Description copied from interface:StylesheetComponent
Check the compatibility of this component with another component that it is overriding- Specified by:
checkCompatibility
in interfaceStylesheetComponent
- Parameters:
component
- the overridden component
-
getParam
-
prepareAttributes
protected void prepareAttributes()Description copied from class:StyleElement
Set the attribute list for the element. This is called to process the attributes (note the distinction from processAttributes in the superclass). Must be supplied in a subclass- Specified by:
prepareAttributes
in classStyleElement
-
processAllAttributes
Description copied from class:StyleElement
Process the attributes of this element and all its children- Overrides:
processAllAttributes
in classStyleElement
- Throws:
XPathException
- in the event of a static error being detected
-
getModeNames
Return the list of mode names to which this template rule is applicable.- Returns:
- the list of mode names. If the mode attribute is absent, #default is assumed.
If #default is present explicitly or implicitly, it is replaced by the default mode, taken
from the in-scope default-modes attribute, which defaults to #unnamed. The unnamed mode
is represented by
Mode.UNNAMED_MODE_NAME
. The token #all translates toMode.OMNI_MODE_NAME
. - Throws:
XPathException
- if the attribute is invalid.
-
getApplicableModes
Get the modes to which this template rule applies- Returns:
- the set of modes to which it applies
- Throws:
XPathException
- should not happen
-
appliesToAllModes
Ask whether this is a template rule with mode="#all"- Returns:
- true if this is the case
- Throws:
XPathException
- if the mode attribute is found to be invalid
-
validate
Description copied from class:StyleElement
Check that the stylesheet element is valid. This is called once for each element, after the entire tree has been built. As well as validation, it can perform first-time initialisation. The default implementation does nothing; it is normally overriden in subclasses.- Overrides:
validate
in classStyleElement
- Parameters:
decl
- the declaration to be validated- Throws:
XPathException
- if any error is found during validation
-
validateSubtree
public void validateSubtree(ComponentDeclaration decl, boolean excludeStylesheet) throws XPathException Description copied from class:StyleElement
Recursive walk through the stylesheet to validate all nodes- Overrides:
validateSubtree
in classStyleElement
- Parameters:
decl
- the declaration to be validatedexcludeStylesheet
- true if the XSLStylesheet element is to be excluded- Throws:
XPathException
- if validation fails
-
index
If this is a named template, then add it to the stylesheet-level component index- Overrides:
index
in classStyleElement
- Parameters:
decl
- the Declaration being indexed. (This corresponds to the StyleElement object except in cases where one module is imported several times with different precedence.)top
- represents the outermost XSLStylesheet or XSLPackage element
-
markTailCalls
protected boolean markTailCalls()Mark tail-recursive calls on templates and functions.- Overrides:
markTailCalls
in classStyleElement
- Returns:
- true if one or more tail calls were identified
-
compileDeclaration
public void compileDeclaration(Compilation compilation, ComponentDeclaration decl) throws XPathException Compile: creates the executable form of the template- Overrides:
compileDeclaration
in classStyleElement
- Parameters:
compilation
- the compilation episodedecl
- the containing top-level declaration, for example xsl:function or xsl:template- Throws:
XPathException
- if compilation fails
-
compileTemplateRule
-
jitCompile
Code executed when the template is first executed under JIT. If the template is defined in several modes, then this may be called several times, but it only does anything the first time. Mode-specific processing is done in the TemplateRuleInitializer.- Parameters:
compilation
- the compilation episodedecl
- the template rule declaration- Throws:
XPathException
- if anything goes wrong
-
register
Registers the template rule with each Mode that it belongs to.- Parameters:
declaration
- Associates this template with a stylesheet module (in principle an xsl:template element can be in a document that is imported more than once; these are separate declarations)- Throws:
XPathException
- if a failure occurs
-
allocatePatternSlotNumbers
public void allocatePatternSlotNumbers()Allocate slot numbers to any local variables declared within a predicate within the match pattern -
optimize
This method is a bit of a misnomer, because it does more than invoke optimization of the template body. In particular, it also registers the template rule with each Mode that it belongs to.- Specified by:
optimize
in interfaceStylesheetComponent
- Parameters:
declaration
- Associates this template with a stylesheet module (in principle an xsl:template element can be in a document that is imported more than once; these are separate declarations)- Throws:
XPathException
- if errors are found
-
getContextItemTypeForTemplateRule
- Throws:
XPathException
-
getSlotManager
Get associated Procedure (for details of stack frame)- Specified by:
getSlotManager
in interfaceStylesheetComponent
- Returns:
- the associated SlotManager object
-
getCompiledNamedTemplate
Get the compiled template- Returns:
- the compiled template
-
getMatch
-