user10888192
user10888192

Reputation: 27

XSLT to pass value with XML tag

I need to get the value of a node with an xml format but all i'm getting is the values inside those tags.

Body:

<input>
<first>one</first>
<second>two</second>
<third>three</third>
</input>

XQuery

<PayloadAsMessage>
          <xsl:value-of select="/input"/>
</PayloadAsMessage>

Expected output:

<PayloadAsMessage>
        <first>one</first>
        <second>two</second>
        <third>three</third>
</PayloadAsMessage>

What i'm getting:

<PayloadAsMessage>
        onetwothree
</PayloadAsMessage>

Upvotes: 0

Views: 111

Answers (1)

wst
wst

Reputation: 11771

xsl:value-of takes the string value of an element (it's also XSLT, not XQuery). To copy the XML exactly, use either xsl:copy-of (XSLT 1) or xsl:sequence (XSLT2).

<xsl:copy-of select="/input/*"/>

or

<xsl:sequence select="/input/*"/>

Upvotes: 1

Related Questions