Topic
  • No replies
SystemAdmin
SystemAdmin
1138 Posts

Pinned topic Need Urgent help in xslt

‏2013-02-27T13:13:45Z |
I need to remove root tag from incoming XML data.
Foe eg :
If this is the given input:
<ROOT retryCount="1">
<C>
<D>
<value>This is Value</value>
</D>
</C>
</ROOT>

Then my Output should be :
<C>
<D>
<value>This is Value</value>
</D>
</C>

Please note we want to remove root tag, I'm able to do same when i have direct input, I used below code & it worked.
<xsl:template match="/">
<xsl:apply-templates select="/child::node()/*" />
</xsl:template>

<xsl:template match="/child::node()/*">
<xsl:copy-of select="."/>
</xsl:template>

But in my requirement I donot have direct input, I have input data stored in one variable inside template.So I tried applying same code(as mentioned above) for variable input but it didn't work, it took only the text value from XML data(This is Value). Please help me as soon as possible.

I tried in this way :

<xsl:template match="/" name="main">
<xsl:param name="inputReq"></xsl:param>

<xsl:variable name="inputRequest">
<dp:url-open http-headers="$headers" target="{$FetchRetryReqURL}" response="xml" />
</xsl:variable>
<xsl:variable name="root" ><xsl:value-of select="name($inputRequest/descendant-or-self::*)"/></xsl:variable>

<xsl:variable name="Response">
<dp:url-open target="{$TargetURL}" response="responsecode-ignore" http-headers="$httpHeader">
<xsl:call-template name="remRootTag">
<xsl:with-param name="inputReq" select="$inputRequest" />
</xsl:call-template>
</dp:url-open>
</xsl:variable>
</xsl:template>

<xsl:template match="/child::node()/*" name="remRootTag">
<xsl:param name="inputReq"></xsl:param>
<xsl:copy-of select="$inputReq"/>
</xsl:template>