home contribute faq download

FunctX XSLT Functions

functx:wrap-values-in-elements

Wraps a sequence of atomic values in XML elements

Google
Webdatypic.com

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 Type

NameTypeDescription
$values xs:anyAtomicType* the values to wrap in elements
$elementName xs:QName the name of the elements to construct
return value element()*

XSLT Function Declaration

See 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 ExampleResults
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

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, https://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery