FYI: solved using parse-xml():

QueryProcessor query = new QueryProcessor("replace node . with parse-xml($replacement)", context);
query.bind("replacement", "<a>main(){int i=0;}</a>");



2013/10/18 Erdal Karaca <erdal.karaca.de@gmail.com>
Sorry, all, here is a more specific question:

The query is constructed at runtime and executed using the QueryProcessor command.

Query: replace node . with <a>main(){int i=0;}</a>
Execution error: Expecting '}' found ...

If I try to bind the replacement as a global parameter, the error message is: Single element, text, attribute, comment or pi expected as replace target.

The java code:

QueryProcessor query = new QueryProcessor("replace node . with $replacement", context);
query.bind("replacement", "<a>main(){int i=0;}</a>");

The problem with escpaing the curly braces (or wrapping all text content nodes and maybe attribute values, too) is the extra overhead which would decrease performance.



2013/10/18 Wendell Piez <wapiez@wendellpiez.com>
Erdal,

Escaping the curly braces by doubling them would be the "normal" way.
You ask for a better way; can you be more specific as to what needs to
be improved? Would this be an improvement?

let $expr := 'main(){int i=0;}'
let $x := doc(<a>{ $expr }</a>)
return ...

Cheers, Wendell
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^


On Fri, Oct 18, 2013 at 9:05 AM, Erdal Karaca <erdal.karaca.de@gmail.com> wrote:
> Hi all,
> How can I process this query in basex:
>
> let $x := doc(<a>main(){int i = 0;}</a>)
> return replace value of node $x with ""
>
>
> There are text contents that contain, for example, c code with curly braces
> which I do not want to be interpreted as embeded expressions.
>
> As a workaround I could escape the curly braces, But, is there a better
> way/option to suppress interpreting text contents that look like embedded
> expressions?
>
> Thanks!
>
>
> _______________________________________________
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk