[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Detecting item types within a sequence (XSLT2.0/XPath2

Subject: Detecting item types within a sequence (XSLT2.0/XPath2.0)
From: Colin Granger <colgranger@xxxxxxxxxxx>
Date: Thu, 28 Oct 2004 16:13:08 +0100 (BST)
colin granger
Hi,

Sequences can contain mixed item types, but is there
any way of detecting the item type of each item within
a sequence in XSLT2.0/XPath2.0/XQuery?

For example, in XSLT2.0...

<?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> of sequence is... </xsl:text>
      <!-- detect item type here?  is this a
node/attribute/document/namespace or a simple type??
-->
    </xsl:for-each>
    <xsl:text>&#10;</xsl:text>
  </output>
</xsl:template>
</xsl:stylesheet>

the output I'd like to obtain would be someting
like...

<output>
Item 1 of sequence is a... xs:date
Item 2 of sequence is... xs:decimal
Item 3 of sequence is... xs:string
Item 4 of sequence is... a node of some kind
Item 5 of sequence is... a node of some kind
</output>

or at least...

<output>
Item 1 of sequence is... not a node of any kind
Item 2 of sequence is... not a node of any kind
Item 3 of sequence is... not a node of any kind
Item 4 of sequence is... a node of some kind
Item 5 of sequence is... a node of some kind
</output>

Many Thanks
Colin


Send instant messages to your online friends http://uk.messenger.yahoo.com 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.