Re: [xsl] compare two nodes (the child elements, not the string values) in XSLT 1.0

Subject: Re: [xsl] compare two nodes (the child elements, not the string values) in XSLT 1.0
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 07 Jul 2011 12:00:39 -0400
Dear Wolfhart,

On 7/7/2011 12:55 AM, Wolfhart Totschnig wrote:
For my particular case, I found a less complicated solution than
Wendell's, but it's a particular solution, not a general one:

<xsl:variable name="last" select="last"/>
<xsl:if test="path/person/last=last and (not(first) or
path/person[last=$last]/first=first) and (not(middle) or
path/person[last=$last]/middle=middle)">

Yes, but that will fail if you have two persons, one with the same last and first names and another with the same last and middle names ...


The reason this is hard is that "equality" for node comparison purposes is impossible to specify adequately for the general case (largely but not entirely due to whitespace-related issues), so even a good general definition (such as in 2.0 deep-equal()) is only somewhat useful. So more powerful means have to be applied.

I am amazed that there is no simple general solution for this kind of
problem in XSLT 1.0. I thought I must be overlooking something obvious.
XSLT 2.0 indeed makes life easier!

I think part of the reason why XSLT 1.0 was so successful was that they limited the scope to a set of problems already well understood, deliberately leaving it to be filled out later. If they had tried to be more comprehensive and general, they might well have botched it. (Plus, we wouldn't have the useful alignment with XQuery as well as other advantages.)


In other words, XSLT 2.0 is the correct approach even from the XSLT 1.0 point of view.

Cheers, Wendell

--
======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
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
======================================================================

Current Thread