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

Re: what is wrong when separating Muenchian method int

Subject: 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)
separating int
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

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.