On Mon, 2013-12-02 at 15:29 -0500, Erol Akarsu wrote:
I would like to generate CDATA of one xmk construct like this.
[...]
let $allfs := <record> <name>{$name}</name> <features> <![CDATA[ <h3>Features:</h3> <br/> <ul> <li>{$f1}</li> <li>{$f2}</li> <li>{$f3}</li> </ul> ]]> </features> </record>
Watch out that if $f1 (say) contains the string ]]> you'd be liable to a cdata injection attack.
Having said that, no, I'd probably write an e() function, declare function my:e($name as xs:string, $content as xs:string) as xs:string { return concat("<", $name, ">", $content, "</", $name, ">") }
and use my:e("ul", concat(my:e("li", $f1), my:e("li", $f2), my:e("li", $f3)) and so on. Which gives you slightly more checking.
The implementation will probably generate < and > rather than CDATA; XML says they're equivalent.
In XQuery 3 there's a per-element serialization option for CDATA sections, http://www.w3.org/TR/xslt-xquery-serialization-30/#XML_CDATA-SECTION-ELEMENT... so if BaseX implements that you have a way to get closer to what you want, perhaps, e.g. for generating RSS. However, you'd still need to construct a string containing "<h1>" etc.
Liam