[xsl] distinguish whether variable holds string or node set

Subject: [xsl] distinguish whether variable holds string or node set
From: TW <zupftom@xxxxxxxxxxxxxx>
Date: Sun, 13 Jun 2010 09:51:50 +0200

sorry for the messed up message I sent from my other mail account.  I
should have known that it wouldn't work as I experienced this issue

Is there a way to determine whether a variable holds a string or a
node set? Something like:

<xsl:template name="my-template">
  <xsl:param name="arg"/>
    <xsl:when test="pseudo test: type($arg)='node-set'">Do something</xsl:when>
    <xsl:otherwise>Do something else</xsl:otherwise>

I've so far not been able to find an answer to this on the web and in
the archives. XPath makes it pretty hard with all the implicit type
conversion e.g. when testing equality. I hoped that any of the XPath
functions that expect a node set as an argument would maybe return an
empty string/node set or false when a string is passed as an argument,
but this will only stop processing with an error.

I'm looking for an XSLT 1.0 solution as I want it to work in browsers.

Thomas W.

Current Thread