Contents

The complete XPath specification can be found at: http://www.w3.org/TR/xpath
Below are three examples of XML files and associated XPath strings that are found within the XML files. For each XML file there is an example message selector. After each sample message selector are the strings that need to be returned by the single pass parser. Following each string is the value that is returned by the single pass parser, given the value of the particular XPath string is found to be advantageous. If the value of the XPATH string is found matching in the parsed XML, then the message is selected.

Elements Only XML

Example 1 for Elements Only XML

An example of a related XPath predicate:
/Stock quotes/AskPrice > 33.2 and /Stock quotes/Symbol = 'csco'

Description: Generate the XML if AskPrice is greater than 33.2 and Symbol is 'csco'. This is an example of using equality and inequality check."

Example 2 for Elements Only XML

An example of a related XPath predicate:
/Stock quotes/AskPrice > 33.2 and /Stock quotes/Symbol LIKE 'csc%'

Description: Generate the XML if AskPrice is greater than 33.2 and Symbol starts with 'csc'.

An example of using Ineq and LIKE trees:

XPath parser will return:

Values returned for each XPath string:

Attributes Only

An example of a related XPath predicate:
/Stock quotes/Quote[@Symbol='csco'] NOT NULL and /Stock quotes/Quote[@AskPrice] > 33.2

Description: Generate the XML if it contains a Quote Element with attribute Symbol set to 'csco' and an AskPrice attribute > 33.2. An example of using Ineq and NULL trees is given below. This example demonstrates the use of checking attribute values inside the XPath query.

XPath parser will return:

/Stock quotes/Quote[@Symbol]
/Stock quotes/Quote[@AskPrice]
/Stock quotes/Quote[@BidPrice]
/Stock quotes/Quote[@Symbol]
/Stock quotes/Quote[@AskPrice]
/Stock quotes/Quote[@BidPrice]

Values returned for each XPath string:

/Stock quotes/Quote[@Symbol]
'csco
/Stock quotes/Quote[@AskPrice]
'33.50'
/Stock quotes/Quote[@BidPrice]
'33.25'
/Stock quotes/Quote[@Symbol]
'ibm'
/Stock quotes/Quote[@AskPrice]
'122.50'
/Stock quotes/Quote[@BidPrice]
'122.25'

Elements and Attributes XML

<Quotes>
 <QuoteType Type='Quote of the Day'>

'This is the funny quote of the day for April 2, 2001 [Close quotation? Syntax check please]

An example of a related XPath predicate: 

/Quotes/QuoteType[@Type='StockQuote']/Symbol = 'csco'
and
/Quotes/QuoteType[@Type='StockQuote']/AskPrice > 33.2

Description: Generate the XML if it contains QuoteType element with attribute Type = 'StockQuote' and elements = 'csco' and > 33.2. The following example uses Eq and Ineq trees:
XPath parser will return:

Values returned for each XPath String are given below:

Adaptavist ThemeBuilder EngineAtlassian Confluence