Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Grouping by two or any number

From: Kiran@-----------.---------.---
To: NULL
Date: 12/2/2004 8:35:00 AM
well that was kool. your first xsl solved my problem.

i am very much interested in the second one but when i validate it give me 
the following error..

The character '<' cannot be used in an attribute value. Error processing 
resource 'file:///C:/grouping.xsl'. Line 32, Position 69 

       <xsl:for-each select=". | preceding-sibling::node[position() <= 
($group-size - 1)]">         
--------------------------------------------------------------------^


Thanks & Regards,
Kiran

"Mukul Gandhi" wrote:

> The following stylesheet can accept any group size..
> 
> You may run it as :
> msxsl file.xml file.xsl group-size=4
> (You may pass any value for group-size from the command line)
> 
> <?xml version="1.0"?> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="1.0">
>  
> <xsl:output method="text" /> 
> 
> <xsl:param name="group-size" select="3" />
>  
> <xsl:template match="/Parent">
>    <xsl:variable name="n" select="count(node) - (floor((count(node) div 
> $group-size)) * $group-size)" />
>    
>    <xsl:for-each select="node">
>      <xsl:if test="(position() mod $group-size) = 0">
>        group <xsl:value-of select="floor(position() div $group-size)" 
> /><xsl:text> - </xsl:text>
>        <xsl:for-each select=". | preceding-sibling::node[position() <= 
> ($group-size - 1)]">         
>          <xsl:value-of select="." /><xsl:if test="(position() mod 
> $group-size) != 0"><xsl:text>,</xsl:text></xsl:if>       
>        </xsl:for-each>
>        <xsl:text>
> </xsl:text>
>      </xsl:if> 
>      <xsl:if test="((position() = last()) and ((position() mod $group-size) 
> != 0))">
>        group <xsl:value-of select="floor(position() div $group-size) + 1" 
> /><xsl:text> - </xsl:text>
>        <xsl:for-each select=". | preceding-sibling::node[position() < $n]">
>          <xsl:value-of select="." /><xsl:if test="position() != 
> last()"><xsl:text>,</xsl:text></xsl:if> 
>        </xsl:for-each>
>        <xsl:text>
> </xsl:text>
>      </xsl:if>
>    </xsl:for-each>
> </xsl:template>
>    
> </xsl:stylesheet>
> 
> Regards,
> Mukul
> 
> 
> "Kiran" wrote:
> 
> >  i have the following xml
> > 
> > <Parent>
> > 	<node>a</node>
> > 	<node>s</node>
> > 	<node>d</node>
> > 	<node>f</node>
> > 	<node>g</node>
> > 	<node>h</node>
> > 	<node>j</node>
> > 	<node>k</node>
> > 	<node>l</node>
> >  </Parent>
> > 
> > 
> > Need to print in following format (into groups of two)
> > 
> > group 1 - a,s
> > group 2 - d,f
> > group 3 - g,h
> > group 4 - j,k
> > group 5 - l
> > 
> > Thanks in advance
> > 
> > Kiran


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent