xsl-list
[Top] [All Lists]

Re: [xsl] Avoiding multiple "apply-templates" by creating one variable for the clauses. Is it possible?

2009-08-20 07:31:43
Hi,


   <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>


Would this code have worked anyway? The XSLT 2.0 spec (8.2) reads:

"The content of the first, and only the first, xsl:when element that is satisfied is evaluated". I suppose it's the same in XSLT 1.0.

So I wonder if the third xsl:when would execute at all, because if either
$AuthorId or $CategoryId evaluate to true, one of the first two xsl:when
should be satisfied.

Michael

*  michael(_dot_)schaefer(_at_)destatis(_dot_)de    http://www.destatis.de
*                                  http://www.statspez.de

--~------------------------------------------------------------------
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>