Michiel; One suggestion is to refactor your query a bit.  Any update on SPO can 
have strange effects, so I'd suggest using FILTER to ensure that the update 
operations occur only on the intended triples:

delete {
  ?s ?p ?o .
}
insert {
  ?s_new ?p ?o_new .
}
where {
?s ?p ?o .
BIND(IRI(REPLACE(str(?s), "mySource", "mySourceX")) AS ?s_new)
BIND(IRI(REPLACE(str(?o), "myTarget", "myTargetY")) AS ?o_new)
FILTER (isIRI(?o) && CONTAINS(str(?s), "mySource") && CONTAINS(str(?o), 
"myTarget"))
FILTER (?s != <http://marklogic.com/todel3>)
}

Note also there isn't a need to test whether the subject is an IRI – it must be 
in RDF.

Try that and the original triple should get deleted.

— Scott

Scott Henninger
Senior Consultant, NAC Central
MarkLogic Corporation
[email protected]<[email protected]>
www.marklogic.com<http://www.marklogic.com/>





Hi,

I have a question of the following SPARQL  query:

-----------------------------------------------------
delete {
  ?s ?p ?o .
}
insert {
  ?s_new ?p ?o_new .
}
where {
?s ?p ?o .
  bind (if(isIRI(?s),IRI(replace(str(?s),"mySource","mySourceX")),?s) as 
?s_new) .
  bind (if(isIRI(?o),IRI(replace(str(?o),"myTarget","myTargetY")),?o) as 
?o_new) .
}
-----------------------------------------------------

and the following triple:
<mySource> <myRelation> <myTarget>

If I execute this query in MarkLogic, the result is 2 triples:
<mySource> <myRelation> <myTarget>
<mySourceX> <myRelation> <myTargetY>

where I expected only one:
<mySourceX> <myRelation> <myTargetY>


Kind regards,
Michiel Vanhoutte
Wolters Kluwer Belgium
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://developer.marklogic.com/pipermail/general/attachments/20160309/60f9f381/attachment.html
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to