|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Alternate Values on every second column
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 reader. 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: <paths> <path>foo/x</path> <path>foo/y</path> <path>foo/z</path> </paths>. 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 name="$callback">. Steve <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:call-template name="emit-xy"/> </xsl:template> <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 < 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:call-template> </xsl:if> </xsl:template> <xsl:template match="x|y"> <xsl:value-of select="name()"/> </xsl:template> </xsl:stylesheet> "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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






