Re: [xsl] list of Values

Subject: Re: [xsl] list of Values
From: David Tolpin <dvd@xxxxxxxxxxxxxx>
Date: Thu, 27 Nov 2003 23:18:28 +0400 (AMT)
[ Charset ISO-8859-1 unsupported, converting... ]
> Hi,
> How can I create a list of values?
> I want select n values from the xml file and put them in one list
> to pass with-param to one template, something like this:
> <xsl:call-template name="tempName">
>     <xsl:with-param name="$paramName" select="$listValues"/>
> </xsl:call-template>
> where listValue have for exemple the elements 'a' , 'b', 'c', 'd'
> after that I want  shift paramName to use each of these values...

If the values are present in the source XML file, then to accumulate 
the values in a data structure one can use node-set union operation.

One can later iterate (for-each) through the node-set or pass and increment
position in the node-set as a parameter for the template.

For example, the simple stylesheet below uses node-set 
to implement a grouping algorithm.


  <xsl:template name="group-n">

    <xsl:param name="e" select="."/>
    <xsl:param name="es" select="."/>
    <xsl:param name="i">1</xsl:param>
    <xsl:param name="n"/>
    <xsl:param name="group">group</xsl:param>

    <xsl:variable name="enext" select="$e/following-sibling::*[1]"/>

      <xsl:when test="$i = $n">
	<xsl:element name="{$group}">
	  <xsl:apply-templates select="$e|$es"/>
	<xsl:for-each select="$enext">
	  <xsl:call-template name="group-n">
	    <xsl:with-param name="group" select="$group"/>
	    <xsl:with-param name="n" select="$n"/>
	<xsl:call-template name="group-n">
	  <xsl:with-param name="group" select="$group"/>
	  <xsl:with-param name="i" select="$i+1"/>
	  <xsl:with-param name="n" select="$n"/>
	  <xsl:with-param name="e" select="$enext"/>
	  <xsl:with-param name="es" select="$es|$enext"/>



 XSL-List info and archive:

Current Thread