org.exolab.adaptx.xslt

Class TemplateRule

public final class TemplateRule extends XSLObject

A class that Represents an XSLT Template Rule. Section 5 of the W3C XSLT 1.0 Recommendation (19991116).

Version: $Revision: 3633 $ $Date: 2003-03-01 02:38:44 -0500 (Sat, 01 Mar 2003) $

Author: Keith Visco

Constructor Summary
TemplateRule()
Creates a new TemplateRule.
By default the new rule will not match any elements.
Method Summary
floatcalculatePriority(XPathNode node, XPathContext context)
Calculates the priority for this Template Rule.
XSLObjectcopy()
Creates a copy of this TemplateRule
LocationPathPatterngetMatchingPattern(XPathNode node, XPathContext context)
Returns the Pattern contained within this template rule that matched the given node using the given context.
StringgetMode()
Returns the mode attribute of this Template Rule
StringgetName()
Returns the name for this Template Rule, or null if no name exists.
PatterngetPattern()
Returns the match Pattern for this template
booleanmatches(XPathNode node, ProcessorState ps)
Determines if the given node is matched by this MatchExpr with respect to the given context node.
voidsetAttribute(String name, String value)
Sets the attribute with the given name to the given value.
voidsetMatchAttr(String matchPattern)
Sets the MatchExpr for this TemplateRule
voidsetModeAttr(String mode)
voidsetName(String name)
Sets the name for this Template
voidsetPriority(float priority)
Sets the priority for this TemplateRule

Constructor Detail

TemplateRule

public TemplateRule()
Creates a new TemplateRule.
By default the new rule will not match any elements.

Method Detail

calculatePriority

public float calculatePriority(XPathNode node, XPathContext context)
Calculates the priority for this Template Rule. The priority is calculated using the rules from Section 5.5 of the XSLT 1.0 Recommendation.

Returns: the priority for this Template Rule

copy

public XSLObject copy()
Creates a copy of this TemplateRule

Returns: the new copy of this TemplateRule

getMatchingPattern

public LocationPathPattern getMatchingPattern(XPathNode node, XPathContext context)
Returns the Pattern contained within this template rule that matched the given node using the given context.

Parameters: node the XPathNode to match against context the XPathContext to match against

Returns: the matching pattern, or null if no patterns matched the given node.

getMode

public String getMode()
Returns the mode attribute of this Template Rule

Returns: the value of the mode attribute.

getName

public String getName()
Returns the name for this Template Rule, or null if no name exists.

UNKNOWN: the name for this rule, or null if no name exists.

getPattern

public Pattern getPattern()
Returns the match Pattern for this template

Returns: the match Pattern for this template

matches

public boolean matches(XPathNode node, ProcessorState ps)
Determines if the given node is matched by this MatchExpr with respect to the given context node. Note: If there are errors in the XPath expression of this template, the errors are reported on first use of the template. The template will then be disabled and no longer used for XSLT processing.

Parameters: node the node to determine a match for context the Node which represents the current context ps the current ProcessorState

Returns: true if the given node is matched by this MatchExpr

setAttribute

public void setAttribute(String name, String value)
Sets the attribute with the given name to the given value.

Parameters: name the name of the attribute to set value the value to set the attribute to

Throws: XSLException if this XSLObject does not allow attributes with the given name, or if the attribute is read only

setMatchAttr

public void setMatchAttr(String matchPattern)
Sets the MatchExpr for this TemplateRule

Parameters: matchPattern the desired Match Pattern to use for this template

setModeAttr

public void setModeAttr(String mode)

setName

public void setName(String name)
Sets the name for this Template

Parameters: name the name to use for this template

setPriority

public void setPriority(float priority)
Sets the priority for this TemplateRule

Parameters: priority the desired priority of this rule. 0 by default