I am working on XSLT transformations. I am stuck at one point.
Source XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Content xmlns="uuid:4522eb85-0a47-45f9-8e2b-1f82c78fa920">
<first xmlns="uuid:4522eb85-0a47-45f9-8e2b-1f82c78fa920">Hello World.This is Fisrt field</first>
<second xmlns="uuid:4522eb85-0a47-45f9-8e2b-1f82c78fa920">Hello World.This is second field2</second>
</Content>
Output Format required:
<aaa>Hello World.This is Fisrt field</aaa>
<bbb>Hello World.This is second field</bbb>
Please suggest a solution for this.
I have tried this
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="uuid:4522eb85-0a47-45f9-8e2b-1f82c78fa920">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<aaa>
<xsl:value-of select="Content/first"/>
</aaa>
</xsl:template>
</xsl:stylesheet>
Output that i got is
<?xml version="1.0" encoding="utf-8"?>
<aaa xmlns="uuid:4522eb85-0a47-45f9-8e2b-1f82c78fa920"></aaa>
Output required is
<aaa>Hello World.This is Fisrt field</aaa>
Here’s one that does what you want, sort of, see comments below.
While certain xslt processors allow you to have more than one root element in the result, this isn’t advisable as it contradicts syntactically with the standard.