- From: Gregg Kellogg <gregg@kellogg-assoc.com>
- Date: Wed, 23 Nov 2011 13:27:44 -0500
- To: Paul Rogers <PaulRogers@smarttech.com>
- CC: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>
- Message-ID: <48CF8ED2-CFA3-471C-BEE6-B0E4B0E23F60@greggkellogg.net>
On Nov 23, 2011, at 10:11 AM, Paul Rogers wrote: Thanks Gregg, I like the use of Turtle, and am trying that now, however I think my question was badly worded. What Im trying to do is crete that xml using the ruby libs. Ive been doing this: graph = RDF::Graph.new s1 = RDF::URI.new("http://server/path/resources/temppersonresource") p1 = RDF::URI.new("http://www.w3.org/2001/vcard-rdf/3.0#Given") o1 = "Paul" # given name statement = RDF::Statement.new(s1, p1, 01) # this gave an rdf literal graph << statement But I cant figure out how to get the rdf:type entry. You can add a type, as you would add any other statement, in this case making use of RDF as a vocabulary: graph << RDF::Statement.new(s1, RDF.type, RDF::URI("http://server/path/Person")) puts graph.dump(:rdfxml) Note that the serializer will most likely create an element for the type, creating something like the following: <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:ns0="http://server/path/" xmlns:foo="http://example.org/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:base=""> <ns0:Person rdf:about="http://server/path/temppersonresource"> <foo:country-name>US</foo:country-name> </ns0:Person> </rdf:RDF> I'm getting to the various readers and writers that have dependencies on external resources, such as Nokogiri, and re-writing them to use pure-ruby alternatives. RDF::RDFXML makes use of Nokogiri both for reading and for writing. I've completed changes to remove this for the reader, and I'm probably going to re-write the writer to use Haml. I make use of Haml in the RDFa writer, which allows you to define your own output template to provide much greater control when serializing. I'll likely do the same for RDF/XML, which could give you fine control over how the RDF/XML is generated. Personally, I avoid using RDF/XML altogether. For more modern serializations, Turtle is the best for authoring and reading, RDFa and/or microdata for embedded markup, and JSON-LD is coming along as a REST interface for Ajax or other applications. Note that with the linkeddata gem, you can get all the appropriate readers and writers and other dependencies at once, which makes content negotiation work better. Gregg Im looking into the ruby-turtle things now. Paul From: Gregg Kellogg <gregg@kellogg-assoc.com<mailto:gregg@kellogg-assoc.com>> Date: Wed, 23 Nov 2011 08:39:24 -0700 To: Paul Rogers <PaulRogers@smarttech.com> Cc: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org> Subject: Re: rdf:type Paul, I usually author in Turtle and then distill to other formats to do this kind of stuff. The form your looking for for your example is the following: <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:foo="http://example.org/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:base=""> <rdf:Description rdf:about="http://server/path/temppersonresource"> <rdf:type rdf:resource="http://server/path/Person"/> <foo:country-name>US</foo:country-name> </rdf:Description> </rdf:RDF> Much easier to write as Turtle: @prefix foo: <http://example.org/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . <http://server/path/temppersonresource> a <http://server/path/Person>; foo:country-name "US" . You can use my online service to validate and transform between representations. It's at http://rdf.greggkellogg.net/distiller. Gregg Kellogg Sent from my iPad On Nov 23, 2011, at 1:14 AM, "Paul Rogers" <PaulRogers@smarttech.com> wrote: Hello, Im a complete beginner with rdf. Im using the ruby rdf xml libraries ( rdf/rdfxml) How would I create a <rdf:type rdf:resource="http://server/path/Person"/> Entry as a child of rdf:description ? Ie like this sample <rdf:Description rdf:about="http://server/path/temppersonresource"> <j.3:country-name>US</j.3:country-name> <rdf:type rdf:resource="http://server/path/Person"/> </rdf:Description> I have created the rdf:description ok, as well as various statements, but am stumped on the type. Hope that is enough of an explanation. Thanks Paul
Received on Wednesday, 23 November 2011 18:28:46 UTC