Finding the First Node That Meets a Condition

Suppose you want to obtain from a collection the first node that meets a certain condition. For example, you want the first book whose author's last name is Bob. You can specify the following query:

(//book[author/last-name="Bob"])[position()=1]
               

            

When the XPath processor evaluates this expression, it creates a collection of book elements where the author's last name is Bob. The XPath processor then returns the first node in this collection.

The following two expressions appear to also return the first book whose author's last name is Bob, but they do not. Instead, these queries both return a book whose author's last name is Bob only if that book is the first book in the document.

//book[author/first-name="Bob"][position()=1]
               
//book[author/first-name="Bob" and position() = 1]
               

            

XML Schema Mapping

Stylus Studio includes a visual XML Schema-to-XML Schema mapping tool that allows you to easily implement sophisticated XML data mappings involving multiple data sources and customized data processing using either XSLT or XQuery code.

Television

Television

Apache FOP

Apache FOP is an open-source engine is available from the Apache project that renders XSL-FO into PDF and other popular document formats. Apache FOP is fully integrated with Stylus Studio's XSL:FO tools.

Create XML Schema from XML Content

Create XML Schema from XML Content by auto-generating an XML Schema with Stylus Studio.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member