Difference between revisions of "XQuery Recipes"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
Returns dynamically named elements: | Returns dynamically named elements: | ||
<pre class="brush:xquery"> | <pre class="brush:xquery"> | ||
− | let $ | + | let $root := "element" |
− | let $ | + | let $value := "hi" |
let $contents := <foo>Bar!</foo> | let $contents := <foo>Bar!</foo> | ||
− | return element { $ | + | return element { $root } { |
− | attribute { "about" } { $ | + | attribute { "about" } { $value }, $contents |
} | } | ||
</pre> | </pre> |
Revision as of 02:32, 24 January 2011
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>