How the XPath Processor Evaluates Comparisons

A query can compare values of elements. For example:

last-name [. = "foo"] 
               

            

The XPath processor compares the value of each last-name element in the current context with the value "foo". The result of each comparison is a Boolean value. The XPath processor returns the last-name elements for which the comparison yields true.

As mentioned before in Filtering Results of Queries, the XPath processor evaluates filters with respect to a context. For example, the expression book[author] means for every book element that is found, determine whether it has an author child element. Likewise, book[author = "Bob"] means for every book element that is found, determine whether it contains an author child element whose value is "Bob".

Comparisons are case sensitive. For example, "Bob" and "bob" are not considered to be equal.

Remember that comparisons return Boolean values. For example:

/bookstore/book/author/last-name="Bob"
               

            

You might think that this query returns authors whose last name is "Bob". But this is not the case. This query returns a single Boolean value. It tests each last-name element to determine if its value is "Bob". As soon as the XPath processor finds a last-name element that tests true, it returns true. If no nodes test true, this query returns false.

To obtain author elements whose last name is "Bob", enclose the comparison in a filter as follows:

/bookstore/book/author[last-name="Bob"]
               

            

XSLT Debugger

Stylus Studio's XSLT debugger - a requirement for building bug-free XSLT stylesheets and XML data transformation applications. Stylus Studio's XSLT debugger gives you complete visibility and control over the XSLT transformation process.

EDI Mapping

To transform EDI to XML, whether for X12 or EDIFACT, Stylus Studio provides the design tools and run-time support. EDIFACT, X12 and custom EDI formats can be translated, validated and mapped using the EDI Mapping adapter technology described here.

XQuery Editor

Stylus Studio's XQuery development tools are a tremendous help in building and testing XML applications requiring a standards-based approach to querying, integrating and transforming data from various distributed data sources.

MSXML - Microsoft XML Tools

MSXML tools in Stylus Studio feature integrated XML validation, XSLT transformation and XSLT debugging using the Microsoft's COM-based XML processing components: MSXML 3.0, MSXML 4.0 and MSXML 6.0

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member