net.sf.saxon.instruct

Class Template

public class Template extends Procedure implements RuleTarget

An xsl:template element in the style sheet.
Constructor Summary
Template()
Create a template
Method Summary
voidapply(XPathContextMajor context)
Process the template, without returning any tail calls.
TailCallapplyLeavingTail(XPathContextMajor 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.
TailCallexpand(XPathContext context)
Expand the template.
voidexplain(ExpressionPresenter presenter)
Output diagnostic explanation to an ExpressionPresenter
intgetConstructType()
Get the type of construct.
LocalParamgetLocalParam(int id)
Get the local parameter with a given parameter id
PatterngetMatchPattern()
Get the match pattern used with this template
intgetMinImportPrecedence()
Get the minimum import precedence used by xsl:apply-imports
StructuredQNamegetObjectName()
Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.
intgetPrecedence()
Get the import precedence of the template
SequenceTypegetRequiredType()
Get the required type to be returned by this template
StructuredQNamegetTemplateName()
Get the name of the template (if it is named)
booleanhasRequiredParams()
Ask whether this template has one or more required parameters
voidinit(StructuredQName templateName, int precedence, int minImportPrecedence)
Initialize the template
booleanisStreamable()
Ask whether or not this template is declared as streamable
voidsetBody(Expression body)
Set the expression that forms the body of the template
voidsetHasRequiredParams(boolean has)
Set whether this template has one or more required parameters
voidsetMatchPattern(Pattern pattern)
Set the match pattern used with this template
voidsetRequiredType(SequenceType type)
Set the required type to be returned by this template
voidsetStreamable(boolean streamable)
Say whether or not this template is declared as streamable

Constructor Detail

Template

public Template()
Create a template

Method Detail

apply

public void apply(XPathContextMajor context)
Process the template, without returning any tail calls. This path is used by xsl:apply-imports and xsl:next-match

Parameters: context The dynamic context, giving access to the current node,

applyLeavingTail

public TailCall applyLeavingTail(XPathContextMajor 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.

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

expand

public TailCall expand(XPathContext context)
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

explain

public void explain(ExpressionPresenter presenter)
Output diagnostic explanation to an ExpressionPresenter

getConstructType

public int getConstructType()
Get the type of construct. This will either be the fingerprint of a standard XSLT instruction name (values in StandardNames: all less than 1024) or it will be a constant in class Location.

getLocalParam

public LocalParam getLocalParam(int 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

getMatchPattern

public Pattern getMatchPattern()
Get the match pattern used with this template

Returns: the match pattern, or null if this is a named template with no match pattern

getMinImportPrecedence

public int getMinImportPrecedence()
Get the minimum import precedence used by xsl:apply-imports

Returns: the minimum import precedence of templates that are candidates for calling by apply-imports

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.

getPrecedence

public int getPrecedence()
Get the import precedence of the template

Returns: the import precedence (a higher number means a higher precedence)

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

getTemplateName

public StructuredQName getTemplateName()
Get the name of the template (if it is named)

Returns: the template name, or null if unnamed

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

init

public void init(StructuredQName templateName, int precedence, int minImportPrecedence)
Initialize the template

Parameters: templateName the name of the template (if any) precedence the import precedence minImportPrecedence the minimum import precedence to be considered in the search performed by apply-imports

isStreamable

public boolean isStreamable()
Ask whether or not this template is declared as streamable

Returns: true if the template belongs to a streamable mode

setBody

public void setBody(Expression body)
Set the expression that forms the body of the template

Parameters: body the body of the template

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

setMatchPattern

public void setMatchPattern(Pattern pattern)
Set the match pattern used with this template

Parameters: pattern the match pattern (may be null for a named template)

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

setStreamable

public void setStreamable(boolean streamable)
Say whether or not this template is declared as streamable

Parameters: streamable true if the template belongs to a streamable mode