I'm kind of new to using XSL. I'm trying to convert an XML file into another XML file with a different structure using XSL. The input section of the XML goes like this:
<tag>
<Keyword>Event: Some Text</Keyword>
<Keyword>Group: Some Text</Keyword>
<Keyword>Other: Some Text</Keyword>
</tag>
I would like the desired output to be:
<tag>
<event> Some Text </event>
<group> Some Text </group>
<other> Some Text </other>
</tag>
My current XSL file:
<xsl:for-each select="tag">
<xsl:if test="starts-with(Keyword, 'Event: ')">
<event>
<xsl:value-of select="substring-after(Keyword, 'Event: ')"/>
</event>
</xsl:if>
<xsl:if test="starts-with(Keyword, 'Group: ')">
<group>
<xsl:value-of select="substring-after(Keyword, 'Group: ')"/>
</group>
</xsl:if>
<xsl:if test="starts-with(Keyword, 'Other: ')">
<other>
<xsl:value-of select="substring-after(Keyword, 'Other: ')"/>
</other>
</xsl:if>
</xsl:for-each>
The current output only shows the event node and does not display the remaining nodes:
<tag>
<event> Some Text </event>
</tag>
I tried switching the 'group' section with the 'event' section in the XSL, however all the child nodes are not displayed probably due to the ordering of the keyword nodes in the input XML. So how can I read all the keyword nodes and convert them to the respective new nodes for display?