EXSLT - exsl:object-type

Implementer Page: exsl.object-type.html
Function Package: exsl.object-type.zip

Function Syntax

string exsl:object-type(object)

The exsl:object-type function returns a string giving the type of the object passed as the argument. The possible object types are: 'string', 'number', 'boolean', 'node-set', 'RTF' or 'external'.

Most XSLT object types can be coerced to each other without error. However, there are certain coercions that raise errors, most importantly treating anything other than a node set as a node set. Authors of utilities such as named templates or user-defined extension functions may wish to give some flexibility in the parameter and argument values that are accepted by the utility; the exsl:object-type function enables them to do so.

Implementations

The following XSLT processors support exsl:object-type:

There are currently no third-party implementations of exsl:object-type.

Examples

Function

The following example shows how to use the exsl:object-type function:

Source

<doc />

Stylesheet

<!--  Test exslt:object-type  -->
<xsl:variable name="tree">
   <a>
      <b>
         <c>
            <d />
         </c>
      </b>
   </a>
</xsl:variable>
<xsl:variable name="string"
              select="'fred'" />
<xsl:variable name="number"
              select="93.7" />
<xsl:variable name="boolean"
              select="true()" />
<xsl:variable name="node-set"
              select="//*" />
<xsl:template match="/">
   <out>
:
          <xsl:value-of select="exslt:object-type($string)" />
;
          <xsl:value-of select="exslt:object-type($number)" />
;
          <xsl:value-of select="exslt:object-type($boolean)" />
;
          <xsl:value-of select="exslt:object-type($node-set)" />
;
          <xsl:value-of select="exslt:object-type($tree)" />
;
          <xsl:if test="function-available('saxon:expression')"
              xmlns:saxon="http://icl.com/saxon">
         <xsl:value-of select="exslt:object-type(saxon:expression('item'))" />
      </xsl:if>
;                    
  
   </out>
</xsl:template>

Result

<out xmlns:exslt="http://exslt.org/common">:
    string;
    number;
    boolean;
    node-set;
    RTF;
    external;                    
  </out>

http://www.exslt.org/exsl/functions/object-type/index.html last modified 2002-11-12