Re: [xsl] is there a way to hash an element?

Subject: Re: [xsl] is there a way to hash an element?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Jun 2016 09:48:12 -0000
On Mon, Jun 13, 2016 at 07:04:08AM -0000, Michael Kay mike@xxxxxxxxxxxx
scripsit:
> I agree with you, computing a hash and adding it as an attribute to
> the top level element, then grouping on the hash looks like a good
> strategy.

This is reassuring; thank you!

> I may have missed something in this thread, but I don't recall seeing
> a specification of your matching rules that is sufficiently precise to
> enable one to write a hash algorithm. We need to see a definition:
> "two elements A and B are considered to be the same if and only if
> they satisfy the following conditions: ....".

The matching rules are that A and B are considered to be the same if and
only if they have the same descendant elements in the same document
order with each element in A having associated with it the same
attributes and attribute values as the corresponding element in B.
(There aren't any descendant text nodes, comments, or processing
instructions.)

A and B are guaranteed to differ in terms of their attribute values (the
name and type attributes associated with the top-level element will have
different values) and might differ by which attributes are associated
with them (since there are some optional attributes).  I think but am
not certain that the optional attributes don't break the equivalence for
"what kind of complex type do you turn into when the schema finally gets
built" purposes.

Straight-up serializing the descendants works in terms of grouping like
with like, but the resulting value is impractically long for debugging
or being-sure-this-is-right purposes.  (and possibly efficient string
equivalence.)

Thanks!
Graydon

Current Thread