com.novell.xsl.pattern
Interface Pattern

All Known Implementing Classes:
AbsolutePathPattern, IdKeyPattern, NodeTestPattern, OrPattern, RelativePathPattern, StepPattern

public interface Pattern

Interface describing XSLT Pattern behavior.


Field Summary
static int ANY_TARGET
          When returned from getTarget(), indicates this Pattern matches any node type.
static int ATTRIBUTE_NAMED_TARGET
          When returned from getTarget(), indicates this Pattern matches attributes with a specific name.
static int ATTRIBUTE_WILDCARD_TARGET
          When returned from getTarget(), indicates this Pattern matches attributes with any name (this includes the forms NCName:*, *:NCName, and *).
static int COMMENT_TARGET
          When returned from getTarget(), indicates this Pattern matches comment nodes.
static int ELEMENT_NAMED_TARGET
          When returned from getTarget(), indicates this Pattern matches elements with a specific name.
static int ELEMENT_WILDCARD_TARGET
          When returned from getTarget(), indicates this Pattern matches elements with any name (this includes the forms NCName:*, *:NCName, and *).
static int NAMESPACE_TARGET
          When returned from getTarget(), indicates this Pattern matches namespace nodes.
static int PI_TARGET
          When returned from getTarget(), indicates this Pattern matches processing-instruction nodes.
static int ROOT_TARGET
          When returned from getTarget(), indicates this Pattern matches the root node.
static int TEXT_TARGET
          When returned from getTarget(), indicates this Pattern matches text nodes.
 
Method Summary
 void dump(PrintWriter writer, int indent)
          Print the pattern in a readable form for debugging.
 double getDefaultPriority()
          Return the default priority for this pattern.
 int getTarget()
          Return the target type of this Pattern.
 ExpandedQName getTargetName()
          Return the name of the patterns target, if there is a target name.
 boolean match(Node node, ExpressionContext context)
          Return true or false depending on whether the passed node matches the XSLT Pattern or not.
 

Field Detail

ROOT_TARGET

public static final int ROOT_TARGET
When returned from getTarget(), indicates this Pattern matches the root node.

See Also:
Constant Field Values

ELEMENT_NAMED_TARGET

public static final int ELEMENT_NAMED_TARGET
When returned from getTarget(), indicates this Pattern matches elements with a specific name. This corresponds to a NodeTest of the form 'QName'

See Also:
Constant Field Values

ELEMENT_WILDCARD_TARGET

public static final int ELEMENT_WILDCARD_TARGET
When returned from getTarget(), indicates this Pattern matches elements with any name (this includes the forms NCName:*, *:NCName, and *).

See Also:
Constant Field Values

ATTRIBUTE_NAMED_TARGET

public static final int ATTRIBUTE_NAMED_TARGET
When returned from getTarget(), indicates this Pattern matches attributes with a specific name. This corresponds to a NodeTest of the form 'QName'

See Also:
Constant Field Values

ATTRIBUTE_WILDCARD_TARGET

public static final int ATTRIBUTE_WILDCARD_TARGET
When returned from getTarget(), indicates this Pattern matches attributes with any name (this includes the forms NCName:*, *:NCName, and *).

See Also:
Constant Field Values

COMMENT_TARGET

public static final int COMMENT_TARGET
When returned from getTarget(), indicates this Pattern matches comment nodes. This corresponds to a NodeTest of the form 'comment()'

See Also:
Constant Field Values

PI_TARGET

public static final int PI_TARGET
When returned from getTarget(), indicates this Pattern matches processing-instruction nodes. This corresponds to a NodeTest of the form 'processing-instruction()' or 'processing-instruction(Literal)'

See Also:
Constant Field Values

TEXT_TARGET

public static final int TEXT_TARGET
When returned from getTarget(), indicates this Pattern matches text nodes. This corresponds to a NodeTest of the form 'text()'

See Also:
Constant Field Values

NAMESPACE_TARGET

public static final int NAMESPACE_TARGET
When returned from getTarget(), indicates this Pattern matches namespace nodes. This is not currently returned because namespace nodes cannot be explicitly matched.

See Also:
Constant Field Values

ANY_TARGET

public static final int ANY_TARGET
When returned from getTarget(), indicates this Pattern matches any node type. This corresponds to a NodeTest of the form 'node()'

See Also:
Constant Field Values
Method Detail

match

public boolean match(Node node,
                     ExpressionContext context)
              throws XPathEvaluationException
Return true or false depending on whether the passed node matches the XSLT Pattern or not. The passed ExpressionContext is necessary for evaluation of XPath Predicate expressions, which may be part of a Pattern, as well as for namespace resolution.

Parameters:
node - The node to match.
context - The context for matching.
Returns:
True if the node matches the pattern, false otherwise.
Throws:
XPathEvaluationException

getDefaultPriority

public double getDefaultPriority()
Return the default priority for this pattern. See XSLT spec for information on default priority calculation.

Returns:
-0.5, 0.0, or 0.5

getTarget

public int getTarget()
Return the target type of this Pattern. This is one of the values defined in the Pattern interface (ELEMENT_NAMED_TARGET, ELEMENT_WILDCARD_TARGET, etc.)

Returns:
The target type value for this Pattern.

getTargetName

public ExpandedQName getTargetName()
Return the name of the patterns target, if there is a target name. This may return null if there is no target name for this pattern (text(), node(), etc.). However, if getTarget() returns ELEMENT_NAMED_TARGET or ATTRIBUTE_NAMED_TARGET this will never return null.

Returns:
The target name or null.

dump

public void dump(PrintWriter writer,
                 int indent)
Print the pattern in a readable form for debugging.

Parameters:
writer - The output device.
indent - Number of tabs to indent the result.