Re: [xslt] Selecting on nodeset in variable from stylesheet
- From: Shaun McCance <shaunm wolfram com>
- To: xslt gnome org
- Subject: Re: [xslt] Selecting on nodeset in variable from stylesheet
- Date: Sun, 14 Dec 2003 16:14:07 -0600
On Sun, 2003-12-14 at 15:50, Elizabeth Mattijsen wrote:
> At 15:30 -0600 12/14/03, Shaun McCance wrote:
> >The whole node set vs. result tree issue always confuses beginners, and
> >understandably so. Here's the basic rule: An XPath expression inside
> >of a select attribute gives you a node set (except, of course, when it
> >gives you a number or something else). A template always gives you a
> >result tree fragment. If you variable looks like this:
> >
> ><xsl:variable name="foo" select="some/xpath/expression"/>
>
> Ok, fine. But if you're inside a called template with parameters,
> and that template is called with a variable as a parameter, how are
> you going to know inside the template whether the variable refers to
> a result tree or a node-set?
Most XSLT programmers structure their stylesheets so that any particular
parameter always gets the same type of thing. I mean, this is really
the same questions as "How do you know if the parameter is a node-set or
a number?" You just keep track of what your templates are doing.
If you really, really, really need to do different things based on what
kind of thing was passed as a parameter, then EXSLT provides a function
for that as well. As with any extension function, you should give some
serious thoughts to portability concerns. The advantage of EXSLT, of
course, is that you get better portability than if each XSLT processor
just did its own set of extensions.
In the case of exsl:object-type, portability is the only real concern.
Unlike exsl:node-set, it doesn't impose a performance penalty, and it
doesn't lead to any confusion. It's a pretty simple extension, and if
you need it, by all means use it.
--
Shaun
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]