xsl-list
[Top] [All Lists]

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

2010-06-14 04:58:19
2010/6/14 David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk>:

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.

--~------------------------------------------------------------------
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>
--~--