That's my very first question according to XSLT. I would like to transform a XML structure by using XSLT.
The relevant part of my XML source:
<field tag="ElementName">
<subfield code="S">p</subfield>
<subfield code="a">Content 1 for S=P</subfield>
</field>
<field tag="ElementName">
<subfield code="S">p</subfield>
<subfield code="a">Content 2 for S=P</subfield>
</field>
<field tag="ElementName">
<subfield code="S">p</subfield>
<subfield code="a">Content 3 for S=P</subfield>
</field>
<field tag="ElementName">
<subfield code="S">g</subfield>
<subfield code="a">Content 1 for S=G</subfield>
</field>
<field tag="ElementName">
<subfield code="S">g</subfield>
<subfield code="a">Content 2 for S=G</subfield>
</field>
<field tag="ElementName">
<subfield code="S">s</subfield>
<subfield code="a">Content 1 for S=S</subfield>
</field>
<field tag="ElementName">
<subfield code="S">s</subfield>
<subfield code="a">Content 2 for S=S</subfield>
</field>
<field tag="ElementName">
<subfield code="S">s</subfield>
<subfield code="a">Content 3 for S=S</subfield>
</field>
<field tag="ElementName">
<subfield code="S">s</subfield>
<subfield code="a">Content 4 for S=S</subfield>
</field>
Next what I would like the XML to look like after transformation:
<field tag="ElementName_P">
<subfield code="a">Content 1 for S=P</subfield>
<subfield code="a">Content 2 for S=P</subfield>
<subfield code="a">Content 3 for S=P</subfield>
</field>
<field tag="ElementName_G">
<subfield code="a">Content 1 for S=G</subfield>
<subfield code="a">Content 2 for S=G</subfield>
</field>
<field tag="ElementName_S">
<subfield code="a">Content 1 for S=S</subfield>
<subfield code="a">Content 2 for S=S</subfield>
<subfield code="a">Content 3 for S=S</subfield>
<subfield code="a">Content 4 for S=S</subfield>
</field>
I know how to get the attribute values and the field values using xsl:variable and xsl:value-of. What I would like to know is how to group the contents from the subfields with code="a". Have been trying for hours. Are there any possibilities using XPath?
Thx for support!