2010/6/13 David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>:
On 13/06/2010 08:51, TW wrote:
Is there a way to determine whether a variable holds a string or a
node set? Something like:
no in xslt 1 all you can do is a static analysis of all teh places where
your template is called and see if it is called with the smae type always=
.
So I can at least console myself I wasn't too dumb to find the solution ;-).
<xsl:template name=3D"my-template">
<xsl:param name=3D"arg"/>
Note that makes the default value an epty string which is dangerous if the
value passed in is going to be a node set and you want to do $arg/some/path.
Safer is to declare it as
<xsl:param name=3D"arg" select=3D"/.."/>
so the default value is a (empty) node set and then it is safe to do
$arg/some/path
without having to test the type, so long as you always pass in a node set.
Thanks for the advice. I'm not sure what you consider "safe"? I
would rather want the transformation to fail than to cover possible
flaws (like missing or misspelled template parameters). Or did I
misunderstand you?
Martin Honnen wrote:
ESLT has object-type
http://www.exslt.org/exsl/functions/object-type/inde=x.html
Yes, but I'd still rather stick to the standard. If I can't determine
the type, then I'll have to take some other route to get where I want
to get. To properly learn XSLT I'll probably best learn how to cope
with its limitations as well.
Thanks for your kind help
Thomas W.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--