I'm trying to create an XSLT to "denormalize" an XML document.
Basically, the starting XML has a "collection" tag with many "item" tags inside it. Each item tag has a different value for its "id" attribute.
I want to use XSLT to change that into one "collection" tag with many tags inside it, where each of those tags has a name based on the "id" attributes of the "item" tags in the first document.
for example, starting with this:
I need to XSLT it to:
I expect to use an xsl:for-each construct,
But I can't figure out how to get the result of
to supply the actual tag name.
Basically, the starting XML has a "collection" tag with many "item" tags inside it. Each item tag has a different value for its "id" attribute.
I want to use XSLT to change that into one "collection" tag with many tags inside it, where each of those tags has a name based on the "id" attributes of the "item" tags in the first document.
for example, starting with this:
Code:
<collection>
<item id="field1">value</item>
<item id="field2">value</item>
<item id="field3">value</item>
<item id="field4">value</item>
</collection>
I need to XSLT it to:
Code:
<collection>
<field1>value</field1>
<field2>value</field2>
<field3>value</field3>
<field4>value</field4>
</collection>
I expect to use an xsl:for-each construct,
But I can't figure out how to get the result of
Code:
<xsl:value-of select="@id"/>