Provides a set of parsers and emitters for serializing and de-serializing RDF {@link com.ibm.team.jfs.app.rdf.IGraph graphs} to stream formats. An implementation of the {@link com.ibm.team.jfs.app.rdf.parsers.IEmitter} interface is responsible for serializing an instance of a graph to a particular streaming format. An implementation of the {@link com.ibm.team.jfs.app.rdf.parsers.IParser} interface is responsible for de-serializing a streaming format into one or more {@link com.ibm.team.jfs.app.rdf.IGraph} instances.

What the rdf Package Contains

Example

The following demonstrates the RDF/XML parser, it first parses a resource (held in a String) into a graph and then serializes the graph back out using a different format of RDF/XML ensuring that while semantically the starting and ending resource express exactly the same graph they are syntactically quite different.

  String xml = 
    "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"<>" +
    "  <rdf:Description rdf:about=\"http://example.org/things/thing/thing2\"<>" +
    "    <ns:pname xmlns:ns=\"http://example.org/properties/\" ns:given=\"Simon\" ns:family=\"Johnston\"/<>" +
    "    <ns:title xmlns:ns=\"http://example.org/properties/\"<>Dev</ns:title<>" +
    "    <ns:project xmlns:ns=\"http://example.org/properties/\"<>" +
    "      <rdf:Description ns:identifier=\"jazz.net\"<>" +
    "        <ns:name xml:lang=\"en\"<>Jazz Foundation</ns:name<>" +
    "        <ns:started rdf:datatype=\"http://www.w3.org/2001/XMLSchema#dateTime\"<>3907-10-21</ns:started<>" +
    "        <ns:website rdf:resource=\"http://ibm.com/\"/<>" +
    "      </rdf:Description<>" +
    "    </ns:project<>" +
    "  </rdf:Description<>" +
    "</rdf:RDF>";

  IParser parser = new XmlParser();
  List graphs = parser.parse(new ByteArrayInputStream(xml.getBytes()));

  Properties config = new Properties();
  config.put(XmlParser.CONFIG_INCLUDE_RDF, "true");
  config.put(XmlParser.CONFIG_XML_FORMAT, XmlParser.FORMAT_STATEMENTS);
  IEmitter emitter = new XmlEmitter();
  emitter.write(graphs.get(0), config, System.out);

@since 0.1