Subject: [xsl] Re: what is wrong when separating Muenchian method into two parts? From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Mon, 26 Mar 2001 20:38:45 -0800 (PST) |
Hi Yang, The reason for the problem is that the key() function operates on ***the current document*** So, when you have: <xsl:for-each select="msxsl:node-set($ppcodes)/pp"> <xsl:value-of select="."/> <xsl:value-of select="key('prodCode',.)/@ProductName"/> </xsl:for-each> The xsl:for-each statement changes the current node to msxsl:node-set($ppcodes) Then the key function will not find the same matching nodes in this new document as it would in the original xml source. <xsl:for-each select="msxsl:node-set($ppcodes)/pp"> <xsl:value-of select="."/> <xsl:value-of select="key('prodCode',.)/@ProductName"/> </xsl:for-each> What will work is something like this: <xsl:variable name="originalDoc" select="/"/> <xsl:for-each select="msxsl:node-set($ppcodes)/pp"> <xsl:variable name="thisPP" select="."/> <xsl:for-each select="$originalDoc"> <xsl:value-of select="$thisPP"/> <xsl:value-of select="key('prodCode',$thisPP)/@ProductName"/> </xsl:for-each> </xsl:for-each> Dimitre Novatchev. "Yang" <sfyang at unisvr dot net dot tw> wrote: Hi, Please someone help me out of the following problem; 1. I use Muenchian method to get the a unique set of product codes and save it into the node-set of'"ppcodes". <xsl:param name="OrderLine" select="//z:row"/> <xsl:variable name="ppcodes"> <xsl:for-each select="$OrderLine[generate-id(.)=generate-id(key('prodCode',(@ProductCode)) [1])]"> <pp> <xsl:value-of select="@ProductCode"/></pp> </xsl:for-each> </xsl:variable> 2. Then read back each product code from the node-set ($ppcodes) and pass it to key('prodCode',.) funtion to access the data. <xsl:for-each select="msxsl:node-set($ppcodes)/pp"> <xsl:value-of select="."/> <xsl:value-of select="key('prodCode',.)/@ProductName"/> </xsl:for-each> However this plot seems not workable, i.e. I can not get correct information from key function. I wonder I have misused Muenchian method somehow? 3. To verify the point I have directed following tests by giving a specific data in the key function with following codes, <xsl:for-each select="msxsl:node-set($ppcodes)/pp"> <xsl:value-of select="."/> <xsl:value-of select="key('prodCode','000001')/@ProductName"/> </xsl:for-each> and found out that; 3-1. when removing out <xsl:for-each select="msxsl:node-set($ppcodes)/pp"> the key function works normally. 3-2. But when including xsl:value-of, the following key function is completely ignored. To me, I am only separating a regular Muenchian method routine into two parts. However I may get lost somewhere in basic principle of using this method. Thanks your helpful input in advance. Sun-fu Yang, sfyang@xxxxxxxxxxxxx __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] what is wrong when separating, Yang | Thread | [xsl] how to outupt data in hex, Jia Ming Li |
[xsl] what is wrong when separating, Yang | Date | [xsl] how to outupt data in hex, Jia Ming Li |
Month |