Description
The functx:wrap-values-in-elements function takes a sequence of atomic values and places each one inside an element with the name specified in $elementName .
The name must be specified as an xs:QName value. QNames can be constructed with calls to the xs:QName type constructor or the fn:QName function, as shown in the examples.
Arguments and Return TypeName | Type | Description |
$values |
xs:anyAtomicType* |
the values to wrap in elements |
$elementName |
xs:QName |
the name of the elements to construct |
return value |
element()* |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:wrap-values-in-elements
( $values as xs:anyAtomicType* ,
$elementName as xs:QName ) as element()* {
for $value in $values
return element {$elementName} {$value}
} ; |
Examplesdeclare namespace new = "http://newns"; |
XQuery Example | Results |
---|
functx:wrap-values-in-elements(
(1,2,3),
xs:QName('num')) |
<num>1</num>
<num>2</num>
<num>3</num> |
functx:wrap-values-in-elements(
(1,2,3),
xs:QName('new:num')) |
<new:num xmlns:new="http://newns">1</new:num>
<new:num xmlns:new="http://newns">2</new:num>
<new:num xmlns:new="http://newns">3</new:num> |
functx:wrap-values-in-elements(
(1,2,3),
QName('http://newns','num')) |
<num xmlns="http://newns">1</num>
<num xmlns="http://newns">2</num>
<num xmlns="http://newns">3</num> |
functx:wrap-values-in-elements(
(1,2,3),
QName('http://newns','new:num')) |
<new:num xmlns:new="http://newns">1</new:num>
<new:num xmlns:new="http://newns">2</new:num>
<new:num xmlns:new="http://newns">3</new:num> |
History |
Recommended Reading:
|