[xsl] Re: Re: Default attribute value templates

Subject: [xsl] Re: Re: Default attribute value templates
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 28 Jun 2001 03:58:55 -0700 (PDT)
Trevor Nash wrote:

> Thanks to Mike Kay and Dimitre Novatchev for their answers addressing
> the example given.  The bottom line seems to be that using AVTs for
> xsl elements which have defaults is a tricky business.
> My example was over simplified: I want all the attributes of xsl:sort
> (except "select" which is another problem entirely) not just 'order'.


> Yes, thats the sort of thing I had in mind.  The problem is xsl:sort
> has four attributes which take AVTs, which makes 16 xsl:whens and 16
> copies of the xsl:apply-templates which could have all sorts of other
> stuff like modes, selects, with-params etc.  Bad news for maintenance
> and testing.  If we use Mike's method where it applies this comes down
> to 4, but its still uglier than I like.
> I think I will do two passes: the first to generate a stylesheet with
> the right xsl:sort in it, then a second to apply it.  This lets me
> parameterise 'select' as well, and with a change to the way 'x' is
> defined allow more than one sort key.

In all complicated cases of using xsl:sort I'd strongly recommend to use the generic
sort() template (see http://www.vbxml.com/downloads/default.asp?id=v2001611171627 )

It is not dependent on and limited by any particular way of defining or comparing
the sort keys -- because this is done in a caller-supplied "compare"-template.

The benefits of using a generic sort template are:

  - conceptual simplicity.
  - maximum reusability.
  - no limitations.
  - less error-prone.
  - less time consuming to program.
  - more efficient than a multi-pass algorithm.

Dimitre Novatchev.

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread