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

grouping problem

Subject: grouping problem
From: 04083259@xxxxxxxxxxxxx
Date: Thu, 31 Mar 2005 11:48:02 +0100 (BST)
dig 35
hi every one
i am having a problem of grouping the dig elements from the xml database
below, i am trying to group all <dig> elements to be childs of their
proceding sibling the one has different name rather then dig
so all the dig after MoToooooooooooo will be childeren of this element
and the same  with the CoTooooooooooooo and SoTooooooooooooo

<top>
	<MoTooooooooooooooooooooo/>
	<dig>0.3</dig>
	<dig>1.2</dig>
	<CoToooooooooooooooooooo />
	<dig>4</dig>
	<dig>0</dig>
	<dig>4</dig>
	<dig>8</dig>
	<dig>12.0</dig>
	<dig>-32</dig>
	<dig>16</dig>
	<dig>0</dig>
	<dig>-6</dig>
	<dig>0</dig>
	<dig>0</dig>
	<dig>5</dig>
	<dig>4</dig>
	<dig>10</dig>
	<dig>-3</dig>
	<dig>10</dig>
	<dig>-103</dig>
	<dig>50</dig>
	<dig>-83</dig>
	<dig>90</dig>
	<dig>-42</dig>
	<dig>0</dig>
	<dig>0</dig>
	<dig>6</dig>
	<dig>20</dig>
	<dig>12</dig>
	<dig>30</dig>
	<dig>7</dig>
	<dig>-2</dig>
	<dig>12</dig>
	<dig>-18</dig>
	<dig>17</dig>
	<dig>-40</dig>
	<dig>17</dig>
	<dig>-55</dig>
	<dig>77</dig>
	<dig>-2</dig>
	<dig>-40</dig>
	<dig>25</dig>
	<dig>-20</dig>
	<dig>35</dig>
	<dig>30</dig>
	<dig>20</dig>
	<dig>35</dig>
	<dig>65</dig>
	<dig>-30</dig>
	<dig>71</dig>
	<dig>-50</dig>
	<SoToooooooooooooooooooooo/>
	<dig>4</dig>
	<dig>-170</dig>
	<dig>4</dig>
	<dig>-200</dig>
	<dig>-7</dig>
	<dig>9</dig>
</top>


to solve this problem i used the below recurseve templates to group the
dig after CoTooooooooooooo to group of 6(s)  it has a problem
can i get some assistant :
thanks



<xsl:template match="top">
<top>
  <xsl:call-template name="SecoundTemplate" >
    <xsl:with-param name="nodes" select="dig" />
  </xsl:call-template>
</top>


</xsl:template>
<xsl:template name="SecoundTemplate" >
<xsl:param name="nodes"  />
<xsl:choose>
   <xsl:when test="name(preceding-sibling::*[1]) !='CoTooooooooooooooo' "/>
     <xsl:otherwise>
    <CoTo>
      <xsl:call-template name="FinalTemplate">
        <xsl:with-param name="nodes" select="$nodes[position() >0 ]" />
      </xsl:call-template>
    </CoTo>
    <xsl:call-template name="SecoundTemplate">
      <xsl:with-param name="nodes" select="$nodes[position() >6]" />
    </xsl:call-template>
    </xsl:otherwise>
</xsl:choose>
</xsl:template>



<xsl:template name="FinalTemplate" >
<xsl:param name="nodes"  />
<xsl:param name="count" select="1" />
  <xsl:choose>
    <xsl:when test="($count = 7) or (name(following-sibling::*[1])
!='$nodes') )   "/>
    <xsl:otherwise>
      <dig><xsl:value-of select="$nodes[1]" /> </dig>
        <xsl:call-template name="FinalTemplate">
        <xsl:with-param name="nodes" select="$nodes[position() > 1]" />
        <xsl:with-param name="count" select="$count + 1" />
        </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
</xsl:stylesheet>

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.