XQuery Recipes

From BaseX Documentation
Revision as of 01:32, 24 January 2011 by CG (talk | contribs)
Jump to navigation Jump to search

This page contains code snippets that mainly originate from our basex-talk mailing list.

Computed Elements

Returns dynamically named elements:

let $root := "element"
let $value := "hi"
let $contents := <foo>Bar!</foo>
return element { $root } {
  attribute { "about" } { $value }, $contents
}

The result is an XML fragment with <element> as root node:

<element about="hi">
  <foo>Bar!</foo>
</element>