[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
xsl every second
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:  http://www.mulberrytech.com/xsl/xsl-list

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

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.