Re: [xslt] How to implement unusual chunking in a stylesheet



On 8 Jun 2002, Peter Williams wrote:

> [Apologies if this is not the right list for this sort of question.
> Please CC me in replies as I'm not subscribed.]
> 
> Hi everyone,
> 
> 	I'm trying to write a stylesheet that chunks my XML document in a
> somewhat unusual way. The basic layout of the document is like this:
> 
> 	<root>
> 		<item>
> 			<node>
> 			<node>
> 		</item><item>
> 			<node>
> 		</item><item>
> 			<node>
> 			<node>
> 			<node>
> 		...
> 		</item>
> 	</root>
> 
> with a variable number of <node>s per <item>. I'd like to chunk it so
> that there's a fixed number of <node>s per output document. I can't
> figure out how to implment this in XSLT. Any ideas?
> 

Something along the lines of:

<xsl:for-each select="item/node">
  <xsl:call-template name="my-write-node-to-file" />
  <xsl:choose>
    <xsl:when test="$testvar=n">
      <xsl:call-template name="move-to-next-file" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="var1" select="$var1 + 1">
    </xsl:otherwise>
  </xsl:choose>
</xsl:for-each>

warning - totally untested

> Thanks in advance for help or pointers,
> 	Peter
> 
> -- 
> Peter Williams     peter@newton.cx / peterw@ximian.com
> 
> &quot;Why should I have to change my name? He's the one who 
> sucks!&quot;                              -- Michael Bolton
> 

	Sander

	you'll rescue me right?
	in the exact same way that they never did
	i'll be happy right?
	when your healing powers kick in





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]