[xsl] VB: Grouping by position (using Jeni's solution) problem

Subject: [xsl] VB: Grouping by position (using Jeni's solution) problem
From: "Ulf Carlsson" <ulf.carlsson@xxxxxxxxx>
Date: Tue, 13 May 2003 20:04:20 +0200
 

	Hello,
	I want to creat a table with two pictures on every row. 
	I have used Jeni's solution of do a group by position but it don't
	work on my xml because of diffrent structure. I have tried 
	to change the apply-template elements in the procstep
	template and in the grate template with row mode see
	the xsl below.
	 
	My xml looks something like this:
	<procedure>
	    <procstep>
	        <grate>
	            <graphic id="KC03489-sv-SE"/>
	        </grate>
	    </procstep>
	    <procstep>
	        <grate>
	            <graphic id="KC03512-sv-SE"/>
	        </grate>
	        <grate>
	            <graphic id="KC036sds-sv-SE"/>
	        </grate>
	    </procstep>
	    <procstep>
	        <grate>
	            <graphic id="KC0370987g-sv-SE"/>
	        </grate>
	    </procstep>
	</procedure>

	My xsl looks like this:
	<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:fo="http://www.w3.org/1999/XSL/Format"; exclude-result-prefixes="fo">
	    <xsl:template match="/procedure">
	        <table>
	            <xsl:apply-templates/>
	        </table>
	</xsl:template>

	

	<xsl:template match="procstep">
	    <xsl:apply-templates select="grate[position() mod 2 = 1]" mode="row"/>
	</xsl:template>

	

	<xsl:template match="grate" mode="row">
	    <row>
	        <xsl:apply-templates select="self::node() | following-sibling::grate[position() &lt; 2]"/>
	    </row>
	</xsl:template> 

	

	<xsl:template match="grate">
	    <entry>
	        <i2graphic>
	            <xsl:copy-of select="graphic | graphic/@*"/>
	        </i2graphic>
	    </entry>
	</xsl:template>

	</xsl:stylesheet>

	I get a table structure like this: 
	<table>
	    <row>
	        <entry>
	            <graphic id="KC03489-sv-SE"/>
	        </entry>
	    </row>
	    <row>
	        <entry>
	            <graphic id="KC03512-sv-SE"/>
	        </entry>
	        <entry>
	            <graphic id="KC036sds-sv-SE"/>
	        </entry>
	    </row>
	    <row>
	        <entry>
	            <graphic id="KC0370987g-sv-SE"/>
	        </entry>
	    </row>
	</table>
	

	
	

	I want a table structure like this:
	<table>
	    <row>
	        <entry>
	            <graphic id="KC03489-sv-SE"/>
	        </entry>
	        <entry>
	            <graphic id="KC03512-sv-SE"/>
	        </entry>
	    </row>
	    <row>
	        <entry>
	            <graphic id="KC036sds-sv-SE"/>
	        </entry>
	        <entry>
	            <graphic id="KC0370987g-sv-SE"/>
	        </entry>
	    </row>
	</table>

	 

	
	Can somebody suggest a solution?

	Thanks in advance,

	Ulf


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


Current Thread