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

MSXML4, key() across node-set

Subject: MSXML4, key() across node-set
From: "Alex Schuetz" <asc@xxxxxx>
Date: Thu, 20 Dec 2001 21:16:53 +0100
convert to nodeset msxml 4
As far as I can tell, when using a key() with the MSXML4 extention
node-set(),
the call to key('key-name', val)[1] does not always return the same node for
a constant val.

I have this stylesheet:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:variable name="set"
select="msxsl:node-set(document(/files/node/@path))"/>
<xsl:key name="k-id" match="person" use="@id" />

<xsl:template name="distinct">
        <xsl:for-each select="$set/doc/person[@id='4']">
            <info self-id="{generate-id(.)}"
index-id="{generate-id(key('k-id',@id)[1])}">
                <self>
                    <xsl:copy-of select="."/>
                </self>
                <index>
                    <xsl:copy-of select="key('k-id',@id)[1]" />
                </index>
            </info>
        </xsl:for-each>
</xsl:template>

<xsl:template match="/">
<test>
<xsl:call-template name="distinct" />
</test>
</xsl:template>
</xsl:stylesheet>

And two input files:

-------------------------------------------
input1.xml
<?xml version="1.0" encoding="utf-8" ?>
 <doc>
        <person name="onePerson" id="4" />
</doc>
-------------------------------------------
input2.xml
<?xml version="1.0" encoding="utf-8" ?>
 <doc>
        <person name="otherPerson" id="4" />
</doc>
-----------------------------------------------
When I run my stilesheet I get:

 <?xml version="1.0" encoding="UTF-16" ?>
- <test xmlns:msxsl="urn:schemas-microsoft-com:xslt">
- <info self-id="IDAUQ2N" index-id="IDAUQ2N">
-     <self>
          <person name="onePerson" id="4" />
      </self>
-     <index>
          <person name="onePerson" id="4" />
      </index>
      </info>
-         <info self-id="IDAIY2N" index-id="IDAIY2N">
-     <self>
          <person name="otherPerson" id="4" />
      </self>
-     <index>
          <person name="otherPerson" id="4" />
      </index>
      </info>
  </test>

It looks like there is a seperate key for each tree-fragment in the
node-set.
Did I miss something, or is this a known problem?

-alex




 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.