Package net.sf.saxon.expr.instruct
Class NamedTemplate
java.lang.Object
net.sf.saxon.expr.instruct.Actor
net.sf.saxon.expr.instruct.NamedTemplate
- All Implemented Interfaces:
SourceLocator,ExpressionOwner,Location,InstructionInfo,Locator
The runtime object corresponding to a named xsl:template element in the stylesheet.
Note that the Template object no longer has precedence information associated with it; this is now only in the Rule object that references this Template. This allows two rules to share the same template, with different precedences. This occurs when a stylesheet module is imported more than once, from different places, with different import precedences.
From Saxon 9.7, the NamedTemplate and TemplateRule objects are separated. A NamedTemplate represents a template with a name attribute; a TemplateRule is a template with a match attribute. If an xsl:template declaration has both attributes, two objects are created.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexpand(XPathContext context) Expand the template.voidexplainProperties(ExpressionPresenter presenter) voidexport(ExpressionPresenter presenter) Output diagnostic explanation to an ExpressionPresenterintGet the kind of component that this represents, using integer constants such asStandardNames.XSL_FUNCTIONintGet the type of construct.Get the local parameter with a given parameter idGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.Get the required type to be returned by this templateGet the symbolic name of the componentGet the name of the template (if it is named)booleanAsk whether this template has one or more required parametersbooleanbooleanvoidsetBody(Expression body) Set the expression that forms the body of the templatevoidsetContextItemRequirements(ItemType type, boolean mayBeOmitted, boolean absentFocus) Set the required context item type.voidsetHasRequiredParams(boolean has) Set whether this template has one or more required parametersvoidvoidsetRequiredType(SequenceType type) Set the required type to be returned by this templatevoidsetTemplateName(StructuredQName templateName) Initialize the templateMethods inherited from class net.sf.saxon.expr.instruct.Actor
allocateAllBindingSlots, allocateBindingSlotsRecursive, getBody, getColumnNumber, getDeclaredVisibility, getDeclaringComponent, getLineNumber, getLocation, getPackageData, getProperties, getProperty, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, isExportable, makeDeclaringComponent, obtainDeclaringComponent, saveLocation, setChildExpression, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId
-
Constructor Details
-
NamedTemplate
Create a named template
-
-
Method Details
-
setTemplateName
Initialize the template- Parameters:
templateName- the name of the template (if any) performed by apply-imports
-
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 the context item is treated as absent even if supplied (use=absent)
-
getComponentKind
public int getComponentKind()Description copied from class:ActorGet the kind of component that this represents, using integer constants such asStandardNames.XSL_FUNCTION- Specified by:
getComponentKindin classActor
-
getSymbolicName
Description copied from class:ActorGet the symbolic name of the component- Specified by:
getSymbolicNamein classActor- Returns:
- the symbolic name
-
setBody
Set the expression that forms the body of the template -
getTemplateName
Get the name of the template (if it is named)- Returns:
- the template name, or null if unnamed
-
getObjectName
Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
setHasRequiredParams
public void setHasRequiredParams(boolean has) Set whether this template has one or more required parameters- Parameters:
has- true if the template has at least one required parameter
-
hasRequiredParams
public boolean hasRequiredParams()Ask whether this template has one or more required parameters- Returns:
- true if this template has at least one required parameter
-
setRequiredType
Set the required type to be returned by this template- Parameters:
type- the required type as defined in the "as" attribute on the xsl:template element
-
getRequiredType
Get the required type to be returned by this template- Returns:
- the required type as defined in the "as" attribute on the xsl:template element
-
getRequiredContextItemType
-
isMayOmitContextItem
public boolean isMayOmitContextItem() -
isAbsentFocus
public boolean isAbsentFocus() -
getLocalParamInfo
Get the local parameter with a given parameter id- Parameters:
id- the parameter id- Returns:
- the local parameter with this id if found, otherwise null
-
expand
Expand the template. Called when the template is invoked using xsl:call-template. Invoking a template by this method does not change the current template.- Parameters:
context- the XPath dynamic context- Returns:
- null if the template exited normally; but if it was a tail call, details of the call that hasn't been made yet and needs to be made by the caller
- Throws:
XPathException- if a dynamic error occurs while evaluating the template
-
getConstructType
public int getConstructType()Get the type of construct. This will either be the fingerprint of a standard XSLT instruction name (values inStandardNames: all less than 1024) or it will be a constant in classLocationKind.- Returns:
- an integer identifying the kind of construct
-
export
Output diagnostic explanation to an ExpressionPresenter- Specified by:
exportin classActor- Parameters:
presenter- the expression presenter used to generate the XML representation of the structure- Throws:
XPathException
-
explainProperties
- Throws:
XPathException
-
setLocalParamDetails
-
getLocalParamDetails
-