Subject: RE: returning single result from apply-templates From: "Evan Lenz" <elenz@xxxxxxxxxxx> Date: Mon, 9 Oct 2000 11:14:24 -0700 |
Mike Kay had a good explanation of this in his book, on the abbreviated syntax of XPath absolute and relative path expressions (pp. 326-330). // is short for /descendant-or-self::node()/ Note that it is interestingly not an abbreviation for one step. Instead, it's an abbreviation for one step + "/". Thus, <xsl:apply-templates select="//"/> is invalid, because it's akin to adding a slash to the end of an XPath expression. Thus, if you keep in mind the fact that //foo actually consists of two XPath steps, you should avoid this confusion in the future. David's solution will work, because it assigns the predicate to the foo//bar overall node-set rather than to each intermediate bar node-set. The following will also work, and may be more straightforward (consisting of two steps rather than three): <xsl:apply-templates select="foo/descendant::bar[1]"/> Hope this helps, Evan Lenz elenz@xxxxxxxxxxx http://www.xyzfind.com XYZFind, the search engine *designed* for XML Download our free beta software: http://www.xyzfind.com/beta -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of David Carlisle Sent: Monday, October 09, 2000 10:42 AM To: xsl-list@xxxxxxxxxxxxxxxx Cc: xsl-list@xxxxxxxxxxxxxxxx Subject: Re: returning single result from apply-templates > If I do > > <xsl:apply-template select="foo//bar[1]"/> > > I get but you don't if you do <xsl:apply-template select="(foo//bar)[1]"/> David XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: returning single result from ap, David Carlisle | Thread | RE: returning single result from ap, Sebastian Rahtz |
Formatted node to variable, Hakan Pettersson | Date | Re: Updated Benchmark Available, Alexey Gokhberg |
Month |