Re: [xsl] avoiding assignment statements

Subject: Re: [xsl] avoiding assignment statements
From: "Sam Carleton" <scarleton@xxxxxxxxxxxxxxxx>
Date: Fri, 8 Dec 2006 09:56:52 -0500
On 12/8/06, David Carlisle <davidc@xxxxxxxxx> wrote:

xslt works rather better if you have structured input rather than a fixed set of flat variables. If you had a parameter show that took a list of elements say <Replicates/><Metadata/> then you could just do <xsl:for-each select="$show"> <xsl:if test="position()!=1">, </xsl:if> <xsl:apply-templates select="."/> </xsl:for-each>

Huston, there is a problem...


I tried it in the main XSLT and it wasn't working so I thought I would
put it into a very simply XSLT file so that it was the only thing that
happens and I simply cannot get it to work.  What am I missing?  Here
is the simple XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:param name="show"><showReplicates/><showMetadata/><showElectronicSignature/></xsl:param>

 <xsl:template match="/">
   <xsl:for-each select="$show">
    <xsl:if test="position()!=1">, </xsl:if>
    <xsl:apply-templates select="."/>
   </xsl:for-each>
 </xsl:template>

 <xsl:template match="showReplicates">
 Reps
 </xsl:template>

 <xsl:template match="showMetadata">
 Meta-Data
 </xsl:template>

 <xsl:template match="showElectronicSignature">
 Signature
 </xsl:template>

</xsl:stylesheet>

Current Thread