From: Rob V. <rv...@do...> - 2014-09-30 11:16:51
|
Frank Nodes are by design immutable objects To change the subject/predicate/object of a triple you need to retract the original triple and assert a replacement triple e.g. INode newSubject = g.CreateUriNode(new Uri("http://new-uri.com")); foreach (INode item in g.Triples.SubjectNodes.ToList()) { if (item.NodeType != NodeType.Uri) continue; List<Triple> ts = g.GetTriplesWithSubject(item).ToList(); foreach (Triple t in ts) { g.Retract(t); g.Assert(newSubject, t.Predicate, t.Object); } } Note that it is necessary to use ToList() as otherwise you will get concurrent modification exceptions Alternatively you may be better off using a SPARQL Update if you are ultimately transforming the stored data e.g. DELETE { <http://old-uri.com> ?p ?o . } INSERT { <http://new-uri.com> ?p ?o . } WHERE { <http://old-uri.com> ?p ?o . } Regards, Rob On 25/09/2014 14:52, "Frank Schumacher" <fs...@in...> wrote: >Hello, > >I want to write a programm that adds triples from a ttl-file to a >virtuoso store. I load them with: > >IGraph g = new Graph(); >FileLoader.Load(g, @"filename"); > >Before I add a triple, I want to check, wheter the element already >exists in the virtuoso store (via >http://www.w3.org/1999/02/22-rdf-syntax-ns#type and >http://www.w3.org/2000/01/rdf-schema#label). If it exists, I want to >replace the URI from the file with the URI from the virtuoso store. >Unfortunately, I cannot rename an URI like > >foreach (INode item in g.Triples.SubjectNodes) > ((IUriNode)item).Uri = "newURI"; > >Any idea how I can achieve this? > >Greetings, >Frank >-- >************************************************ >* Universität Leipzig, Institut für Informatik * >* Abteilung Betriebliche Informationssysteme * >* http://bis.informatik.uni-leipzig.de * >* Tel.: 0341 / 97 32 256 * >* * >* ========== Opera Metal: molllust =========== * >* http://www.molllust.com * >* M'era Luna Newcomer 2013! * >************************************************ > >-------------------------------------------------------------------------- >---- >Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer >Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports >Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper >Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer >http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clkt >rk >_______________________________________________ >dotNetRDF-Support mailing list >dot...@li... >https://lists.sourceforge.net/lists/listinfo/dotnetrdf-support |