harish
harish

Reputation: 2493

Adding "mode" attibute to xslt stylesheet

I have an xslt stylesheet which functions with no problem. I need to add the mode attribute to all xsl:template elements. What facts should I keep in mind in order to add the attribute to all elements and still have the stylesheet functioning properly. Any help is appreciated. Thank you in advance.

Upvotes: 2

Views: 740

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167696

Well it depends of course on the stylesheet and on the exact mode value you want to use, see http://www.w3.org/TR/xslt20/#modes for details.

Assuming you have something like templates without a mode attribute e.g.

<xsl:template match="foo">
  <bar>
    <xsl:apply-templates/>
  </bar>
</xsl:template>

and you want to use a certain mode then you have to change both the xsl:template as well as the xsl:apply-templates e.g.

<xsl:template match="foo" mode="m1">
  <bar>
    <xsl:apply-templates mode="m1"/>
  </bar>
</xsl:template>

On the apply-templates you have a different option however, you can use

<xsl:template match="foo" mode="m1">
  <bar>
    <xsl:apply-templates mode="#current"/>
  </bar>
</xsl:template>

although with a single mode value there is no difference.

Upvotes: 3

Related Questions