Skip to content

Instantly share code, notes, and snippets.

@fordmadox
Last active August 29, 2015 14:03
Show Gist options
  • Save fordmadox/1f351f6b191c8d3d1f31 to your computer and use it in GitHub Desktop.
Save fordmadox/1f351f6b191c8d3d1f31 to your computer and use it in GitHub Desktop.
xquery version "3.0";
declare namespace ead="urn:isbn:1-931666-22-9";
declare namespace xlink = "http://www.w3.org/1999/xlink";
<results>
{
for $ead in ead:ead
let $doc := base-uri($ead)
return
<document uri="{$doc}">
{
for $note in $ead//ead:dsc//ead:note
let $parent-notes := $note/parent::ead:*/parent::ead:*/ead:note
for $p in $parent-notes
let $xpath := replace(path($p),'\[1\]','')
let $xpathNS := replace($xpath, 'Q\{urn:isbn:1-931666-22-9\}', 'ead:')
let $duplicate-test := deep-equal($note, $p)
return
<note duplicate-parent="{$duplicate-test}">
{
if ($duplicate-test eq true())
then element {'path-to-parent'} {$xpathNS}
else ()
}
</note>
}
</document>
}
</results>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment