Subject: Re: [xsl] XPath: ancestor:: axis vs. use of ../../../ etc. From: Jarkko.Moilanen@xxxxxx Date: Sat, 8 Mar 2003 10:22:44 +0200 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XPath: ancestor:: axis vs, David Carlisle | Thread | Re: [xsl] XPath: ancestor:: axis vs, Lars Nyman |
Re: [xsl] newbie question, Jarkko . Moilanen | Date | Re: [xsl] newbie question, Jarkko . Moilanen |
Month |