RE: RDF: better syntax effort - who could contribute?

> I guess it will be something like 20 lines of Java code.
> Can anybody give the RDF syntax for
> [[subject1 pred1 [subject2 pred2 object2]] pred3 object3]
> Thank you.

Thanks for the example Jos.  Got me to fix some bugs in Jena.

The Jena code for your example is:

  Model m = new ModelMem();        
  Statement s1 = m.createStatement(m.createResource("subject2"),
                                   m.createProperty("foo/pred2"),
                                   "object2");        
  Statement s2 = m.createStatement(m.createResource("subject1"),
                                   m.createProperty("foo/pred1"),
                                   s1);        
  m.add(s2, m.createProperty("foo/pred3"), "subject3");
  m.write(new PrintWriter(System.out);

and the (unsophisticated) Jena RDFWriter produces:

<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
  xmlns:RDFNsId0='foo/' >
  <rdf:Description rdf:about='#RDFAnonId2'>
    <rdf:type
rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement'/>
    <rdf:subject rdf:resource='subject1'/>
    <rdf:predicate rdf:resource='foo/pred1'/>
    <rdf:object rdf:resource='#RDFAnonId1'/>
    <RDFNsId0:pred3>subject3</RDFNsId0:pred3>
  </rdf:Description>
  <rdf:Description rdf:about='#RDFAnonId1'>
    <rdf:type
rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement'/>
    <rdf:subject rdf:resource='subject2'/>
    <rdf:predicate rdf:resource='foo/pred2'/>
    <rdf:object >object2</rdf:object>
  </rdf:Description>
</rdf:RDF>

Brian McBride
HPLabs

Received on Friday, 1 September 2000 02:36:55 UTC