Re: Alternate Values on every second column

Subject: Re: Alternate Values on every second column
From: Steve Tinney <stinney@xxxxxxxxxxxxx>
Date: Mon, 17 Jan 2000 21:59:40 -0500
Here is a fairly general way to step through a pair of node-sets
simultaneously.  It would be easy to move the node-set select to the
parent template, and also easy to write it such that it steps through
lists of unequal length, padding the shorter with empty cells as
necessary.  With the not-yet-available, new, improved, washes-whiter
Saxon, you will even be able to use such a function as a library
routine, and pass in variables to it to select the node-sets you want to
step through.  These modifications are left as an exercise for the

Thinking out loud department: I suppose it will even be possible to
write a single routine that steps through n node-sets, according to an
argument nodeset of the form:


You could build such a node-set by making an RTF from features in the
input data and converting it with nodeset().  Now if we could only call
templates using a function-name in a variable: <xsl:calltemplate


<xsl:stylesheet version="1.0" 

<xsl:template match="/">
  <xsl:call-template name="emit-xy"/>

<xsl:template name="emit-xy">
  <xsl:param name="index" select="0"/>
  <xsl:param name="xnodes" select="foo/x"/>
  <xsl:param name="ynodes" select="foo/y"/>
  <xsl:if test="$index &lt; count($xnodes)">
    <xsl:apply-templates select="$xnodes[$index+1]"/>
    <xsl:apply-templates select="$ynodes[$index+1]"/>
    <xsl:call-template name="emit-xy">
      <xsl:with-param name="index" select="$index+1"/>

<xsl:template match="x|y">
  <xsl:value-of select="name()"/>


"Olynyk, Dean" wrote:
> Hi there,
> Is there a way, besides a brute-force attack, to do the following with XSL?
> ---------------------------------
> | x | y | x | y | x | y | x | y |
> ---------------------------------
> The values of x and y will appear once in the associated XML file.
> Currently, I'm doing:
> <td align="center"><b><xsl:value-of select="foo/x"/></b></td>
> <td align="center"><b><xsl:value-of select="foo/y"/></b></td>
> <td align="center"><b><xsl:value-of select="foo/x"/></b></td>
> ...repeat 23 more times...
> >From the XML:
> <foo>
>   <x>'98</x>
>   <y>'99</y>
> </foo>
> Is there a cleaner way to do this?
> Thanks,
> --
> d.
>  XSL-List info and archive:

Steve Tinney                                        Babylonian Section
                                 *   University of Pennsylvania Museum
stinney@xxxxxxxxxxxxx                          Phila, PA. 215-898-4047

 XSL-List info and archive:

Current Thread