XSLT combining 2 nodes into a new node



Im struggling with XML and XSLt transformations, i have the following.





<<?xml version="1.0" encoding="utf-8"?>
<playlist>
<song>
<title>Little Fluffy Clouds</title>
<artist>the Orb</artist>
</song>
</playlist>



I want to combine title and artits into a new node called: info





<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output indent="yes"/>
<!--Identity Transform.-->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="title | artits">
<info>
<xsl:value-of select="."/>
</info>
</xsl:template>
</xsl:stylesheet>



The above returns:





<playlist>
<info>Little Fluffy Clouds</info>
<info>the Orb</info>
</playlist>



I need to combine these, this is supposed to be simple but i cant get it right, what i would want is:



<playlist>
<info>Little Fluffy Clouds the Orb</info>
</playlist>

No comments:

Post a Comment