xsl-list
[Top] [All Lists]

Re: [xsl] XPath to find duplicate elements

2018-04-05 15:13:40
Dimitre, I am not sure whether I understand your two cents…
For each node you read, you have to compare all following nodes. How would you 
like to do that in the initial reading?

Yours
Leo


On 5 Apr 2018, at 20:15, Dimitre Novatchev dnovatchev(_at_)gmail(_dot_)com 
<mailto:dnovatchev(_at_)gmail(_dot_)com> 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com 
<mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>> wrote:

Just a thought on this.

If we can implement deep-equal($n1, $n2)  as calculating some
ValueIdentity (VI) for each of the nodes and returning

    VI1 eq VI2 ...

Then the VIs for each node can be calculated on the initial reading of
the XML document (even in streaming mode) with almost no additional
effort. If these VIs are made properties of the nodes, then we could
just compare the VIs of the nodes and avoid any repeated zip-like
comparison of the subtrees that are topped by these nodes. And this
also seems more declarative/functional.

Just my 2c.

Cheers,
Dimitre


let $xml := <a>
                <b>
                    <c>1</c>
                    <d>1</d>
                    <d>2</d>
                </b>
                <b>
                    <c>2</c>
                    <d>1</d>
                    <d>3</d>
                </b>
                <b>
                    <c>3</c>
                    <d>2</d>
                    <d>3</d>
                </b>
                <b>
                    <c>3</c>
                    <d>2</d>
                    <d>3</d>
                </b>
            </a>
            return
--~----------------------------------------------------------------
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>