I have a big set of XSLT templates that generate <div>
elements with assorted content. Matches look like these:
<xsl:template match="block[@name = 'block_blah']">
<div>
blah
<div>foooo</div>
</div>
</xsl:template>
<xsl:template match="block[@name = 'block2']">
<div>
<div>xyz</div>
abc
</div>
</xsl:template>
I need to add an attribute to every first level <div>
. So the output will become:
<div data-blockname="block_blah">
blah
<div>foooo</div>
</div>
<div data-blockname="block2">
<div>xyz</div>
abc
</div>
Do I have to insert data-blockname="{@name}"
manually in every case? Or is there a way to inject it globally?