Created
May 21, 2012 10:52
-
-
Save micheee/2761801 to your computer and use it in GitHub Desktop.
Groups authors by author/name and returns all authors that have more than one distinct author/@id attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let $authors := | |
<authors> | |
<author id="a"><name>Foo</name>…whatever…</author> | |
<author id="b"><name>Foo</name>…whatever…</author> | |
<author id="a"><name>Foo</name>…whatever…</author> | |
<author id="c"><name>Bar</name>…whatever…</author> | |
<author id="d"><name>Bar</name>…whatever…</author> | |
<author id="f"><name>FooBar</name>…whatever…</author> | |
</authors> | |
return | |
<distinct-names> { | |
for $author in $authors//author | |
group by $name := $author/name | |
return | |
if(count(distinct-values($author/@id)) > 1) then | |
element {"author"} | |
{ | |
attribute {"name"} {$name}, | |
for $id in distinct-values($author/@id) | |
return <id>{$id}</id> | |
} | |
else () | |
}</distinct-names> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment