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

Re: Using XSLT's key() function while context in seco

Subject: Re: Using XSLT's key() function while context in secondary document?
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 19 Feb 2008 17:24:25 +0000
Re:  Using XSLT's key() function while context in  seco
On 19/02/2008, Scott Trenda <Scott.Trenda@xxxxxxxx> wrote:
>       <xsl:for-each select="key('chnam', document('s.xml')//Channel)">

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I don't know the origins of this thread but that looks highly dubious
- the key lookup would be the string value of all of the <Channel>
elements in s.xml.

If this is XSLT 1.0 then the pattern is:

<xsl:variable name="this" select="/">
<xsl:variable name="sDoc" select="document('s.xml')"/>

<xsl:for-each select="$sDoc//Channel">
  <xsl:variable name="lookup" select="."/>
  <xsl:for-each select="$this">
    <xsl:apply-templates select="key('chnam', $lookup)"/>
  ..
..

In 2.0 its much easier because you don't have to maintain a pointer to
the original source XML, and you have the slash operator, so the
equivalent is:

<xsl:apply-templates select="$sDoc//Channel/key('chnam', ., /)"/>


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.