[Monetdb-developers] Q: pathfinder output of CDATA

Jens Teubner jens.teubner at in.tum.de
Wed Jan 3 09:43:06 CET 2007


On Wed, Jan 03, 2007 at 12:09:44AM +0100, Arjen P. de Vries wrote:

> With bzv.xq:
> <abstract><![CDATA[Kijkers van het populaire programma <i>Boer zoekt
> vrouw</i>]]></abstract>
> as query,
> 
> I get result MapiClient -lx bzv.xq
> 
> <?xml version="1.0" encoding="utf-8"?>
> <XQueryResult><abstract>Kijkers van het populaire programma
> <i>Boer zoekt vrouw</i></abstract></XQueryResult>
> 
> How do I get the <i> instead of <i>?
> (I know how to do this with fn:replace, but guess there must be an
> output directive?)

Hi Arjen,

this is expected behavior.  XML/XQuery's CDATA construct is syntactic
sugar that can be used to avoid lots of escaping with entity references.
So

  <foo><![CDATA[bar]]></foo>

and

  <foo>bar</foo>

are exactly the same thing in XML.  But within CDATA sections, you don't
have to escape any special character.

  <foo><![CDATA[foo & bar]]></foo>

and

  <foo>foo & bar</foo>

are, again, the exact same thing in XML.  Similarly, you can write angle
brackets within CDATA sections without escaping them.

What you probably want in your case is not to use CDATA at all, but just
regular XML content, i.e.,

<abstract>Kijkers van het populaire programma <i>Boer zoekt vrouw</i></abstract>


By the way, you can *not* avoid the escaping of angle brackets with
fn:replace.  Written as a string in the C programming language, e.g.,
the content of your original <abstract> element is

 "Kijkers van het populaire programma <i>Boer zoekt vrouw</i>"

(no "<" involved here).  Upon serialization to XML, however, angle
brackets need to be escaped, with the output you observed.  Note that
you could construct illegal XML otherwise.

Regards from Bavaria

Jens

-- 
Jens Teubner
Technische Universitaet Muenchen, Department of Informatics
D-85748 Garching, Germany
Tel: +49 89 289-17259     Fax: +49 89 289-17263

Please avoid sending me MS Word, MS Excel or MS PowerPoint files.
Why? See http://www.fsf.org/philosophy/no-word-attachments.html




More information about the developers-list mailing list