home contribute faq download

FunctX XSLT Functions

functx:atomic-type

The built-in type of an atomic value

Google
Webxsltfunctions.com

Description

The functx:atomic-type function checks the types of one or more atomic values and returns their type names. It will only work for built-in atomic types; if the value has a user-defined atomic type, the function will return the built-in type upon which the user-defined type is based. If $values is the empty sequence, it will return "empty sequence".

Arguments and Return Type

NameTypeDescription
$values xs:anyAtomicType* the value(s) whose type you want to determine
return value xs:string*

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:atomic-type" as="xs:string*"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="values" as="xs:anyAtomicType*"/>

  <xsl:sequence select="
 for $val in $values
 return
 (if ($val instance of xs:untypedAtomic) then 'xs:untypedAtomic'
 else if ($val instance of xs:anyURI) then 'xs:anyURI'
 else if ($val instance of xs:string) then 'xs:string'
 else if ($val instance of xs:QName) then 'xs:QName'
 else if ($val instance of xs:boolean) then 'xs:boolean'
 else if ($val instance of xs:base64Binary) then 'xs:base64Binary'
 else if ($val instance of xs:hexBinary) then 'xs:hexBinary'
 else if ($val instance of xs:integer) then 'xs:integer'
 else if ($val instance of xs:decimal) then 'xs:decimal'
 else if ($val instance of xs:float) then 'xs:float'
 else if ($val instance of xs:double) then 'xs:double'
 else if ($val instance of xs:date) then 'xs:date'
 else if ($val instance of xs:time) then 'xs:time'
 else if ($val instance of xs:dateTime) then 'xs:dateTime'
 else if ($val instance of xs:dayTimeDuration)
         then 'xs:dayTimeDuration'
 else if ($val instance of xs:yearMonthDuration)
         then 'xs:yearMonthDuration'
 else if ($val instance of xs:duration) then 'xs:duration'
 else if ($val instance of xs:gMonth) then 'xs:gMonth'
 else if ($val instance of xs:gYear) then 'xs:gYear'
 else if ($val instance of xs:gYearMonth) then 'xs:gYearMonth'
 else if ($val instance of xs:gDay) then 'xs:gDay'
 else if ($val instance of xs:gMonthDay) then 'xs:gMonthDay'
 else 'unknown')
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:atomic-type(2)
xs:integer
functx:atomic-type('abc')
xs:string
functx:atomic-type(xs:date('2005-12-15'))
xs:date
functx:atomic-type(
   (2,'abc',xs:date('2005-12-15')))
('xs:integer',
 'xs:string',
 'xs:date')

History

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

Recommended Reading:

XQuery