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

Please help Problem for : increment a variable in a f

Subject: Please help Problem for : increment a variable in a for-each?
From: que Li <queincanada@xxxxxxxx>
Date: Tue, 30 Nov 2004 13:28:49 -0500 (EST)
xsl variable increment
Hi all:
  I got so many peopel help but I can't get solution
for my problem yet. I need fix it asap so please help
me ! question is : How I can find relatiove position 
on the node which satify the condition ? I try to set
the variable called index and increment index value
when I call template but the index value is always 1

I work on this problems for several days, I wish I can
get help for solution.

Thanks



xml file:
<Lists>
<List >
  <List_ID>10</List_ID>
   <Title>A</Title>
  <Parent_ID>1</Parent_ID>
 </List>
 <List>
   <List_ID>11</List_ID>
   <Title>A1</Title>
   <Parent_ID>10</Parent_ID>
 </List>
<List >
    <List_ID>12</List_ID>
   <Title>B</Title>
  <Parent_ID>20</Parent_ID>
 </List>
 <List >
   <List_ID>13</List_ID>
   <Title>A2</Title>
   <Parent_ID>10</Parent_ID>
 </List>
 <List >
   <List_ID>14</List_ID>
   <Title>C</Title>
    <Parent_ID>1</Parent_ID>
 </List>
  </Lists>


xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="Lists"  >
        <xsl:apply-templates>
<xsl:with-param name="ValidCount"
select="number(count(List)-count(List[Parent_ID=../List/List_ID]))"/>
 
</xsl:apply-templates> 	   
</xsl:template>		

<xsl:template match="List">
   <xsl:param name="ValidCount"/>
   <xsl:variable name="self" select="."/> 
   <xsl:variable name="index" select="0"/> 
   <xsl:choose>
   <xsl:when test="Parent_ID=1 or
not(preceding-sibling::List[List_ID = $self/Parent_ID]
 or following-sibling::List[List_ID =
$self/Parent_ID])"> 
 <xsl:call-template name="formatTitle">
  <xsl:with-param name="index" select="$index+1"/>
  <xsl:with-param name="TotalCount"
select="$ValidCount"/> 
<xsl:with-param name="Title" select="Title"/>         
            
</xsl:call-template>
<xsl:call-template name="findChildNode">
  <xsl:with-param name="ParentID" select="List_ID"/>
</xsl:call-template> 
</xsl:when> 
</xsl:choose>                   
</xsl:template> 

<xsl:template name="findChildNode">
....this part work
</xsl:template>

<xsl:template name="formatTitle">
 	   <xsl:param  name="index" />
                  <xsl:param  name="TotalCount"/> 
               index:  <xsl:value-of select="$index"/>
                  <xsl:param name="Title"/>	
                  <xsl:choose>
<xsl:when test="$TotalCount=1 or $index=1">
 <b><xsl:value-of select="$Title"/></b>						
						</xsl:when>
						<xsl:when test="$index = $TotalCount -1">
						     <b> and <xsl:value-of select="$Title"/></b>
					
						</xsl:when>
						<xsl:when test="$index  = $TotalCount">
						     <b> <xsl:value-of select="$Title"/></b>				
	
						</xsl:when>
						<xsl:otherwise>
						   <b>; <xsl:value-of select="$Title"/></b>	
						</xsl:otherwise> 
				  </xsl:choose> 
	</xsl:template>
</xsl:stylesheet>


______________________________________________________________________ 
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.