Home > Net >  Create a new tag from attribute
Create a new tag from attribute

Time:02-01

I need an xsl transformation that, given inputs like (with variable number of columns and rows)

<row>
<column inum="1">...</column>
<column inum="2">...</column>
[...]
</row>
<row>
[...]

gives back a structure like

<row>
<column_1>...</column_1>
<column_2>...</column_2>
[...]
</row>
<row>
[...]

I've seen many answers, but all about copying/modifying attributes, not using them to create new tags. Is it possible?

CodePudding user response:

It's a rather trivial exercise:

<xsl:template match="column">
    <xsl:element name="column_{@inum}">
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>
  • Related