W3C home > Mailing lists > Public > www-rdf-interest@w3.org > September 2000

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

From: McBride, Brian <bwm@hplb.hpl.hp.com>
Date: Fri, 1 Sep 2000 07:36:41 +0100
Message-ID: <5E13A1874524D411A876006008CD059FE7D91C@0-mail-1.hpl.hp.com>
To: jos.deroo.jd@belgium.agfa.com, " - *www-rdf-interest@w3.org" <www-rdf-interest@w3.org>
> 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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:51:44 GMT