org.apache.ws.jaxme.xs

Class XPathMatcher


public final class XPathMatcher
extends java.lang.Object

An XPath matcher. Implements the restricted subset of XPath as defined by the XML Schema.
Author:
Chris Kirk

Method Summary

XSElementOrAttrRef[]
match(XSElement startingNode)
Return the elements and attributes matched by this xpath when applied from the specified starting node.
void
match(XSElement startingNode, Set matches)
Return the elements and attributes matched by this xpath when applied from the specified starting node.
static XSElementOrAttrRef[][]
match(XsTKeybase keybase, XSElement startingNode)
Matches every element and attribute referenced by the specified keybase.
static XPathMatcher
parse(Locator locator, String xpath, boolean elementsOnly)
Create an XPathMatcher.

Method Details

match

public XSElementOrAttrRef[] match(XSElement startingNode)
            throws SAXException
Return the elements and attributes matched by this xpath when applied from the specified starting node.

match

public void match(XSElement startingNode,
                  Set matches)
            throws SAXException
Return the elements and attributes matched by this xpath when applied from the specified starting node.

match

public static XSElementOrAttrRef[][] match(XsTKeybase keybase,
                                           XSElement startingNode)
            throws SAXException
Matches every element and attribute referenced by the specified keybase.

The result is a two dimensional array, the first dimension corresponds to each xs:field used to declare the constraint. The second dimension is for each 'or' used within the fields xpath query.

Only tags and attributes that were matched by the xpath will be in the result, any xpath that fails to match anything will not be stored in this array.


parse

public static XPathMatcher parse(Locator locator,
                                 String xpath,
                                 boolean elementsOnly)
            throws SAXException
Create an XPathMatcher. Parses a string holding a restricted subset of XPath and returns an object that knows how to walk XSElement objects based on that XPath.
Parameters:
elementsOnly - True if the xpath is not allowed to match attributes.