I have an XML document that needs to pass text inside an element with an '&' in it.
This is called from .NET to a Web Service and comes over the wire with the correct encoding &
e.g.
T&O
I then need to use XSLT to create a transform but need to query SQL server through a SP without the encoding on the Ampersand e.g T&O would go to the DB.
(Note this all has to be done through XSLT, I do have the choice to use .NET encoding at this point)
Anyone have any idea how to do this from XSLT?
Note my XSLT knowledge isn’t the best to say the least!
Cheers
Supposing your XML looks like this:
you can use this XSLT snippet to get the text out of it:
Output (from Saxon 9, that is):
The point is the
<xsl:output/>
element. The defauklt would be to output XML, where the ampersand would still be encoded.More info at: http://www.w3schools.com/xsl/el_text.asp
If you have the choice to use .NET you can convert between an HTML-encoded and regular string using (this code requires a reference to System.Web):
Update
Since you need to do this in plain XSLT you can use
xsl:value-of
to decode the HTML encoding:The variable
string($test)
will have the valueT&O
. You can pass this variable as an argument to your extension function then.