public class TemplateRule extends java.lang.Object implements RuleTarget, Location, ExpressionOwner, InstructionInfo
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 old Template class is split into NamedTemplate and TemplateRule.
From Saxon 9.8, a subclass is used in Saxon-EE
Modifier and Type | Field and Description |
---|---|
protected Expression |
body |
protected Pattern |
matchPattern |
protected java.util.List<TemplateRule> |
slaveCopies |
Constructor and Description |
---|
TemplateRule()
Create a template
|
Modifier and Type | Method and Description |
---|---|
void |
apply(XPathContextMajor context)
Process the template, without returning any tail calls.
|
TailCall |
applyLeavingTail(XPathContext context)
Process this template, with the possibility of returning a tail call package if the template
contains any tail calls that are to be performed by the caller.
|
TemplateRule |
copy()
Create a copy of a template rule.
|
protected void |
copyTo(TemplateRule tr) |
void |
explainProperties(ExpressionPresenter presenter) |
void |
export(ExpressionPresenter presenter)
Output diagnostic explanation to an ExpressionPresenter
|
Expression |
getBody() |
int |
getColumnNumber()
Get the column number.
|
int |
getComponentKind() |
int |
getConstructType()
Get the type of construct.
|
int |
getContainerGranularity() |
Expression |
getInterpretedBody() |
int |
getLineNumber()
Get the line number.
|
java.util.List<LocalParam> |
getLocalParams() |
Pattern |
getMatchPattern()
Get the match pattern used with this template
|
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.
|
PackageData |
getPackageData() |
java.util.Iterator<java.lang.String> |
getProperties()
Get an iterator over all the properties available.
|
java.lang.Object |
getProperty(java.lang.String name)
Get the value of a particular property of the instruction.
|
java.lang.String |
getPublicId()
Get the Public ID
|
ItemType |
getRequiredContextItemType() |
SequenceType |
getRequiredType()
Get the required type to be returned by this template
|
java.util.List<Rule> |
getRules()
Get the rules that use this template.
|
SlotManager |
getStackFrameMap() |
java.lang.String |
getSystemId()
Get the system ID.
|
boolean |
hasRequiredParams()
Ask whether this template has one or more required parameters
|
void |
initialize()
Ensure that any first-time initialization has been done.
|
boolean |
isAbsentFocus() |
boolean |
isDeclaredStreamable() |
void |
prepareInitializer(Compilation compilation,
ComponentDeclaration decl,
StructuredQName modeName)
Prepare for JIT compilation.
|
void |
registerRule(Rule rule)
Register a rule for which this is the target
|
Location |
saveLocation()
Get an immutable copy of this Location object.
|
void |
setBody(Expression body)
Set the expression that forms the body of the template
|
void |
setChildExpression(Expression expr) |
void |
setContextItemRequirements(ItemType type,
boolean absentFocus)
Set the required context item type.
|
void |
setDeclaredStreamable(boolean streamable)
Say whether or not this template is declared as streamable
|
void |
setHasRequiredParams(boolean has)
Set whether this template has one or more required parameters
|
void |
setLineNumber(int line) |
void |
setMatchPattern(Pattern pattern)
Set the match pattern used with this template
|
void |
setPackageData(PackageData data) |
void |
setRequiredType(SequenceType type)
Set the required type to be returned by this template
|
void |
setStackFrameMap(SlotManager map) |
void |
setSystemId(java.lang.String id) |
void |
updateSlaveCopies()
Update the properties of template rules that have been marked as slave copies of this one (typically the same
template, but in a different mode).
|
protected Expression body
protected Pattern matchPattern
protected java.util.List<TemplateRule> slaveCopies
public void setMatchPattern(Pattern pattern)
pattern
- the match pattern (may be null for a named template)public Expression getBody()
public void setContextItemRequirements(ItemType type, boolean absentFocus)
type
- the required context item typeabsentFocus
- true if the context item is treated as absent even if supplied (use="absent")public int getComponentKind()
public Pattern getMatchPattern()
public void setBody(Expression body)
body
- the body of the templatepublic void setStackFrameMap(SlotManager map)
public SlotManager getStackFrameMap()
public void setHasRequiredParams(boolean has)
has
- true if the template has at least one required parameterpublic boolean hasRequiredParams()
public void setRequiredType(SequenceType type)
type
- the required type as defined in the "as" attribute on the xsl:template elementpublic SequenceType getRequiredType()
public void registerRule(Rule rule)
registerRule
in interface RuleTarget
rule
- a rule in which this is the targetpublic java.util.List<Rule> getRules()
public int getContainerGranularity()
public PackageData getPackageData()
public void setPackageData(PackageData data)
public java.lang.String getPublicId()
Location
getPublicId
in interface javax.xml.transform.SourceLocator
getPublicId
in interface Location
getPublicId
in interface org.xml.sax.Locator
public java.lang.String getSystemId()
Location
The system identifier of a node is in general not the same as its base URI. The base URI is affected by xml:base attributes; the system identifier is not.
getSystemId
in interface javax.xml.transform.SourceLocator
getSystemId
in interface Location
getSystemId
in interface org.xml.sax.Locator
public void setSystemId(java.lang.String id)
public int getLineNumber()
Location
getLineNumber
in interface javax.xml.transform.SourceLocator
getLineNumber
in interface Location
getLineNumber
in interface org.xml.sax.Locator
public void setLineNumber(int line)
public int getColumnNumber()
Location
getColumnNumber
in interface javax.xml.transform.SourceLocator
getColumnNumber
in interface Location
getColumnNumber
in interface org.xml.sax.Locator
public Location saveLocation()
saveLocation
in interface Location
public ItemType getRequiredContextItemType()
public boolean isAbsentFocus()
public java.util.List<LocalParam> getLocalParams()
public void prepareInitializer(Compilation compilation, ComponentDeclaration decl, StructuredQName modeName)
compilation
- the XSLT compilationdecl
- the component declaration of this template rulepublic void initialize() throws XPathException
XPathException
public void apply(XPathContextMajor context) throws XPathException
context
- The dynamic context, giving access to the current node,XPathException
- if a dynamic error occurs while evaluating
the templatepublic TailCall applyLeavingTail(XPathContext context) throws XPathException
context
- the XPath dynamic contextXPathException
- if a dynamic error occurs while evaluating
the templatepublic int getConstructType()
StandardNames
: all less than 1024)
or it will be a constant in class LocationKind
.getConstructType
in interface InstructionInfo
public void export(ExpressionPresenter presenter) throws XPathException
export
in interface RuleTarget
presenter
- the destination for the explanationXPathException
public void setDeclaredStreamable(boolean streamable)
streamable
- true if the template belongs to a streamable mode; set to false if it does not belong
to a streamable mode, or if it is found that the template is not actually streamable, and fallback
to non-streaming has been requested.public boolean isDeclaredStreamable()
public void explainProperties(ExpressionPresenter presenter) throws XPathException
XPathException
public Expression getInterpretedBody()
public TemplateRule copy()
public void updateSlaveCopies()
protected void copyTo(TemplateRule tr)
public void setChildExpression(Expression expr)
setChildExpression
in interface ExpressionOwner
public StructuredQName getObjectName()
InstructionInfo
getObjectName
in interface InstructionInfo
public java.lang.Object getProperty(java.lang.String name)
InstructionInfo
getProperty
in interface InstructionInfo
name
- The name of the required propertypublic java.util.Iterator<java.lang.String> getProperties()
InstructionInfo
getProperties
in interface InstructionInfo
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.