tags:

views:

163

answers:

1

Hi all,

Using XSLT, I'd like to be able to transform this :

<doc>
  <tag1>AAA</tag1>
  Hello !
  <tag2>BBB</tag2>
</doc>

into this :

<div class="doc">
  <div class="tag1">AAA</div>
  Hello !
  <div class="tag2">BBB</div>
</div>

...but without specifying explicitly any tag name in the stylesheet (there are too many in the real world)

What would be the best way to do this ?

+5  A: 

Something along the lines of

<xslt:template match="*">
    <div class="{local-name()}">
        <xsl:apply-templates />
    </div>
</xslt:template>
Mario Menger
I haven't been doing xsl stuff in quite a while, but is the xslt prefix on the template element deliberate, or should it be xsl?
Fredrik Mörk
It can be anything, depending on the header.It can even be a default namespace! `<template match="*">`...
alamar
Works like a charm indeed, correcting the prefix as Fredrik said.
Julien