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

four time post:

Subject: four time post:
From: que Li <queincanada@xxxxxxxx>
Date: Thu, 25 Nov 2004 22:46:00 -0500 (EST)
xsl parentid
Hi:
   It was fourth time for me to post this question and
I hope no reject this time.

I found several people asked the same question with me
"Re:  how to increment a variable in a for-each
loop" but it really didn't resolve my problems. So
just wonder could I get help ? I spent lots of time on
it and can't get solution!

My xml file
<root> 
<list>
    <ID>21</ID>
   <Title>text1</Title>
   <ParentID>1<ParentID>
</list>
<list>
    <ID>22</ID>
   <Title>text2</Title>
   <ParentID>21<ParentID>
</list>

<list>
    <ID>23</ID>
   <Title>text3</Title>
   <ParentID>21<ParentID>
</list>    

<list>
    <ID>24</ID>
   <Title>text4</Title>
   <ParentID>21<ParentID>
</list>  

<list>
    <ID>25</ID>
   <Title>text5</Title>
   <ParentID>1<ParentID>
</list>  

</root>

What I want do: I need do different thing  for the 
node which  parentID is 21(by passing in )(exampel:If
it is first child then I need bold. if not first and
not last one then I need do second thing. If the node
is last child then I need do third things.

I try to use the call:template and xsl:for each to
pass the parameter but the count is always set to
initial since I run so many for each 
what I shoud do ?

My code


<xsl:template match="root">

<xsl:for each select="list">

<xsl:if test="parented =1">

<xsl:call-template name= !0findChildNode!1>

  <xsl:with-param name=!1ID!1 select="ID!1/>

</xsl:call-template>

</xsl:for-each>

</xsl:template>



<xsl:template name="findChildNode!1>

<xsl:param name="ID!1>

<xsl:param name="count!1 select="0!1/>

<xsl:for-each select="../list!1>

   <xsl:if test="parentID=$ID!1>

    <xsl:call-template  name="formatChild!1>

<xsl:with-param name="count" select="$count+1!1/>

   </xsl:if>

</xsl:for each>

</xsl:template>



<xsl:template name="formatChid!1>

   <xsl:param name="count!1>

<xsl:variable name="TotalChildCount!1 select=!1?!1/>
(Note: I don't know how I can get all child node count
based on the one parentID)

            <xsl:choose>

<xsl:when  test="$count=1!1>do firsth thing</xsl:when>
<xsl:when  test="$count &gt; 1 and $count &lt; 
$TotalChildCount!1>do second  thing</xsl:when>

<xsl:when  test="$count=$TotalCount!1>do third 
thing</xsl:when>

          </xsl:choose>

</xsl:template>



Question: 

 1.   Why every time the $count is 0 and never
incresement  ?
2.   How I can get the total child count value based
on the parent ID?

Thanks for any help
Helena


______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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.