Som Sarkar
Som Sarkar

Reputation: 289

Updating a graph in an RDF file

I have an RDF file which has two graphs (shown at end). Now I want to change the uml:information owner for urn:uuid:00001 to cp:ioNEWONE. I know that it can be done directly by using INSERT DATA and DELETE DATA, but I'd like to use INSERT and DELETE along with WHERE clause, where inside the WHERE I will specify the uri -<urn:uuid:00001>. Is this possible?

This is my RDF file:

<urn:uuid:00001>
  rdf:type ldmext:InformationOwnership , ldmext:DerivedInformationOwnership ;
  ldmext:hasOwnershipType
          ldmext:BusinessEntityOwnership ;
  uml:businessEntity cp:beBOND ;
  uml:lineOfBusiness cp:lobEQUITIES ;
  uml:region cp:regionALL ;
  uml:informationOwner cp:ioMAYDUP ;
  uml:superPathsOwned cp:superPathsOwnedALL ;
  <http://www.w3.org/ns/prov#wasDerivedFrom>
          cp:_17_0_4_6a4018e_1397142349684_397604_11389 .

<urn:uuid:00002>
  rdf:type ldmext:InformationOwnership , ldmext:DerivedInformationOwnership ;
  ldmext:hasOwnershipType
          ldmext:BusinessEntityPathOwnership ;
  uml:businessEntity cp:beBOND ;
  uml:lineOfBusiness cp:lobRATES ;
  uml:mapType cp:mapTypeLOCAL ;
  uml:path "bondId"^^xsd:string ;
  uml:informationOwner cp:ioFICTISHUS ;
  uml:region cp:regionALL ;
  uml:superPathsOwned cp:superPathsOwnedALL ;
  <http://www.w3.org/ns/prov#wasDerivedFrom>
          cp:_17_0_4_78401ae_1396078188850_122597_7725 .

 cp:ioFICTISHIUS
  rdf:type uml:Enumeration_Literal , cp:_17_0_4_78401ae_1396073215096_223800_6327 ;
  rdfs:label "FIC_TISHIUS"^^xsd:string ;
  uml:name "FIC_TISHIUS"^^xsd:string .

cp:ioMAYDUP
  rdf:type uml:Enumeration_Literal , cp:_17_0_4_78401ae_1396073215096_223800_6327 ;
  rdfs:label "MAY_DUP"^^xsd:string ;
  uml:name "MAY_DUP"^^xsd:string .

cp:ioNEWONE
  rdf:type  cp:_17_0_4_78401ae_1396073215096_223800_6327 , uml:Enumeration_Literal ;
  rdfs:label "NEW_ONE"^^xsd:string ;
  uml:name "NEW_ONE"^^xsd:string .

Upvotes: 0

Views: 89

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85913

You can do this. It's described in the SPARQL Update specification, in the aptly named DELETE/INSERT section. If you're beginning with SPARQL (which is probably a safe assumption if you haven't come across this before), it's a good idea to at least skim through that document so that you've got an idea what the language supports. You don't need to memorize the whole thing, but just become familiar enough so that when you have a question like this, you know where to look for the answer.

3.1.3 DELETE/INSERT

The DELETE/INSERT operation can be used to remove or add triples from/to the Graph Store based on bindings for a query pattern specified in a WHERE clause:

( WITH IRIref )?
( ( DeleteClause InsertClause? ) | InsertClause )
( USING ( NAMED )? IRIref )*
WHERE GroupGraphPattern

Notes

I have an RDF file which has the following two graphs-

No, you have one RDF file that has one graph. What you've shown us isn't actually a legal file, because it doesn't include the necessary prefix declarations. If they were defined, you'd have an RDF graph containing thirty-two (32) triples. It's just one graph, though. This particular graph happens to be a forest.

Upvotes: 1

Related Questions