xsl-list
[Top] [All Lists]

Re: what does xsl:sort do if "select" doesn't evaluate to anything?

2003-03-18 23:07:44

"Robert P. J. Day" <rpjday(_at_)mindspring(_dot_)com> wrote in message
news:Pine(_dot_)LNX(_dot_)4(_dot_)44(_dot_)0303182306400(_dot_)26300-100000(_at_)dell(_dot_)(_dot_)(_dot_)

  what is the defined behavior for <xsl:sort> if the "select="
expression is not satisfied by anything?

  eg., i want to process a bunch of <car> elements, sorted by their
engine <displacement> values, but some of the <car> elements have no
such element?

If the "data-type" attribute of xsl:sort is "text" then:

For these elements the sort key "displacement" will evaluate to the empty
string. Depending on how a particular XSLT processor implements string
comparison in xsl:sort all "car" elements with no "displacement" children
will be sorted together (with "car" elements that have a "displacement" with
empty string value) as a group either preceding or following all "car"
elements, which have "dis[lacement" children with non-empty string value.

If the "data-type" attribute of xsl:sort is "number" then the value of the
sort key "displacement" will be NaN -- and they will be sorted again as a
group -- first or last depending on the implementation.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL





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