Re: [xslt] Selecting on nodeset in variable from stylesheet



At 16:14 -0600 12/14/03, Shaun McCance wrote:
>On Sun, 2003-12-14 at 15:50, Elizabeth Mattijsen wrote:
>  > 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.

Well, that's just the problem (in my view): a node-set and a result 
tree fragment are basically the same thing in _my_ eyes.  To me, the 
difference is just as stupid as having a function that only functions 
on odd integers, and croaks on even integers.  I think I understand 
some of the artchitectural reasons behind the way it is in XSLT 1.0, 
but I think they impose a stupid limitation.  Computers are for doing 
your work: me, as a person of flesh and blood, having to keep track 
of what is a node-set and what is a result tree fragment, is _not_ 
very efficient.


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

I missed the existence of exslt:object-type.  Thanks for pointing 
that out.  It's nice to have if you want to create black box 
templates.  However, I can't believe there is no performance penalty 
for using it: I don't think you can have your cake and eat it too. 
But still, it allows you to get around this inherent limitation of 
XSLT 1.0.


Liz



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]