From: Chad C. <ch...@bs...> - 2014-09-19 14:10:20
|
Thanks Rob. I really appreciate the help. I'll continue working on this now that I have a better understanding of using blank nodes. Chad From: Rob Vesse [mailto:rv...@do...] Sent: Friday, September 19, 2014 5:09 AM To: dotNetRDF User Help and Support Subject: Re: [dotNetRDF-Support] Creating nested RDF/xml Chad Firstly sorry for taking so long to get back to you. The complication here is that your RDF/XML fragment is using a compression technique called striping (http://www.w3.org/TR/rdf-syntax-grammar/#example1) so not everything you see is a blank node: <bf:publication> Property <bf:Provider> Blank Node <bf:providerName> Property <bf:Organization> Blank Node <bf:label>Unwin Hyman</bf:label> Property with Literal Object </bf:Organization> </bf:providerName> <bf:providerPlace> Property <bf:Place> Blank Node <bf:label>London</bf:label> Property with Literal Object </bf:Place> </bf:providerPlace> <bf:providerDate>1987 ;</bf:providerDate> Property with Literal Object </bf:Provider> </bf:publication> The yellow annotations serve to illustrate which is which, generally a well designed ontology will use lowercase local names for properties and uppercase local names for types which usually makes it easy to distinguish which is which Your fragment here is incomplete because it starts with a property and it is unclear from your code what the root node is but I'll assume it is in the variable root for the purposes of the example INode pubProperty = g.CreateUriNode("bf:publication"); INode providerNode = g.CreateBlankNode(); INode providerType = g.CreateUriNode("bf:Provider"); g.Assert(root, pubProperty, providerNode); g.Assert(providerNode, rdfType, providerType); INode provNameProperty = g.CreateUriNode("bf:providerName"); INode orgNode = g.CreateBlankNode(); INode orgType = g.CreateUriNode("bf:Organization"); g.Assert(providerNode, provNameProperty, orgNode); g.Assert(orgNode, rdfType, orgType); INode labelProperty = g.CreateUriNode("bf:label"); INode labelValue = g.CreateLiteralNode("Unwin Hyman"); g.Assert(orgNode, labelProperty, labelValue); The above example creates just the first portion of your fragment but should hopefully point you in the right direction. Hope this helps, Rob From: Chad Cluff <cc...@bs...<mailto:cc...@bs...>> Reply-To: dotNetRDF User Help and Support <dot...@li...<mailto:dot...@li...>> Date: Tuesday, 9 September 2014 16:49 To: dotNetRDF User Help and Support <dot...@li...<mailto:dot...@li...>> Subject: Re: [dotNetRDF-Support] Creating nested RDF/xml Rob, I appreciate your help, and would like to ask a follow up question about the creation of the blank nodes. I'm still very new at this, so I apologize if the question is simple. Can you explain a bit, perhaps with an example about how to create the nodes? I've been working on getting it put together but I'm struggling. Let me show you what I've got and can you correct my thinking. /*previous creation of <bf:work> and <bf:instance> nodes and various triple assertions, such as ittle such as the line below g.Assert(bfInstance, g.CreateUriNode("bf:modeOfIssuance"), g.CreateLiteralNode("monographic")); IUriNode pubnode = g.CreateUriNode("bf:publication"); IBlankNode blnkPubNode = g.CreateBlankNode(); g.Assert(blnkPubNode, rdfType, pubnode); IUriNode providernode = g.CreateUriNode("bf:Provider"); IBlankNode blnkProvNode = g.CreateBlankNode(); g.Assert(blnkProvNode, rdfType, providernode); IUriNode providernamenode = g.CreateUriNode("bf:providerName"); IBlankNode blnkProvNameNode = g.CreateBlankNode(); g.Assert(blnkProvNameNode, rdfType, providernamenode); IUriNode orgnode = g.CreateUriNode("bf:Organization"); IBlankNode blnkOrgNode = g.CreateBlankNode(); g.Assert(blnkOrgNode, rdfType, orgnode); ILiteralNode publabel = g.CreateLiteralNode("Unwin Hyman"); /*End*/ It's at this point that I'm not sure how to make my assertions so that I get to an RDF like this (with the understanding that the formatting may not be exactly the same, based on how the library decides is the most efficient way of writing it out): <bf:publication> <bf:Provider> <bf:providerName> <bf:Organization> <bf:label>Unwin Hyman</bf:label> </bf:Organization> </bf:providerName> <bf:providerPlace> <bf:Place> <bf:label>London</bf:label> </bf:Place> </bf:providerPlace> <bf:providerDate>1987 ;</bf:providerDate> </bf:Provider> </bf:publication> Any help would be appreciated. Thanks, Chad From: Rob Vesse [mailto:rv...@do...] Sent: Tuesday, August 19, 2014 4:30 PM To: dotNetRDF User Help and Support Subject: Re: [dotNetRDF-Support] Creating nested RDF/xml Chad dotNetRDF may produce such RDF/XML but then it may not. See the email thread at http://sourceforge.net/p/dotnetrdf/mailman/message/32563380/ for some discussion around this, essentially it comes down to the fact that we prefer round trip correctness over readability so we provide limited configurability of the RDF writer. With an appropriate Graph created with the relevant triples and using the RDF/XML writer with the compression level turned up to high dotNetRDF may well produce that specific RDF/XML but it still may not. In your specific example you will need to ensure that you are using blank nodes as the intermediate nodes and ensuring that all the appropriate rdf:type triples are present RDF/XML provides multiple ways to encode the same graph and dotNetRDF will use whichever it decides is the most appropriate and most likely to round trip correctly. See https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/UserGuide/Writing%20RDF#!advanced-usage for how to set the compression level, note that you can also set Options.DefaultCompressionLevel if your code won't have direct access to the write (see https://bitbucket.org/dotnetrdf/dotnetrdf/wiki/UserGuide/Global%20Options#!writing-options). As I stated in the email thread I linked earlier if a system relies on a specific format of RDF/XML then that is a bug in that system, a proper RDF system should only care about the underlying triples and the specific serialisation should be irrelevant. Rob From: Chad Cluff <cc...@bs...<mailto:cc...@bs...>> Reply-To: dotNetRDF User Help and Support <dot...@li...<mailto:dot...@li...>> Date: Tuesday, 19 August 2014 14:58 To: "dot...@li...<mailto:dot...@li...>" <dot...@li...<mailto:dot...@li...>> Subject: [dotNetRDF-Support] Creating nested RDF/xml I am trying to programmatically create a graph which will then export with nested RDF/xml elements. For example, I would like my output to look something like this: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <bf:Instance xmlns:bf="http://bibframe.org/vocab/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#<http://www.w3.org/2000/01/rdf-schema>" rdf:about="http://bibframe.org/resources/backstage/3389308instance24"<http://bibframe.org/resources/backstage/3389308instance24%22>> <bf:publication> <bf:Provider> <bf:providerDate>1987</bf:providerDate> </bf:Provider> </bf:publication> </bf:Instance> </rdf:RDF> Is there any way to make this work with dotnetrdf? Thanks, Chad -- Chad Cluff IT/Programming Manager Backstage Library Works 800-288-1265 x696 cc...@bs...<mailto:cc...@bs...> ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/_______________________________________________ dotNetRDF-Support mailing list dot...@li...<mailto:dot...@li...> https://lists.sourceforge.net/lists/listinfo/dotnetrdf-support ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce. Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk_______________________________________________ dotNetRDF-Support mailing list dot...@li...<mailto:dot...@li...> https://lists.sourceforge.net/lists/listinfo/dotnetrdf-support |