Try this url it is good to begin with http://www.w3schools.com/xsl/xsl_templates.asp;
*The disadvantage is it scans to the entire document always if we use match = "/"* The <xsl:template> Element The <xsl:template> element is used to build templates. The *match* attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document). Ok, let's look at a simplified version of the XSL file from the previous chapter: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td>.</td> <td>.</td> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet> Since an XSL style sheet is an XML document itself, it always begins with the XML declaration: *<?xml version="1.0" encoding="ISO-8859-1"?>*. The next element, *<xsl:stylesheet>*,* *defines that this document is an XSLT style sheet document (along with the version number and XSLT namespace attributes). The *<xsl:template>* element defines a template. The * match="/"* attribute associates the template with the root of the XML source document. The content inside the <xsl:template> element defines some HTML to write to the output. The last two lines define the end of the template and the end of the style sheet. The result of the transformation above will look like this: My CD Collection Title Artist . . <http://www.w3schools.com/xsl/cdcatalog.xml> <http://www.w3schools.com/xsl/cdcatalog_with_ex1.xml> Sajan Franco 2008/7/28 Matthew Holloway <[EMAIL PROTECTED]> > Hi Grant, > > On Mon, Jul 28, 2008 at 3:48 PM, Focas, Grant > <[EMAIL PROTECTED]> wrote: > > Is there a way in XSLT to loop through the ancestors until I find > > the first instance of a node called "foo"? > > > > For context what I'm trying to do is see if a "bookmark" is in the same > > "section" as the link/@href (and to find this out when I'm processing > > the link). > > First I've just got a few questions... you've got nested section tags > so what if the bookmark was in the parent section? Is that the same as > if it's in a following section? (if not then can you give a few more > XML file examples). > > If the first ancestor section is all that matters then an approach > would be to compare the generate-id()s of an ancestor section of the > link to the ancestor section of the bookmark. So you'd do something > like (from memory, untested code) > > <xsl:key name="bookmarkById" match="bookmark" use="@id"/> > > <xsl:template match="link"> > <xsl:choose> > <xsl:when test="generate-id(ancestor::section[1]) = > generate-id(key('bookmarkById', substring(@href, > 1)[1]/ancestor::section[1])">it's the same section</xsl:when> > <xsl:otherwise>it's not the same section</xsl:otherwise> > </xsl:choose> > </xsl:template> > > > > .Matthew Holloway > http://holloway.co.nz/ > > > ******************************************************************* > List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm > Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm > Help: [EMAIL PROTECTED] > ******************************************************************* > > ******************************************************************* List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *******************************************************************
