Difference between revisions of "XQuery Recipes"

From BaseX Documentation
Jump to navigation Jump to search
Line 12: Line 12:
 
</pre>
 
</pre>
  
The result is an element named "element":
+
The result is an XML fragment with <code>&lt;element&gt;</code> as root node:
 
<pre class="brush:xml">
 
<pre class="brush:xml">
 
<element about="hi">
 
<element about="hi">

Revision as of 01:31, 24 January 2011

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">
  <foo>Bar!</foo>
</element>