This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: returning single result from apply-templates



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@xyzfind.com
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@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of David Carlisle
Sent: Monday, October 09, 2000 10:42 AM
To: xsl-list@mulberrytech.com
Cc: xsl-list@mulberrytech.com
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]