i am beginner into XSLT. I am using it to transform XML to XML.
Source XML:
<Response>
<Text>Hello</Text>
</Response>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://myexample.org/a"
xmlns:b="http://myexample.org/b"
version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="Response" namespace="http://myexample.org/a">
<xsl:element name="Root">
<xsl:element name="a:Parent">
<xsl:element name="b:Child">
<xsl:value-of select="Text"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Output:
<Root>
<a:Parent xmlns:a="http://myexample.org/a">
<b:Child xmlns:b="http://myexample.org/b">Hello</b:Child>
</a:Parent>
</Root>
I would like to transform the XML into below XML using XSLT.
Expected Outpout:
<Root xmlns:a="http://myexample.org/a">
<a:Parent xmlns:b="http://myexample.org/b">
<b:Child/>
</a:Parent>
<Root>
I have successfully created the XSLT to transform the data but here i am confused with namespaces. I am not able to generate it as above.
Please help. Thanks.