|
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> <indexes><scro_number>S29811/94Q</scro_number> <subject_surname>DICKIE</subject_surname><keywords>DICKIE</keywords><case_number>BA05001553</case_number><office_code>BA</office_code><date_of_receipt>2005-10-07</date_of_receipt><witness_seq_no>1</witness_seq_no></indexes></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 < and > 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
|