Re: [xsl] Detecting item types within a sequence (XSLT2.0/XPath2.0)

Subject: Re: [xsl] Detecting item types within a sequence (XSLT2.0/XPath2.0)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 28 Oct 2004 16:31:50 +0100
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
exclude-result-prefixes="xs"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:xs="http://www.w3.org/2001/XMLSchema";>

<xsl:template match="/">
  <xsl:variable name="foo">
    <aaa>aaa</aaa>
    <aaa>bbb</aaa>
  </xsl:variable>
  <xsl:variable name="bar"
select="(xs:date('2004-10-30'), 1.1, 'A', $foo/*)"/>
  <output>
    <xsl:for-each select="$bar">
      <xsl:variable name="this" select="."/>
      <xsl:text>&#10;Item </xsl:text>
      <xsl:value-of select="position()"/>
      <xsl:text> </xsl:text>
      <xsl:choose>
 <xsl:when test=". instance of xs:integer">integer</xsl:when>
 <xsl:when test=". instance of xs:date">date</xsl:when>
 <xsl:when test=". instance of xs:decimal">decimal</xsl:when>
 <xsl:when test=". instance of xs:string">string</xsl:when>
 <xsl:when test=". instance of element()">element</xsl:when>
 <xsl:otherwise>something else</xsl:otherwise>
      </xsl:choose>

    </xsl:for-each>
    <xsl:text>&#10;</xsl:text>
  </output>
</xsl:template>
</xsl:stylesheet>

$ saxon8 type.xsl type.xsl
<?xml version="1.0" encoding="UTF-8"?><output>
Item 1 date
Item 2 decimal
Item 3 string
Item 4 element
Item 5 element
</output>


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread