Hi Ajay,
From your problem description, it seems you effectively need an XSLT
stylesheet like following,
<xsl:stylesheet version="1.0" xmlns:SwInt="some-namespace-ref">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<SwInt:RequestDescriptor>
<xsl:copy-of select="*/Request/RequestHeader"/>
</SwInt:RequestDescriptor>
</xsl:template>
</xsl:stylesheet>
(not tested)
and it seems, you wouldn't need a text to node facility.
Please feel free to report, if above solution doesn't work, and we could
possible suggest something different.
On Sat, Nov 19, 2011 at 3:27 AM, ajay bhadauria <[email protected]>wrote:
> Hi ,
>
> I have a variable in my xslt and based on the value of the variable, I
> need to select the xpath but the variable is not getting translated to node
> since it is text. So how I can convert text(string ) to node. Is there any
> alternate way of doing it ?
>
> Regards
> Ajay
>
> My XSLT is
>
> <xsl:stylesheet version="1.0" >
> <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
> <xsl:template match="/">
> <xsl:variable name="v1">
> <xsl:for-each select="/SendRequest|/ExchangeRequest">
> <xsl:choose>
> <xsl:when test="(local-name()='SendRequest')">
> <xsl:value-of select="SendRequest"/>
> </xsl:when>
> <xsl:when test="(local-name()='ExchangeRequest')">
> <xsl:value-of select="ExchangeRequest"/>
> </xsl:when>
> </xsl:choose>
> </xsl:for-each>
> </xsl:variable>
> <SwInt:RequestDescriptor>
> <xsl:copy-of select="$v1/Request/RequestHeader"/>
> </SwInt:RequestDescriptor>
> </xsl:template>
> </xsl:stylesheet>
>
> --------------------------
> XML is
> <SendRequest >
> <Request>
> <RequestHeader>
> <Requestor>xyz</Requestor>
> <Responder>abc</Responder>
> <RequestType>test</RequestType>
> </RequestHeader>
> </Request>
> </SendRequest>
>
--
Regards,
Mukul Gandhi