openRDF.org Welcome Guest   | Login   
  Search  
  Index  | Recent Threads  | Who's Online  | User List  | Search  | Help  | RSS feeds

Forum has been closed down
This forum has been closed down due to extensive spamming activities. Please use the mailing list instead.


Quick Go »
Thread Status: Normal
Total posts in this thread: 3
[Add To My Favorites] [Watch this Thread]
Author
Previous Thread This topic has been viewed 9618 times and has 2 replies Next Thread
Aug 29, 2009 9:43:24 PM

bblfish
Sesame Addict
Member's Avatar

France
Joined: Sep 13, 2004
Posts: 102
Status: Offline
How to create a new parser?

Hi I am tryihng to adapt shellac's rdfa parser to Sesame. Here is what shellac told me:
 
Here's some stuff to get you started:

* http://rootdev.net/maven/projects/java-rdfa/ is a bit bare, but has most of the useful info.
* java-rdfa releases are in the maven central repo (net.rootdev java-rdfa). The dependencies are screwy. You'll only really need StAX (for java < 6) and IRI (because java.net.URI is rubbish). I might relax the IRI thing.
* All you need to do is implement StatementSink (http://rootdev.net/maven/projects/java-rdfa/apidocs/net/rootdev/javardfa/StatementSink.html).
* http://rootdev.net/maven/projects/java-rdfa/apidocs/src-html/net/rootdev/javardfa/RDFaReader.html show how to plumb together the parsing:

Take a StatementSink.
Make a Parser using the StatementSink.
Get a SAX XMLReader (I use the jdk one and the html 5 validator.nu parser).
Set the XMLReader's content handler to be the Parser.
parse an InputSource.


That seeed doable, so I started working on it.

The first problem I came accross is: how do I associate an RDFParser with an RDFFormat so that the calls to add triples from an input stream get sent to the correct parser?
Show Printable Version of Post        Hidden to Guest    http://bblfish.net [Link] Report threatening or abusive post: please login first  Go to top 
Aug 30, 2009 3:10:44 PM

james
OpenRDF.org Consultant
Member's Avatar

Canada
Joined: Jul 21, 2005
Posts: 650
Status: Offline
Re: How to create a new parser?

List your parser factory in a file named:
META-INF/services/org.openrdf.rio.RDFParserFactory

In the getRDFFormat method return a format that was registered with:
RDFFormat.register

Now your parser can be looked up by RDFFormat, mimetype, or file extension.
----------------------------------------
Sesame Consultant
http://leighnet.ca
http://jamesrdf.blogspot.com
Show Printable Version of Post        Hidden to Guest    http://leighnet.ca [Link] Report threatening or abusive post: please login first  Go to top 
Sep 9, 2009 7:03:31 PM

bblfish
Sesame Addict
Member's Avatar

France
Joined: Sep 13, 2004
Posts: 102
Status: Offline
Re: How to create a new parser?

I forked shellac's parser and it is now available online. For more info see:
http://blogs.sun.com/bblfish/entry/rdfa_parser_for_sesame
Show Printable Version of Post        Hidden to Guest    http://bblfish.net [Link] Report threatening or abusive post: please login first  Go to top 
[Show Printable Version of Thread]