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

RE: how to group equal nodes by a it's position()

Subject: RE: how to group equal nodes by a it's position()
From: Dmitri Ilyin <dmitri.ilyin@xxxxxxxxx>
Date: Mon, 1 Oct 2001 13:44:19 +0200
position of elements equal
thanks Paul. It does what I want.

> -----Original Message-----
> From: Paul Tyson [mailto:paul@xxxxxxxxxxxxxxxxxxxxxx]
> Sent: Friday, September 28, 2001 10:45 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  how to group equal nodes by a it's position()
> 
> 
> Dmitri,
> 
> This does, literally, what you asked for.
> 
> If you want HTML-like tables with rows and cells, you'd use 
> <table> literal
> result elements (instead of <table_n>), and add some template 
> processing of
> <call> elements (instead of copy-of).  One way of making 
> table rows from a
> list is shown in archived post:
>      
> http://www.biglist.com/lists/xsl-list/archives/200109/msg01324.html
> 
> <xsl:template match="calls">
>     <xsl:call-template name="make-tables"/>
> </xsl:template>
> 
> <xsl:template name="make-tables">
>     <xsl:param name="nth-item" select="1"/>
>     <xsl:param name="table-number" select="1"/>
>     <xsl:variable name="table-name"
> select="concat('table_',$table-number)"/>
>     <xsl:choose>
>         <xsl:when test="$nth-item &gt; count(call)"/><!-- done -->
>         <xsl:when test="$nth-item = 1">
>             <!-- the first table, 10 items -->
>             <xsl:element name="{$table-name}">
>                 <xsl:copy-of select="call[position() &lt;= 10]"/>
>             </xsl:element>
>             <xsl:call-template name="make-tables">
>                 <xsl:with-param name="nth-item" 
> select="$nth-item + 10"/>
>                 <xsl:with-param name="table-number" 
> select="$table-number +
> 1"/>
>             </xsl:call-template>
>         </xsl:when>
>         <xsl:when test="count(call) - $nth-item &lt; 20">
>             <!-- the last table, up to 20 items -->
>             <xsl:element name="{$table-name}">
>                 <xsl:copy-of select="call[position() &gt;= 
> $nth-item]"/>
>             </xsl:element>
>         </xsl:when>
>         <xsl:otherwise>
>             <xsl:element name="{$table-name}">
>                 <xsl:copy-of select="call[position() &gt;= 
> $nth-item and
>                          position() &lt; $nth-item + 15]"/>
>             </xsl:element>
>             <xsl:call-template name="make-tables">
>                 <xsl:with-param name="nth-item" 
> select="$nth-item + 15"/>
>                 <xsl:with-param name="table-number" 
> select="$table-number +
> 1"/>
>             </xsl:call-template>
>         </xsl:otherwise>
>      </xsl:choose>
>   </xsl:template>
> 
> Have fun,
> Paul
> 
> ----- Original Message -----
> From: "Dmitri Ilyin" <dmitri.ilyin@xxxxxxxxx>
> To: "XSL-List@lists. mulberrytech. com (E-mail)"
> <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Friday, September 28, 2001 12:15 PM
> Subject:  how to group equal nodes by a it's position()
> 
> 
> > Hi *,
> >
> > i have next xml:
> >
> > <calls>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  <call>sme text</call>
> >  .....
> >  <call>sme text</call>
> > </calls>
> >
> > i have to group the <call> by it's position()
> > to get
> > <table_1>
> >  <call>some text</call>
> >  from position 1 to 10 (10 elements in the table_1)
> >  <call>some text</call>
> > </table_1>
> > <table_2>
> >  <call>some text</call>
> >   from position 11 to 25 (15 elements in table_2)
> > </table_2>
> > ....
> > <table_n>
> >  <call>some text</call>
> >   from position 26 to 40 (15 elements in table_n)
> > </table_n>
> >
> > <table_x>
> >  <call>some text</call>
> >   from position nnn to mmm (20 elements or less in table_x)
> > </table_x>
> >
> > So I have 3 types of tables, with 10, 15, 20 elements.
> > The number of call nodes in table 1 must be 10 and it must 
> be first 10
> > elements,
> > the number of call nodes in tables 2 to n must be 15,
> > the number of call nodes in last table must be 20 or less.
> >
> > the number of call elements can be different.
> > eg i have 100 call elements
> > so i have to put in the first table 10 elements,
> > in the tables from 2..6 15 elements
> > and in the last table 15 elements.
> >
> > If i have 106 elements i could put in last table 20 (and 
> make the last
> table
> > complete)
> > elements end still have ones more element,
> > so i have to create one more table with 15 elements and put 
> in the last
> > table the last 6 elements.
> >
> >
> > are there any solutions of that problem???
> >
> > thanks for advise
> >
> > Dmitri
> >
> >  XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 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.