|
Subject: [xsl] XPath to find duplicate elements From: "Leo Studer leo.studer@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 5 Apr 2018 16:11:53 -0000 |
Hello
I have an xml file where I need and XPath expression to find all elements that
are a copy of a previous element in the same file.
I came up with the following:
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
$xml//*[let $node1 := . return some $node2 in $xml//*[. << $node1] satisfies
deep-equal($node1,$node2)]/(ancestor-or-self::node()/concat(node-name(.),1+co
unt(preceding-sibling::*)),' ')
which gives
a1 b2 d2
a1 b3 d2
a1 b3 d3
a1 b4
a1 b4 c1
a1 b4 d2
a1 b4 d3
This is actually not to bad. However, I would like the correct position of the
copy. Instead of preceding-sibling::* in the count() function, I would like to
write something like preceding-sibling::element(node-name(.)). Unfortunately
the processor does not allow that ;-(b&
Any suggestions?
Thanks in advance
Leo
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] collection is not working, Mukul Gandhi gandhi. | Thread | Re: [xsl] XPath to find duplicate e, Martin Honnen martin |
| Re: [xsl] collection is not working, Mukul Gandhi gandhi. | Date | Re: [xsl] XPath to find duplicate e, Martin Honnen martin |
| Month |