XQuery Recipes

From BaseX Documentation
Revision as of 01:31, 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 $name:= "element"
let $class := "hi"
let $contents := <foo>Bar!</foo>
return element { $name } {
  attribute { "about" } { $class }, $contents

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

<element about="hi">