Package net.sf.saxon.instruct
Class Template
java.lang.Object
net.sf.saxon.instruct.Procedure
net.sf.saxon.instruct.Template
- All Implemented Interfaces:
Serializable
,SourceLocator
,LocationProvider
,SaxonLocator
,Container
,InstructionInfo
,Locator
An xsl:template element in the style sheet.
- See Also:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(XPathContext context, Rule rule) Process the template, without returning any tail calls.applyLeavingTail
(XPathContext context, Rule rule) 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.expand
(XPathContext context) Expand the template.int
Get the type of construct.Get the match pattern used with this templateint
Get the minimum import precedence used by xsl:apply-importsGet a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.int
Get the import precedence of the templateGet the required type to be returned by this templateGet the name of the template (if it is named)boolean
Ask whether this template has one or more required parametersvoid
init
(StructuredQName templateName, int precedence, int minImportPrecedence) Initialize the templatevoid
setBody
(Expression body) Set the expression that forms the body of the templatevoid
setHasRequiredParams
(boolean has) Set whether this template has one or more required parametersvoid
setMatchPattern
(Pattern pattern) Set the match pattern used with this templatevoid
setRequiredType
(SequenceType type) Set the required type to be returned by this templateMethods inherited from class net.sf.saxon.instruct.Procedure
getBody, getColumnNumber, getColumnNumber, getExecutable, getHostLanguage, getLineNumber, getLineNumber, getLocationProvider, getProperties, getProperty, getPublicId, getStackFrameMap, getSystemId, getSystemId, replaceSubExpression, setExecutable, setHostLanguage, setLineNumber, setStackFrameMap, setSystemId
-
Constructor Details
-
Template
public Template()Create a template
-
-
Method Details
-
init
Initialize the template- Parameters:
templateName
- the name of the template (if any)precedence
- the import precedenceminImportPrecedence
- the minimum import precedence to be considered in the search performed by apply-imports
-
setMatchPattern
Set the match pattern used with this template- Parameters:
pattern
- the match pattern (may be null for a named template)
-
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
-
setBody
Set the expression that forms 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.- Returns:
- the QName of the object declared or manipulated by this instruction or expression
-
getPrecedence
public int getPrecedence()Get the import precedence of the template- Returns:
- the import precedence (a higher number means a higher precedence)
-
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
-
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
-
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
-
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
-
apply
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,rule
- the template rule that caused this template to be invoked. When a template has a match pattern defined as a union, there can be more than one Rule referring to the same template, and further calls on next-match or apply-imports need to know which one in in force- Throws:
XPathException
-
applyLeavingTail
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 contextrule
- the template rule that caused this template to be invoked. When a template has a match pattern defined as a union, there can be more than one Rule referring to the same template, and further calls on next-match or apply-imports need to know which one in in force- 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
-
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:
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
- Throws:
XPathException
-
getConstructType
public int getConstructType()Get the type of construct. This will either be the fingerprint of a standard XSLT instruction name (values inStandardNames
: all less than 1024) or it will be a constant in classLocation
.- Returns:
- an integer identifying the kind of construct
-