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
,Locatable
,Location
,Traceable
,TraceableComponent
,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
ConstructorsConstructorDescriptionNamedTemplate
(StructuredQName templateName, Configuration config) Create a named template -
Method Summary
Modifier and TypeMethodDescriptionexpand
(Outputter output, XPathContext context) Expand the template.void
explainProperties
(ExpressionPresenter presenter) void
export
(ExpressionPresenter presenter) Output diagnostic explanation to an ExpressionPresentervoid
gatherProperties
(BiConsumer<String, Object> consumer) Get the properties of this object to be included in trace messages, by supplying the property values to a supplied consumer functionGet 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)Get a string used to identify this kind of component when used in tracing outputboolean
boolean
void
setBody
(Expression body) Set the expression that forms the body of the templatevoid
setContextItemRequirements
(ItemType type, boolean mayBeOmitted, boolean absentFocus) Set the required context item type.void
void
setRequiredType
(SequenceType type) Set the required type to be returned by this templatevoid
setTemplateName
(StructuredQName templateName) Initialize the templateMethods inherited from class net.sf.saxon.expr.instruct.Actor
allocateAllBindingSlots, allocateBindingSlotsRecursive, getBody, getChildExpression, getColumnNumber, getComponentName, getDeclaredVisibility, getDeclaringComponent, getLineNumber, getLocation, getPackageData, getProperty, getPublicId, getRetainedStaticContext, getStackFrameMap, getSystemId, isExportable, makeDeclaringComponent, obtainDeclaringComponent, process, saveLocation, setChildExpression, setColumnNumber, setDeclaredVisibility, setDeclaringComponent, setLineNumber, setPackageData, setRetainedStaticContext, setStackFrameMap, setSystemId
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.expr.Locatable
getLocation
Methods inherited from interface net.sf.saxon.trace.TraceableComponent
getBody
-
Constructor Details
-
NamedTemplate
Create a named template- Parameters:
templateName
- the name of the template (if any)
-
-
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)
-
getSymbolicName
Description copied from class:Actor
Get the symbolic name of the component- Specified by:
getSymbolicName
in classActor
- Returns:
- the symbolic name
-
getTracingTag
Description copied from class:Actor
Get a string used to identify this kind of component when used in tracing output- Specified by:
getTracingTag
in interfaceTraceableComponent
- Overrides:
getTracingTag
in classActor
- Returns:
- a diagnostic string used to identify the component when tracing
-
gatherProperties
Get the properties of this object to be included in trace messages, by supplying the property values to a supplied consumer function- Specified by:
gatherProperties
in interfaceTraceable
- Parameters:
consumer
- the function to which the properties should be supplied, as (property name, value) pairs.
-
setBody
Set the expression that forms the body of the template- Specified by:
setBody
in interfaceTraceableComponent
- Overrides:
setBody
in classActor
- Parameters:
body
- 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.- Specified by:
getObjectName
in interfaceTraceable
- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
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:
output
- the destination for the resultcontext
- 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
-
export
Output diagnostic explanation to an ExpressionPresenter- Specified by:
export
in classActor
- Parameters:
presenter
- the expression presenter used to generate the XML representation of the structure- Throws:
XPathException
- if things go wrong, for example an I/O failure
-
explainProperties
- Throws:
XPathException
-
setLocalParamDetails
-
getLocalParamDetails
-