2009/8/20 Kate Busch-Petersen
<kate(_dot_)busch-petersen(_at_)the-group(_dot_)net>:
Hello,
I'm currently working on creating a blog in asp.net, using XML and XSLT 2.0.
In the past (working with XSLT 1.0) I've used multiple "apply-templates" to
handle all the possible param combinations, but I am looking for a more
manageable solution.
Current method:
<xsl:choose>
<xsl:when test="$AuthorId">
<xsl:apply-templates select="//blog[author_id = $AuthorId]"/>
</xsl:when>
<xsl:when test="$CategoryId">
<xsl:apply-templates select="//blog[category_id = $CategoryId]"/>
</xsl:when>
<xsl:when test="$AuthorId and $CategoryId">
<xsl:apply-templates select="//blog[author_id = $AuthorId and
category_id = $CategoryId]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="//blog"/>
</xsl:otherwise>
</xsl:choose>
How about:
<xsl:apply-templates select="//blog[author_id = ($AuthorId,
author_id)[1]][category_id = ($CategoryId, category_id)[1]]"/>
...although there might be a nicer way. Even so, sometimes its better
to have more readable code spread over a few lines than one that takes
you a few goes to understand what it's doing :)
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
--~------------------------------------------------------------------
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>
--~--