The answer to this question depends on which engine is used. For example, Saxon users, use the saxon:parse method.
The fact is that the XQuery specification has no built-in for this.
Generally speaking, you really will need to use this if you need to extract the embedded XML from the CDATA section. Otherwise, you can read files from the file system or declare XML directly.
For the most part, you should use a declarative form rather than a hard-coded string, for example. (using studio Stylus)
declare namespace my = "http://tempuri.org"; declare function my:foo($bar as node()*) as node() { <unimportant></unimportant> } ; let $bar := <node><child></child></node> return my:foo(bar)
source share