xsl-list
[Top] [All Lists]

Re: [xsl] avoiding assignment statements

2006-12-08 07:29:00

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>

where templates macching Replicates woul ddo whatever your pseudo code
Output("Reps") does.


or in xslt2 you could just have again a single parameter which takes a
sequence of strings rather than elements, and again for-each over that.

As it is, with scalar params, it's a bit easier to handle in xslt2, as
you can easily turn it into the above

<xsl:variable name="show" as="element()*">
<xsl:if test="showReplicates=1"><Replicates/></xsl:if>
...
</xsl:if>

in xslt1 you could do the same with the node-set extension that most
systems offer.



David

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>