[xquery-talk] Outputting CDATA Sections

Michael Kay mhk at mhk.me.uk
Tue Jul 12 18:26:10 PDT 2005


> I'd like to output something like
> 
> <svg>
>    <defs>
>       <style type="text/css">
>          <![CDATA[
>             rect {stroke:black;}
>             circle {stroke-width:1;}
>          ]]>
>       </style>
>    </defs>
> </svg>
> 
> 
> The Question is How?

The first Question is Why?

Are you really using software that treats this differently from

<svg>
>    <defs>
>       <style type="text/css">
>             rect {stroke:black;}
>             circle {stroke-width:1;}
>       </style>
>    </defs>
> </svg>

?

With Saxon, you can however achieve something close to this output (with the
CDATA section) by using

!cdata-section-elements=style

on the command line, or the equivalent in the Java API. (If "style" is in a
namespace, it has to be 
"{uri}style")

Michael Kay
http://www.saxonica.com/



More information about the talk mailing list