Positions in Relation to Parent Nodes

Positions are relative to the parent. Consider the following data, which has line numbers on the left for explanation only.

1 	<x>
               
2 		<z>
               
3 		<z/>
               
4 	</x>
               
5 	<x>
               
6 		<y>
               
7 		<y/>
               
8	</x>
               
9	<x>
               
10		<y>
               
11		<y/>
               
12	</x>
               

            

The following query returns the first y element contained in each x element. It returns the elements on lines 6 and 10. The XPath processor finds all x elements. For each x element, the XPath processor then returns the first y element it finds.

x/y[1] 
               

            

The next query returns the first y element that is contained in an x element that is in the context node set. It returns the element on line 6. The XPath processor finds all y elements inside x elements. The XPath processor then returns the first element in that set.

(x/y)[1] 
               

            

The next query returns the empty set. The XPath processor finds the first x element. It then searches that first x element for the first y. Because the first x element does not contain a y element, this query returns the empty set.

x[1]/y[1] 
               

            

XML Reports

Build beautiful XML reports from Relational, XML and Legacy Data. You XML report can be rendered in PDF or HTML using XSLT, XQuery or XSL:FO.

Using DTD in Java Applications

Learn how to validate XML documents using industry-standard DTD's from within your Java applications using Java DTD components including Apache Xerces and XSV.

ZapThink Report: Using Stylus Studio to Deploy XML Data Services

A Zapthink analyst discusses how to create the next generation of XML data services using Stylus Studio XML tools - Download the special report today for free.

Convert CSV to XML

Convert CSV to XML with a handy CSV to XML document wizard that helps you extract data from your CSV files with ease.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member