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

question on preceding nodes

Subject: question on preceding nodes
From: "Liao, John Teguh (John)" <jliao@xxxxxxxxxx>
Date: Mon, 31 Mar 2003 18:07:52 -0500
 question on preceding nodes
Hi list

I would like to understand the use of preceding axis relative to my problem.

My xml looks like

<BOXES>
    <BOX number="1">
         <C name="pencil"/>
         <C name="pen"/>
         <C name="eraser"/>
     </BOX>
     <BOX number="2">
          <C name="pen"/>
          <C name="razor blade"/>
          <C name="highlighter"/>
          <C name="post_it_notes"/>
     </BOX>
     .... other BOXes
</BOXES>

In my xsl i would like to display the names of C in BOX number 2 as "pen_2"
because it's found in
BOX number 2 and there is already a pencil in BOX number 1 (to make the name
unique). For the
pen found in BOX number 1 I just want to display "pen". If the tenth BOX has
a "pen"s also, it should
be displayed as "pen_10" and so forth.
 
so I have a line to check for uniqueness like this:
<xsl:template match="C">
    <xsl:for-each select="C">
        <xsl:choose>
        <xsl:when test="preceding::/*/*/C[@name=current()/@name]">
            <xsl:value-of select="current()/@name"/>_<xsl:value-of
select="../BOX/@number"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="current()/@name"/>
        </xsl:otherwise>
    </xsl:for-each>
</xsl:template>

but this never produces the "_2" in "pen_2".

Any tip?






 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.