xsl-list
[Top] [All Lists]

Re: Re: [xsl] Multiple elements condition

2007-08-30 09:49:16
At 06:14 PM 8/29/2007, you wrote:
> But I might opt for note[count(para)=2] as it's both concise, and
> quite obvious.

It is, but someone is certainly going to build or have an XSLT 2.0
processor that counts all 1000000 para elements and then confirms that
1000000 is not equal to 2

Yes, I know.

This presents me with one of those problems that's both philosophical and practical. Do I code against the possibility of poor or naive XSLT engines, even when the legibility and hence maintainability of my code suffers as a consequence?

The answer: frequently, yes.

But often, there are other mitigating factors. For example, I may know that there will never be more than a few para elements. Or I may know that only a particular processor, which knows how to optimize such expressions, is being used. Or I may be writing a one-off, which I'll run just once or a few times, and if there are performance problems I can deal with them lazily.

(FWIW, I almost never have performance problems with my XSLT. I think that has more to do with the scenarios for which I write -- the scale of the documents and data sets -- than it does with the way I write.)

So here's my style question of the month. In XSLT 2.0, should I prefer:

exists(para[2]) and not(exists(para[3]))

or

exists(para[2]) and empty(para[3])

? Is there ever any difference in functionality? I think the first is marginally more legible, but maybe the second gets out of the gate a microsecond faster.

Cheers,
Wendell



======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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