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()* |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:wrap-values-in-elements" as="element()*"
xmlns:functx="http://www.functx.com">
<xsl:param name="values" as="xs:anyAtomicType*"/>
<xsl:param name="elementName" as="xs:QName"/>
<xsl:for-each select="$values">
<xsl:element name="{$elementName}"
namespace="{namespace-uri-from-QName($elementName)}">
<xsl:sequence select="."/>
</xsl:element>
</xsl:for-each>
</xsl:function>
|
Examples<xsl:stylesheet xmlns:new="http://newns">... |
XPath 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:
|