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

Re: Spotting "cousin marriages" in a tree

Subject: Re: Spotting "cousin marriages" in a tree
From: Phil Endecott <spam_from_xslt_list@xxxxxxxxxxxx>
Date: Thu, 29 Jul 2004 13:13:36 +0100
phil endecott
David Carlisle wrote:
All that is stopping me is that XSLT doesn't - as far as I know - allow for keys to be used on exsl:node-set()s,

keys, once set up, automatically apply, separately, to any document that is used and so if your exsl:node-set() returns a node set consisting of a root node / which it will if it is given a result tree fragment coming from xsl:variable, then your keys will apply to that.

Thanks for the suggestion David. But I can't get it to work. Here's my test code:


<xsl:transform
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common"
  extension-element-prefixes="exsl">

<xsl:key name="k" match="a" use="@x"/>

  <xsl:template match="/">
    <xsl:variable name="v">
      <n>
        <a x="1" y="A"/>
        <a x="2" y="B"/>
      </n>
    </xsl:variable>
    <xsl:apply-templates select="exsl:node-set($v)/*"/>
  </xsl:template>

  <xsl:template match="n">
<!--    <xsl:apply-templates select="a[@x='1']"/> -->
    <xsl:apply-templates select="key('k','1')"/>
  </xsl:template>

  <xsl:template match="a">
    <xsl:value-of select="@y"/>
  </xsl:template>

</xsl:transform>


I get no output. But when I use the non-key lookup (commented out) I get "A", as expected. This is with libxslt's xsltproc:


$ xsltproc --version
Using libxml 20610, libxslt 10105 and libexslt 804

Does it work correctly on other processors?

--Phil.

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.