Re: [XQuery] Computed CDATA constructor

At 02:23 PM 11/11/2003, Sarah Wilkin wrote:

>On Nov 11, 2003, at 6:37 AM, Jonathan Robie wrote:
>
>>So in XQuery, the purpose of a computed CDATA constructor would be to 
>>escape text that contains characters which would otherwise be recognized 
>>as markup. But for computed text, I can't think of any context in which a 
>>computed CDATA constructor is needed for this. Some people think of CDATA 
>>sections as the boundaries for code examples, but you should use elements 
>>for that.
>
>I appreciate the reasoning here. However, simply because a person *should* 
>use elements for something does not mean they will. XQuery should be a 
>first class citizen for working with XML, yet small issues like this make 
>it an unacceptable solution for creating generic XML documents. It's 
>unfortunate that this is not a requirement of XQuery, as in general 
>creating XML with XQuery is much easier and faster than other programatic 
>methods.

I don't really see a problem with the approach XQuery uses here. Suppose I 
write a document that looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <eg><![CDATA[<?xml version="1.0" encoding="utf-8"?>]]></eg>

Now you do a query on the eg element, and get the following result:

    <eg>&lt;?xml version="1.0" encoding="utf-8"?&gt;</eg>

Any XML parser understands what that means, and any experienced XML user 
should know that the two are equivalent. Why is this problematic?

Jonathan 

Received on Tuesday, 11 November 2003 17:27:10 UTC