xsl-list
[Top] [All Lists]

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

2019-11-07 12:49:48
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(_at_)fromoldbooks(_dot_)org 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 
Sent: Wednesday, November 6, 2019 1:04 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_dot_)flanders(_at_)baesystems(_dot_)com 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.delightfulcomputing.com%2F&amp;data=02%7C01%7Cwendell.piez%40nist.gov%7C9a278a4d477c4bd6fad608d762e3b664%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C1%7C637086602482501137&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.fromoldbooks.org&amp;data=02%7C01%7Cwendell.piez%40nist.gov%7C9a278a4d477c4bd6fad608d762e3b664%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C1%7C637086602482511129&amp;sdata=p8kAb9K08JYeVPglPRFYG5kSz%2F%2BRzJnaqnECnQMlIAM%3D&amp;reserved=0

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>