[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath: ancestor:: axis vs. use of ../../../ etc.

Subject: Re: XPath: ancestor:: axis vs. use of ../../../ etc.
From: Jarkko.Moilanen@xxxxxx
Date: Sat, 8 Mar 2003 10:22:44 +0200
xpath grandparent
Lainaus David Carlisle <davidc@xxxxxxxxx>:

| 
| >> My basic question: what is going on that 
| 	A.	"../../@name" 
| is so different from 
| 	B.	"../../../span-fill/@name"
| ?

Concider the source as a tree where you jump around (Thanks for this 
idea, Ken =)). Once you state that ".." you will go to the parent element. 
If you would state just "." you would jump on your self axis.

A simple example:
When you would have somethign like this:
<?xml version ="1.0"?>
<Elements>
 <elem>value 1
  <subelem>value 1.1</subelem>
 </elem>
 <elem>value 2
  <subelem>value 2.1</subelem>
 </elem>
</Elements>

and you would apply this stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" indent="yes" /> 
	
<xsl:template match="Elements">
<html>
<body>
 <xsl:for-each select="elem/subelem">
 <p><xsl:value-of select="."/></p>
 <p><xsl:value-of select="parent::*"/></p>
 </xsl:for-each> 

 <xsl:for-each select="elem/subelem">
 <p><xsl:value-of select="."/></p>
 <p><xsl:value-of select="parent::elem"/></p>
 </xsl:for-each>

 <xsl:for-each select="elem/subelem">
 <p><xsl:value-of select="."/></p>
 <p><xsl:value-of select=".."/></p>
 </xsl:for-each>
 </body>
</html>
</xsl:template>
</xsl:stylesheet> 

All of those in this case would select the same values.

Cheers, 
Jarkko


Cheers, 
Jarkko  

| 
| 
| A is the name attribute of your grandparent
| B is the name attribute of a span-fill child of your great-grandparent,
| this might not be your ancestor, it might be a great uncle.
| 
| David
| 
|  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| 
| 


***************************************************
* Jarkko Moilanen                                 *
* Project Researcher, ITCM (www.itcm.org)         *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.