Re: [xsl] distinguish whether variable holds string or node set

Subject: Re: [xsl] distinguish whether variable holds string or node set
From: TW <zupftom@xxxxxxxxxxxxxx>
Date: Mon, 14 Jun 2010 11:57:50 +0200
2010/6/14 David Carlisle <davidc@xxxxxxxxx>:
> If you are needing to test the types for some other reason, rather than ask
> how to test the types, you should ask yourself why your template is being
> called with the parameter set to different types.

My example was made up, I really don't have a template that has to
check a parameter type.  What I have is a template that evaluates a
very, very tiny subset of XPath for addressing nodes.  I know, an eval
function is also in EXSL, but I also want some special behavior when
the XPath snippet "points to" a non-existent attribute node.  If
attributes are present, they have a static value, if not, they get a
calculated "dynamic" value depending on context (when accessed using
the mentioned template).

I can't return such a fake attribute as an attribute node, it will be
a string or a number.  What I'm tackling is further processing the
mixture of nodes and strings that this template produces.  But I think
I can change things so that I can safely interpret everything that's
produced by the template as a string.  I could also have a plan-A
template, and if this returns an empty nodeset, I go with a plan-B
template.  I would know that plan-A returns a node set, plan-B a
string.  The result of plan-A could serve as a test for switches that
I may have to build in.

Thanks for your suggestions

Thomas W.

Current Thread