Difference between revisions of "XQuery Recipes"
Jump to navigation
Jump to search
(→Computed Elements: Added return value of the example) |
|||
| Line 1: | Line 1: | ||
This page contains code snippets that mainly originate from our [https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk Mailing List]. | This page contains code snippets that mainly originate from our [https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk Mailing List]. | ||
| + | |||
== Computed Elements == | == Computed Elements == | ||
Returns dynamically named elements: | Returns dynamically named elements: | ||
| Line 5: | Line 6: | ||
let $class := "hi" | let $class := "hi" | ||
let $contents :=<foo><br />Bar!</foo> | let $contents :=<foo><br />Bar!</foo> | ||
| − | return element {$name} { | + | return element { $name } { |
| − | attribute { "about" } {$class}, $contents | + | attribute { "about" } { $class }, $contents |
} | } | ||
</pre> | </pre> | ||
| Line 16: | Line 17: | ||
</Element1> | </Element1> | ||
</pre> | </pre> | ||
| + | |||
[[Category:XQuery]] | [[Category:XQuery]] | ||
| − | |||
Revision as of 02:29, 24 January 2011
This page contains code snippets that mainly originate from our Mailing List.
Computed Elements
Returns dynamically named elements:
let $name:= "Element1"
let $class := "hi"
let $contents :=<foo><br />Bar!</foo>
return element { $name } {
attribute { "about" } { $class }, $contents
}
The result is an element named "Element1":
<Element1 about="hi">
<foo>
<br/>Bar!</foo>
</Element1>