celina
celina

Reputation: 1

Escape special characters in XQuery or XSLT

I have an xml that has uname and pwd. The pwd has special characters like ‘&’.

I am using a XQuery or XSLT to transform it.. the output generated should have exact password and not &.

Is there a way I can do that?

<uname>xyz</uname>
<pwd>12a&ad&12</pwd>

Output after transformation should exactly same

(I am doing this in OSB, so when I test through OSB it doesn't allow me to, so I am using SoapUI to validate ut, but at the first stage itself it fails to handle it)

Can someone please guide me with the escaping special characters or XQuery or XSLT functions for this

Thanks

Upvotes: 0

Views: 632

Answers (1)

Michael Kay
Michael Kay

Reputation: 163322

XQuery and XSLT are both designed for processing well-formed XML, and your input is not well-formed XML, so it cannot be processed using these languages. To make it well-formed XML, it needs to be written

<data>
  <uname>xyz</uname>
  <pwd>12a&amp;ad&amp;12</pwd>
</data>

Similarly, the output will always be well-formed XML.

Upvotes: 1

Related Questions