Thursday, November 25, 2004

One step closer to making a lighter Kowari

An initial port of Sesame 1.1's RIO RDF/XML parser to JRDF has been checked into JRDF's CVS repository. It's basically the same with a few modifications to the constructor, the SAXFactory explicitly asks for a reader that will use namespaces and a reduction on depending on other Sesame classes.

In Kowari it already uses JRDF to do N3 and RDF/XML exporting. A recent requirement that I was just asked about was providing RDF/XML from the result of an iTQL query. The client side JRDF API allows the creation of a JRDF graph using an iTQL answer so it might be possible to plug this into the exporter classes.

Instruction on getting it are here.

A simple example of using it:

public class RdfXmlParserExample {
public static void main(String[] args) throws Exception {
String baseURI = "http://slashdot.org/index.rss";
URL url = new URL(baseURI);
InputStream is = url.openStream();
final Graph jrdfMem = new GraphImpl();
RdfXmlParser parser = new RdfXmlParser(jrdfMem);
parser.setStatementHandler(new StatementHandler() {
public void handleStatement(SubjectNode subject,
PredicateNode predicate, ObjectNode object) {
try {
jrdfMem.add(subject, predicate, object);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
);

parser.parse(is, baseURI);
Iterator iter = jrdfMem.find(null, null, null);
while (iter.hasNext()) {
System.err.println("Graph: " + iter.next());
}
is.close();
}
}


While mentioning Kowari, one of the included resolvers to be included in 1.1 will generate statements based on the latitude and longitude of two points. We used the DAML Geofile linked from Semantic Web Application Integration: Travel Tools.
Post a Comment