I have this XML file
<?xml version="1.0"?>
<ns0:personas xmlns:ns0="http://www.personas.com">
<ns0:persona>
<ns0:idee>idee_1</ns0:idee>
<ns0:nss>nss_1</ns0:nss>
<ns0:curp>curp_1</ns0:curp>
<ns0:rfc>rfc_1</ns0:rfc>
<ns0:nombre>nombre_1</ns0:nombre>
<ns0:apellido-paterno>apellido-paterno_1</ns0:apellido-paterno>
<ns0:apellido-materno>apellido-materno_1</ns0:apellido-materno>
<ns0:agregado-medico>agregado-medico_1</ns0:agregado-medico>
<ns0:agregado-afiliacion>agregado-afiliacion_1</ns0:agregado-afiliacion>
</ns0:persona>
<ns0:persona>
<ns0:idee>idee_1</ns0:idee>
<ns0:nss>nss_1</ns0:nss>
<ns0:curp>curp_1</ns0:curp>
<ns0:rfc>rfc_1</ns0:rfc>
<ns0:nombre>nombre_1</ns0:nombre>
<ns0:apellido-paterno>apellido-paterno_1</ns0:apellido-paterno>
<ns0:apellido-materno>apellido-materno_1</ns0:apellido-materno>
<ns0:agregado-medico>agregado-medico_1</ns0:agregado-medico>
<ns0:agregado-afiliacion>agregado-afiliacion_1</ns0:agregado-afiliacion>
</ns0:persona>
<ns0:persona>
<ns0:idee>idee_1</ns0:idee>
<ns0:nss>nss_1</ns0:nss>
<ns0:curp>curp_1</ns0:curp>
<ns0:rfc>rfc_1</ns0:rfc>
<ns0:nombre>ramon</ns0:nombre>
<ns0:apellido-paterno>apellido-paterno_1</ns0:apellido-paterno>
<ns0:apellido-materno>apellido-materno_1</ns0:apellido-materno>
<ns0:agregado开发者_JAVA百科-medico>agregado-medico_1</ns0:agregado-medico>
<ns0:agregado-afiliacion>agregado-afiliacion_1</ns0:agregado-afiliacion>
</ns0:persona>
</ns0:personas>
I'd like to remove all the elements which is not repeated. For example the wished outcome from the above xml example should be:
<?xml version="1.0"?>
<ns0:personas xmlns:ns0="http://www.personas.com">
<ns0:persona>
<ns0:idee>idee_1</ns0:idee>
<ns0:nss>nss_1</ns0:nss>
<ns0:curp>curp_1</ns0:curp>
<ns0:rfc>rfc_1</ns0:rfc>
<ns0:nombre>nombre_1</ns0:nombre>
<ns0:apellido-paterno>apellido-paterno_1</ns0:apellido-paterno>
<ns0:apellido-materno>apellido-materno_1</ns0:apellido-materno>
<ns0:agregado-medico>agregado-medico_1</ns0:agregado-medico>
<ns0:agregado-afiliacion>agregado-afiliacion_1</ns0:agregado-afiliacion>
</ns0:persona>
<ns0:persona>
<ns0:idee>idee_1</ns0:idee>
<ns0:nss>nss_1</ns0:nss>
<ns0:curp>curp_1</ns0:curp>
<ns0:rfc>rfc_1</ns0:rfc>
<ns0:nombre>nombre_1</ns0:nombre>
<ns0:apellido-paterno>apellido-paterno_1</ns0:apellido-paterno>
<ns0:apellido-materno>apellido-materno_1</ns0:apellido-materno>
<ns0:agregado-medico>agregado-medico_1</ns0:agregado-medico>
<ns0:agregado-afiliacion>agregado-afiliacion_1</ns0:agregado-afiliacion>
</ns0:persona>
</ns0:personas>
I got these functions:
There's more code above this
fn:remove($persona, xf:index-of-node($no-duplicado, $persona))
declare function xf:index-of-node ( $arg as element()? , $substring as element()* ) as xs:integer* {
if (contains($arg, $substring))
then (string-length(substring-before($arg, $substring))+1,
for $other in
xf:index-of-node(substring-after($arg, $substring),
$substring)
return
$other + string-length(substring-before($arg, $substring)) + string-length($substring))
else ()
} ;
Sorry for the delay, I didn't catch the notification. Here is one of many XQuery expressions:
<ns0:personas xmlns:ns0="http://www.personas.com">
{/*/*[some $other in (/*/* except .) satisfies deep-equal(.,$other)]}
</ns0:personas>
精彩评论