public class TemplateRule extends Object implements RuleTarget, Location
From Saxon 9.7, the old Template class is split into NamedTemplate and TemplateRule.
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.
|
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() |
TemplateInversion |
getInversion() |
int |
getLineNumber()
Get the line number.
|
LocalParam |
getLocalParam(StructuredQName id)
Get the local parameter with a given parameter id
|
List<LocalParam> |
getLocalParams() |
Pattern |
getMatchPattern()
Get the match pattern used with this template
|
PackageData |
getPackageData() |
String |
getPublicId()
Get the Public ID
|
ItemType |
getRequiredContextItemType() |
SequenceType |
getRequiredType()
Get the required type to be returned by this template
|
List<Rule> |
getRules()
Get the rules that use this template.
|
SlotManager |
getStackFrameMap() |
String |
getSystemId()
Get the system ID.
|
boolean |
hasRequiredParams()
Ask whether this template has one or more required parameters
|
boolean |
isActuallyStreamable(boolean allowExtensions,
List<String> reasons)
Ask whether this template satisfies the rules for a guaranteed streamable template
|
boolean |
isDeclaredStreamable()
Ask whether or not this template is declared as streamable
|
boolean |
isMayOmitContextItem() |
boolean |
isMaySupplyContextItem() |
void |
makeInversion()
Generate the inversion of the expression comprising the body of a template rules.
|
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 |
setContextItemRequirements(ItemType type,
boolean mayBeOmitted,
boolean mayBeSupplied)
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(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).
|
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 mayBeOmitted, boolean mayBeSupplied)
type
- the required context item typemayBeOmitted
- true if the context item may be absentmayBeSupplied
- true if the context item may be suppliedpublic 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 List<Rule> getRules()
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 int getContainerGranularity()
public PackageData getPackageData()
public void setPackageData(PackageData data)
public String getPublicId()
Location
getPublicId
in interface SourceLocator
getPublicId
in interface Location
getPublicId
in interface Locator
public 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 SourceLocator
getSystemId
in interface Location
getSystemId
in interface Locator
public void setSystemId(String id)
public int getLineNumber()
Location
getLineNumber
in interface SourceLocator
getLineNumber
in interface Location
getLineNumber
in interface Locator
public void setLineNumber(int line)
public int getColumnNumber()
Location
getColumnNumber
in interface SourceLocator
getColumnNumber
in interface Location
getColumnNumber
in interface Locator
public Location saveLocation()
saveLocation
in interface Location
public ItemType getRequiredContextItemType()
public boolean isMayOmitContextItem()
public boolean isMaySupplyContextItem()
public List<LocalParam> getLocalParams()
public LocalParam getLocalParam(StructuredQName id)
id
- the parameter idpublic 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
.public void export(ExpressionPresenter presenter)
export
in interface RuleTarget
presenter
- the destination for the explanationpublic void explainProperties(ExpressionPresenter presenter)
public Expression getInterpretedBody()
public TemplateRule copy()
public void updateSlaveCopies()
public boolean isActuallyStreamable(boolean allowExtensions, List<String> reasons)
allowExtensions
- if true, the method tests for streamability against the Saxon
rules rather than the W3C rulesreasons
- the caller may supply a list which on return will contain explanations
for why the template is not streamable, suitable for inclusion in error messagespublic void makeInversion() throws XPathException
XPathException
public TemplateInversion getInversion()
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.