[xslt] non-dynamic modes



I know that the XSL spec doesn't allow for anything but QNames as a value for mode attributes on <xsl:apply-templates/>, and thus this is not a libxslt bug. So I'm wondering whether this is a drawback of 1.0, or if I'm attacking the problem incorrectly.

Am I correct in assuming that the only way to vary modes is with a choose block?

  <xsl:choose>
    <xsl:when test="$thismode = 'edit'">
      <xsl:apply-templates mode='edit'/>
    </xsl:when>
    <xsl:when test="$thismode = 'preview'">
      <xsl:apply-templates mode='preview'/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates/>
    </xsl:otherwise>
  <xsl:choose>

And since modes do not cascade, that I need to duplicate that block each time I do subsequent <xsl:apply-templates/> from within each individual template, using a global vary to carry the mode through each processing step? (And obviously add to the list (each list) each time I have a new set of templates with a new mode.)

Is there a better way to apply-templates to the same source data in different ways? I just wanted a sanity check before I dig in to the source, because this seems quite limiting. The only other thing that occurs to me is to use <xsl:call-template/>, in which case I'm still creating choose blocks, and have templates that are much less elegant.

Thanks,
Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]