Subject: Re: [xsl] MSXML4, key() across node-set From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> Date: Fri, 21 Dec 2001 02:18:26 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] MSXML4, key() across node-set, Alex Schuetz | Thread | [xsl] XPath Question., Avula, Raj |
RE: [xsl] how to rearrange nodes ba, Chris Bayes | Date | Re: Re[2]: [xsl] How can I avoid ge, Joerg Heinicke |
Month |