[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: returning single result from apply-templates

Subject: RE: returning single result from apply-templates
From: "Evan Lenz" <elenz@xxxxxxxxxxx>
Date: Mon, 9 Oct 2000 11:14:24 -0700
xsl single result
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.