[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Selecting nodes based on previous node values
Subject: Re: [xsl] Selecting nodes based on previous node values From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 11 Dec 2008 09:33:16 GMT |
> I want to print all book titles in library with criteria status = "active". <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:reporting="http://www.sophis.net/reporting"> <xsl:template match="demo"> <xsl:apply-templates select="library[criteria/status/@value='active']/books/book"/> </xsl:template> <xsl:template match="book"> : <xsl:value-of select="@title"/> </xsl:template> </xsl:stylesheet> > What did I wrong? preceding::/ that would be asking for the preceding / node, which isn't what you meant' you meant /books[preceding::status but ther eis no need to keep goiing back looking everywhere in all earlier nodes, also you would need a [1] otherwise if any earlier status was active you would list the book, but you want to just check the immediately preceding element. select="./@title" ./ at the front of a select never does anything (it doesn't do any harm) similarly <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> is the default template so doesn't actually make any difference here. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Selecting nodes based on , Michael Kay | Thread | [xsl] removing trailing space for a, M Balaji |
RE: [xsl] Selecting nodes based on , Michael Kay | Date | RE: [xsl] Generating ID key values, Trevor Nicholls |
Month |