From: Lars H. <he...@se...> - 2008-11-25 14:35:19
|
Hi all, I checked in a JTMTopicMapReader to support reading of JSON TopicMaps and committed several RDF topic map readers. Further, a new interface RDFTopicMapReader which is derived from TopicMapReader. The JTMTopicMapReader needs json_simple.jar in the classpath. All RDFTopicMapReaders need "semagia-mio-0.9.3.jar", "semagia-mio-rdf-0.9.3.jar", and "openrdf-sesame-2.2.1-onejar.jar" in the classpath. The current set of TopicMap(Reader|Writer)s define the final set for the next .mio release. In the following days I'll fix some bugs, if any and write some docs etc. Here an excerpt from my draft how to use the RDF readers: tinyTiM is able to import several RDF syntaxes using the `RDF to Topic Maps (RTM) <http://www.ontopia.net/topicmaps/materials/rdf2tm.html>`_ mapping vocabulary. The actual mapping may either be defined within the RDF file which should be deserialized or, more commonly, by an external RDF source. Each RDF ``TopicMapReader`` provides several ``setMappingSource`` methods to specify the source to read the acutal mapping from. If no external mapping source was defined, the reader assumes that the mapping is part of the main RDF source. The following example assumes that the mapping is defined within the main RDF source ``rdfSource``:: import org.tinytim.mio.TopicMapReader; import org.tinytim.mio.N3TopicMapReader; File rdfSource = new File("http://tinytim.sf.net/example.n3"); // It is assumed that a org.tmapi.core.TopicMap is given TopicMapReader reader = new N3TopicMapReader(tm, rdfSource); reader.read(); Usually the mapping source is different from the main RDF source. If an external mapping should be defined, one of the ``setMappingSource`` method can be used:: import org.tinytim.mio.RDFTopicMapReader; import org.tinytim.mio.N3TopicMapReader; File rdfSource = new File("http://tinytim.sf.net/example.n3"); RDFTopicMapReader reader = new N3TopicMapReader(tm, rdfSource); reader.setMappingSource("http://tinytim.sf.net/the-mapping.n3"); reader.read(); The mapping source may use a different syntax than the main RDF source. All ``RDFTopicMapReader``s try to detect the mapping source syntax by its file extension. If the syntax cannot be detected, RDF/XML is assumed. The following example reads a RDF source using RDF/XML and utilises a mapping encoded in N-Triples:: import org.tinytim.mio.RDFTopicMapReader; import org.tinytim.mio.RDFXMLTopicMapReader; File rdfSource = new File("http://tinytim.sf.net/example.rdf"); RDFTopicMapReader reader = new RDFXMLTopicMapReader(tm, rdfSource); reader.setMappingSource("http://tinytim.sf.net/the-mapping.nt"); reader.read(); It is also possible to specify the syntax of the mapping source explicitly:: import org.tinytim.mio.RDFTopicMapReader; import org.tinytim.mio.RDFXMLTopicMapReader; import static org.tinytim.mio.RDFTopicMapReader.MappingSyntax; File rdfSource = new File("http://tinytim.sf.net/example.rdf"); RDFTopicMapReader reader = new RDFXMLTopicMapReader(tm, rdfSource); reader.setMappingSource("http://tinytim.sf.net/the-mapping.nt"); reader.setMappingSourceSyntax(MappingSyntax.NTRIPLES); reader.read(); Best regards, Lars -- Semagia <http://www.semagia.com> |