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:
javax.xml.transform.SourceLocator
,ExpressionOwner
,Locatable
,Location
,Traceable
,TraceableComponent
,org.xml.sax.Locator
public class NamedTemplate extends Actor implements TraceableComponent
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 Modifier and Type Class Description static class
NamedTemplate.LocalParamInfo
-
Constructor Summary
Constructors Constructor Description NamedTemplate(StructuredQName templateName, Configuration config)
Create a named template
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TailCall
expand(Outputter output, XPathContext context)
Expand the template.void
explainProperties(ExpressionPresenter presenter)
void
export(ExpressionPresenter presenter)
Output diagnostic explanation to an ExpressionPresentervoid
gatherProperties(java.util.function.BiConsumer<java.lang.String,java.lang.Object> consumer)
Get the properties of this object to be included in trace messages, by supplying the property values to a supplied consumer functionjava.util.List<NamedTemplate.LocalParamInfo>
getLocalParamDetails()
NamedTemplate.LocalParamInfo
getLocalParamInfo(StructuredQName id)
Get the local parameter with a given parameter idStructuredQName
getObjectName()
Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.ItemType
getRequiredContextItemType()
SequenceType
getRequiredType()
Get the required type to be returned by this templateSymbolicName
getSymbolicName()
Get the symbolic name of the componentStructuredQName
getTemplateName()
Get the name of the template (if it is named)java.lang.String
getTracingTag()
Get a string used to identify this kind of component when used in tracing outputboolean
isAbsentFocus()
boolean
isMayOmitContextItem()
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
setLocalParamDetails(java.util.List<NamedTemplate.LocalParamInfo> details)
void
setRequiredType(SequenceType type)
Set the required type to be returned by this templatevoid
setTemplateName(StructuredQName templateName)
Initialize the template-
Methods 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 Detail
-
NamedTemplate
public NamedTemplate(StructuredQName templateName, Configuration config)
Create a named template- Parameters:
templateName
- the name of the template (if any)
-
-
Method Detail
-
setTemplateName
public void setTemplateName(StructuredQName templateName)
Initialize the template- Parameters:
templateName
- the name of the template (if any) performed by apply-imports
-
setContextItemRequirements
public void setContextItemRequirements(ItemType type, boolean mayBeOmitted, boolean absentFocus)
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
public SymbolicName getSymbolicName()
Description copied from class:Actor
Get the symbolic name of the component- Specified by:
getSymbolicName
in classActor
- Returns:
- the symbolic name
-
getTracingTag
public java.lang.String 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
public void gatherProperties(java.util.function.BiConsumer<java.lang.String,java.lang.Object> consumer)
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
public void setBody(Expression body)
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
public StructuredQName getTemplateName()
Get the name of the template (if it is named)- Returns:
- the template name, or null if unnamed
-
getObjectName
public StructuredQName 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
public void setRequiredType(SequenceType type)
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
public SequenceType 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
public ItemType getRequiredContextItemType()
-
isMayOmitContextItem
public boolean isMayOmitContextItem()
-
isAbsentFocus
public boolean isAbsentFocus()
-
getLocalParamInfo
public NamedTemplate.LocalParamInfo getLocalParamInfo(StructuredQName id)
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
public TailCall expand(Outputter output, XPathContext context) throws XPathException
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
public void export(ExpressionPresenter presenter) throws XPathException
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
public void explainProperties(ExpressionPresenter presenter) throws XPathException
- Throws:
XPathException
-
setLocalParamDetails
public void setLocalParamDetails(java.util.List<NamedTemplate.LocalParamInfo> details)
-
getLocalParamDetails
public java.util.List<NamedTemplate.LocalParamInfo> getLocalParamDetails()
-
-