ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
Re: [xsl] MSXML4, key() across node-set
by Joerg Heinicke other posts by this author
Dec 21 2001 1:18AM messages near this date
[xsl] MSXML4, key() across node-set | [xsl] Can someone convert this function in MSXSL:script to Rhino 1.5 ??
I think, this is a strange behaviour, too. Isn't only one nodeset created
with

<xsl:variable name="set" select="document(/files/node/@path)"/> 
(You don't need the extension-function.)?

On which key('k-id',@id)[1] should only return the first node and always
return the same first node?

Only the working with a RTF and the nodeset-extension works as expected:
(I tried it with Xalan and MSXML.)

<xsl:variable name="settemp"> 
    <xsl:for-each select="/files/node"> 
        <xsl:copy-of select="document(@path)"/> 
    </xsl:for-each> 
</xsl:variable> 

<xsl:variable name="set" select="xalan:nodeset($settemp)"/> 

Is it correct how MSXML and Xalan behave?

Joerg

>  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
Thread:
Alex Schuetz
Joerg Heinicke

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved