Modes

1. How to apply different stylesheets depending on document content

1.

How to apply different stylesheets depending on document content

David Allouche

you can use modes.

For example, if you want to apply style1.xsl or style2.xsl from style.xsl, you could define all templates in style1.xsl with mode="style1" (and use the mode attribute too in all call-template and apply-templates) and all templates in style2.xsl with mode="style2".

Then, you could have a style.xsl styelsheet that contains:

<xsl:include href="style1.xsl"/>
<xsl:include href="style2.xsl"/>

<xsl:template match="some pattern">
  <xsl:choose>
    <xsl:when test="some test">
      <xsl:apply-templates select="." mode="style1"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="." mode="style2"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>