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] 
               

            

Data Integration Tools: Using the Stylus Studio XML Pipeline to Visually Integrate and Publish Data

Data Integration Tools from Stylus Studio include a visual pipeline editor, support for non-XML data sources, scalable data integration components, cross-language debugging and Java code generation. Try it now.

Oil, Gas & Electric Companies That Use Stylus Studio

Oil, gas & electric companies know a good resource when they see it. That's why they use Stylus Studio as their #1 XML resource. Come see which of these top oil, gas & electric companies are conserving their time and labor with Stylus Studio.

XQuery and Web Services

XQuery provides a flexible means for data abstraction, while Web services provide process abstraction. In this online video demonstration, learn how integrated XQuery & Web service tools simplify development of XQuery-based Web service applications.

XML Spell Checker

The Stylus Studio Spell Checker is integrated with our intuitive XML Text Editor. It highlights typographical errors as you type and lets you easily search, replace, and build custom dictionaries.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member