Re: [xsl] Comparing node-sets or groups. Deep-equal with an exception?

Subject: Re: [xsl] Comparing node-sets or groups. Deep-equal with an exception?
From: "Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Nov 2019 18:49:42 -0000
Hi,

Another approach is to bind your signature (aka fingerprint) to your elements
using a key declaration, then use an old-fashioned key-based test to see to it
you get only one of each. This can even work under XSLT 1.0, at least if your
signature logic is not too bad.

Cheers, Wendell

-----Original Message-----
From: Liam R. E. Quin liam@xxxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, November 6, 2019 1:04 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Comparing node-sets or groups. Deep-equal with an
exception?

On Wed, 2019-11-06 at 14:50 +0000, Flanders, Charles E (US)
charles.flanders@xxxxxxxxxxxxxx wrote:
> I have a long list of <mac-group-2lvl>  structures as below. Most are
> unique. However in some cases, they are identical except for the "ref"
> attribute value on the <teref>  element.

One approach:

So, you can easily identify the ones you need to process differently:

1/ if they are identical, then deep-equal will be true.

2/ make an identity template and a template that will set the ref attribute to
"marmaduke", use a mode (since XSLT 2 doesn't have fn:transform), and then use
deep-equal

3/ encapsulate this in an XSLT function, and now you can write an xsl:choose
with test="my:i-need-to-update-ref-attribute(., $other):"

4/ the xsl:choose would ignore the following siblings that are already
processed in the earlier case (or write a recursive template or function that
consumes one or more structures each time round).


Liam

--
Liam Quin,
https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.delight
fulcomputing.com%2F&amp;data=02%7C01%7Cwendell.piez%40nist.gov%7C9a278a4d477c
4bd6fad608d762e3b664%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C1%7C63708660248
2501137&amp;sdata=E%2FMa0LbH1Bx4LPSQ%2BD2xSUtziWgSr8CkGG5c%2B%2FGmlBU%3D&amp;
reserved=0
Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text
Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:
https://gcc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.fromoldb
ooks.org&amp;data=02%7C01%7Cwendell.piez%40nist.gov%7C9a278a4d477c4bd6fad608d
762e3b664%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C1%7C637086602482511129&amp
;sdata=p8kAb9K08JYeVPglPRFYG5kSz%2F%2BRzJnaqnECnQMlIAM%3D&amp;reserved=0

Current Thread