Subject: un escape text to use as fragment
Posted By: brenchley Post Date: 12/13/2005 8:23:34 AM
I have this xml

<?xml version="1.0" encoding="UTF-8"?>
<doc>
    <INDXES> &lt;indexes&gt;&lt;scro_number&gt;S29811/94Q&lt;/scro_number&gt; &lt;subject_surname&gt;DICKIE&lt;/subject_surname&gt;&lt;keywords&gt;DICKIE&lt;/keywords&gt;&lt;case_number&gt;BA05001553&lt;/case_number&gt;&lt;office_code&gt;BA&lt;/office_code&gt;&lt;date_of_receipt&gt;2005-10-07&lt;/date_of_receipt&gt;&lt;witness_seq_no&gt;1&lt;/witness_seq_no&gt;&lt;/indexes&gt;</INDXES>
</doc>

as the text between <INDXES></INDXES> is valid xml with the angle brackets encoded it should be possible to use the un-encoded text as a node or node fragment.
Assigning the value to a variable with disable-output-escaping="yes" doesn't seem to work.

Can anyone help?

Reply By: mhkay Reply Date: 12/13/2005 9:25:42 AM
The best advice is to avoid getting into this mess in the first place. The idea of &lt; and &gt; is that they should be used for escaping angle brackets that aren't being used for markup; if you use them for angle brackets that *do* represent markup then you're creating problems for yourself.

By "unescaping" you actually mean parsing. You need to pass the string (the content of the INDXES element) to an XML parser to construct a tree. In Saxon you can do this with the saxon:parse() extension; in other processors you can do it with your own extension function.

Another solution is to serialize the whole document, using disable-output-escaping="yes" for the relevant text node, and then reparse the whole thing.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

Go to topic 37575

Return to index page 417
Return to index page 416
Return to index page 415
Return to index page 414
Return to index page 413
Return to index page 412
Return to index page 411
Return to index page 410
Return to index page 409
Return to index page 408