semantic web - Why some rdf files does not contain <rdf:Description rdf:about=...>? -


i'm using jena write rdf file describes online posts. according sioc ontology/namespace i'm using there is, instance, following:

  • class: sioc:post
  • property: sioc:has_creator

how can i, in jena, include sioc:post in file

<sioc:post rdf:about="http://example.com/vb/1035092">  

instead of

<rdf:description rdf:about="http://example.com/vb/1035092"> 

and best practice?

both of answers far make points:

  • you should not pay attention particular serialization of rdf graph, because there lots of different serializations, , should accessing them using api exposes graph, not serialization. (see, instance, don't query rdf (or owl) xpath in 1 of previous answers, comments depending on particular xml serialization.)
  • the difference you're seeing simple rdf/xml serialization use lots of rdf:description elements, , these contain rdf:type elements indicate types of described element. however, rdf/xml serialization format defines many abbreviations can used make serialization of graph shorter, more readable, and, in cases, more traditional xml document. others have mentioned using type element name 1 such abbreviation, think it's worth examining spec on point. particular abbreviation defined in 2.13 typed nodes:

it common rdf graphs have rdf:type predicates subject nodes. these conventionally called typed nodes in graph, or typed node elements in rdf/xml. rdf/xml allows triple expressed more concisely. replacing rdf:description node element name namespaced-element corresponding rdf uri reference of value of type relationship. there may, of course, multiple rdf:type predicates 1 can used in way, others must remain property elements or property attributes.

the typed node elements commonly used in rdf/xml built-in classes in rdf vocabulary: rdf:seq, rdf:bag, rdf:alt, rdf:statement, rdf:property , rdf:list.

for example, rdf/xml in example 14 written shown in example 15.

example 14: complete example rdf:type (example14.rdf output example14.nt)

<?xml version="1.0"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"          xmlns:dc="http://purl.org/dc/elements/1.1/"          xmlns:ex="http://example.org/stuff/1.0/">   <rdf:description rdf:about="http://example.org/thing">     <rdf:type rdf:resource="http://example.org/stuff/1.0/document"/>     <dc:title>a marvelous thing</dc:title>   </rdf:description> </rdf:rdf> 

example 15: complete example using typed node element replace rdf:type (example15.rdf output example15.nt)

<?xml version="1.0"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"          xmlns:dc="http://purl.org/dc/elements/1.1/"          xmlns:ex="http://example.org/stuff/1.0/">   <ex:document rdf:about="http://example.org/thing">     <dc:title>a marvelous thing</dc:title>   </ex:document> </rdf:rdf> 

if you're using jena, can extensive control on way rdf/xml output formatted. these options documented in advanced rdf/xml output section of documentation. however, case want, serializing in rdf/xml versus rdf/xml-abbrev take care of want do. instance, @ results using jena command line rdfcat tool. here's our data (in turtle):

# actual namespace doesn't matter example. @prefix sioc: <http://example.org/> .   <http://example.com/vb/1035092>   sioc:post ;   sioc:has_creator "someone" . 

let's convert simple rdf/xml:

$ rdfcat -out rdf/xml data.n3 <rdf:rdf     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:sioc="http://example.org/" >    <rdf:description rdf:about="http://example.com/vb/1035092">     <rdf:type rdf:resource="http://example.org/post"/>     <sioc:has_creator>someone</sioc:has_creator>   </rdf:description> </rdf:rdf> 

now let's convert rdf/xml-abbrev:

$ rdfcat -out rdf/xml-abbrev data.n3 <rdf:rdf     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:sioc="http://example.org/">   <sioc:post rdf:about="http://example.com/vb/1035092">     <sioc:has_creator>someone</sioc:has_creator>   </sioc:post> </rdf:rdf> 

in first case see rdf:description element rdf:type , sioc:has_creator subelements, in second case see sioc:post element sioc:has_creator subelement.

as best practice, don't know matters. rdf/xml-abbrev typically bit shorter, incur less network overhead on transmission, storage on disk, , easier read. simpler rdf/xml faster write, though. on graphs won't make big difference, generating rdf/xml-abbrev can pretty expensive, a recent thread on jena mailing list discusses.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -