Current revision: 2001-01-19

  1. Overview
  2. Known use cases
  3. Download and revision history
  4. Documentation (most recent release)
  5. Ant build script for source code contributed by David Li (DigitalSesame.com)
  6. FAQ (incomplete)
  7. Tutorial (under construction)
  8. Examples
  9. Creating unique URIs
  10. Vocabulary class generator
  11. Cryptographic digests of RDF models and statements
  12. UML on top of RDF (code included in this distribution)
  13. Feedback


This is a draft of an RDF API provided for a public discussion. The API defines interfaces for parsing (org.w3c.rdf.syntax) and accessing RDF models as sets of statements (org.w3c.rdf.model). Default implementations for those interfaces are included in the org.w3c.rdf.implementation package.

There are additional modules in the distribution that do not belong to the core API. They are packaged with the API to simplify download and evaluation:

Known use cases

Please let me know about further uses.

Download and revision history

.zip files contain documentation, sources and the jar file.
  • Download: rdf-api-2001-01-19.zip (jar file only)
  • Optimization release. Speed-up by an order of magnitude when dealing with large models.
    • Provided a more efficient implementation of interfaces in org.w3c.rdf.model (i.e. resources, statements, models etc.) The new implementation is contained in package edu.stanford.db.rdf.model.i and is used as the default one in examples and org.w3c.rdf.util.RDFFactoryImpl.
      Make sure you switch to the new implementation if you were using org.w3c.rdf.implementation.model classes directly (e.g. not via RDFFactory) in your code!
    • Added a new pair of parser/serializer: edu.stanford.db.rdf.syntax.generic.{TripleSerializer|TripleParser}. These are stream-oriented tools that are based on an extremely simple XML-based serialization syntax. The parser/serializer are very fast and small, and support a compact reification syntax. Use them e.g. for on-the-wire exchange of RDF models.
    • Better namespace support: added capability of overriding the default way the namespace abbreviations are generated in the serializer SiRS. Added a group of methods collectNamespaces in org.w3c.rdf.util.RDFUtil (suggested by Michael Sintek).
    • Fixed bug in saving of models in RDFUtil (uncovered by Michael Sintek).
    • Added method getNodeFactory to RDFFactory.
  • Download: rdf-api-2000-12-05.zip (jar file only)
  • Bugfix release.
    • Made digest computation in the default resource/literal/model implementation more efficient
    • Implemented syntax in edu.stanford.db.rdf.syntax.generic.TripleSerializer. Now it supports reification and embedded models efficiently
    • SiRS: fixed "order"-related bug; revived abbreviated syntax; improved efficiency
    • SiRPAC: added a function to disable fetching of external entities in XML parser; fixed bug with empty name in input source
  • Download: rdf-api-2000-11-13.zip (jar file only)
  • This release contains a major package restructuring; the org.w3c.rdf subtree has been cleaned up, a few packages have been moved to edu.stanford tree. The API interfaces are not affected. In addition, this release provides several fixes and improvements.
    • Moved org.w3c.rdf.util.xml to edu.stanford.db.xml.util and edu.stanford.db.rdf.syntax.generic
    • Moved org.w3c.rdf.implementation.syntax.strawman to edu.stanford.db.rdf.syntax.strawman
    • Moved org/w3c/rdf/examples/StrawmanToMS10.java to edu/stanford/db/rdf/examples/StrawmanToMS10.java
    • Modified SiRPAC to reflect changes
    • Moved digest utilities from org/w3c/rdf/util/ to org/w3c/rdf/digest/
    • Trashed org/w3c/rdf/util/OrderUtil.java, org/w3c/rdf/util/OrderedModel.java
    • Trashed org/w3c/tools completely
    • Generated an updated schema vocabulary org/w3c/rdf/vocabulary/rdf_schema_200001/RDFS.java
    • Generated a schema vocabulary for DAML-O: edu/stanford/db/rdf/vocabulary/daml_o_20001011/DAML_O.java
    • Fixed a bug in SiRS serializer which could not deal with more than 26 namespaces (reported by Mike Dean).
    • Modified the digest algorithm for models as suggested by Steve Dunham. The algorithm is now cryptographically secure.
  • Download: rdf-api-2000-10-30.zip (jar file only)
  • Notice: this release contains (incremental) changes to the API that are not backward compatible!
    • Now resources support methods getNamespace() and getLocalName(). This change affected several other interfaces.
    • Changed NodeFactory interface: allow namespace-based resource creation
    • Changed ModelImpl (fixed bug in duplication of models)
    • Added getName and getNamespace to RDFUtil
    • Extended NodeFactory to createLiterals for all primitive Java types: boolean, byte, short, char, int, long, float, double
    • Modified NodeFactory implementation to speedup secure random generation
    • Fixed a bug in SiRS related to empty namespaces
    • ParseAndSerialize accepts options -xml and -triples
    • Moved experimental order resources to a separate class (edu.stanford.db.rdf.vocabulary.order_20000527) and changed SiRPAC and SiRS adequately.
    • Added more reserved words to edu.stanford.db.rdf.vocabulary.Generator
    • SiRPAC now recognizes unqualified ID, resource and about XML attributes. It also supports new namespace handling and deals with string generation in a slightly more efficient way. Fixed bug in SiRPAC related to explicit use of ordinals rdf:_1 etc.
    • Added a new example, a tiny utility that generates unique resource identifiers (org.w3c.rdf.examples.CreateUniqueURIs)
  • Download: rdf-api-2000-09-03.zip (jar file only)
  • Bugfix release, 100% contributed by William Grosso. No changes in the API.
    • Fixed bug that prevented source code from being compiled properly
    • Replaced package org.w3c.rdf.implementation.model by more efficient code provided by Bill (from now on, Java 1.2+ is required)
    • Serializer (org.w3c.rdf.implementation.syntax.sirpac.SiRS) now generates correct syntax for class names that contain spaces
  • Download: rdf-api-2000-05-12.zip (jar file only)
  • latest release that worked with Java 1.1.x; newer releases require Java 1.2+
  • added support for RDF schema: edu.stanford.db.rdf.schema.RDFSchemaModel (includes validation)
  • added support for UML over RDF: edu.stanford.db.rdf.uml.UMLModel (includes validation)
  • generated vocabulary classes for DublinCore, UML Core, StateMachines, DataTypes, Behavior
  • experimental support for order by reification. Methods for ordering are in org.w3c.rdf.util.OrderUtil. (added support for rdf:order and rdf:backwardOrder to SiRPAC)
  • improved SiRS (serializer), uses entities to generate compact syntax (also support for order)
  • minor bugfixes in SiRPAC
  • fixed the security bug in the statement digest algorithm (reported by Brian McBride). Model digest is still insecure.
  • added exceptions to the core interfaces (org.w3c.rdf.model.ModelException)
  • added method isEmpty() to model
  • added createOrdinal() to NodeFactory, removed ord() from RDFUtil
  • changed RDFConsumer: addStatement() receives a statement as a parameter instead of (s, p, o)
  • added isMutable() to Model
  • made vocabularies be classes instead of interfaces. A NodeFactory that creates custom resources can now be set using a static method
  • Download: rdf-api-2000-04-13.zip (jar file only)
  • Contains improvements proposed by Stefan Haustein:
    • Reorganized the package structure:
      org.w3c.rdf.model.impl.ModelConsumer -> org.w3c.rdf.util.ModelConsumer
      org.w3c.rdf.syntax.xml -> org.w3c.rdf.util.xml
      org.w3c.rdf.model.impl -> org.w3c.rdf.implementation.model
      org.w3c.rdf.syntax.* -> org.w3c.rdf.implementation.syntax.*
    • Added NodeFactory interface to org.w3c.rdf.model and updated RDFConsumer. Now the parsers can create custom RDF nodes during parsing.
  • Updated the strawman parser:
    • now it starts interpreting XML as RDF only when it encounteres one of the attributes rdf:instance, rdf:for, or rdf:resource.
    • triples of the kind (X, rdf:type, rdfs:Resource) are filtered out before passing to RDFConsumer
  • Download: rdf-api-1999-12-18.zip (jar file only)
  • SHA-1 algorithm (160-bit hash) is now used by default instead of MD5 (128-bit) to compute the URIs for reified statements, models and anonymous resources.
  • Download: rdf-api-1999-12-16.zip (jar file only)
  • Classes org.w3c.rdf.model.Triple and org.w3c.rdf.model.RDFModel have been renamed into org.w3c.rdf.model.Statement and org.w3c.rdf.model.Model respectively.
  • Strawman parser package added: org.w3c.rdf.syntax.strawman
  • Generic RDF/XML parser package added: org.w3c.rdf.syntax.xml
  • Minor bug fixes


Some examples are contained in the package org.w3c.rdf.examples. Please use them to familiarize yourself with the API. Run
java org.w3c.rdf.examples.ParseAndSerialize
to list the command line parameters of this tool.

Vocabulary class generator

All vocabulary classes (RDF, RDFS, DC etc) included in the distribution were generated using this utility.


java edu.stanford.db.rdf.vocabulary.Generator
  -s http://www.w3.org/1999/02/22-rdf-syntax-ns#
  -o org.w3c.rdf.vocabulary.rdf_syntax_19990222.RDF

java edu.stanford.db.rdf.vocabulary.Generator
  -n http://www.w3.org/2000/01/rdf-schema#
  -s http://www.w3.org/2000/01/rdf-schema
  -o org.w3c.rdf.vocabulary.rdf_schema_200001.RDFS

java edu.stanford.db.rdf.vocabulary.Generator
  -s http://www-db.stanford.edu/~melnik/rdf/vocabulary/dublin-core-19990702.rdf
  -o org.w3c.rdf.vocabulary.dublin_core_19990702.DC
  -n http://purl.org/dc/elements/1.1/

Creating unique URIs

Sometimes there is a need to generate a unique identifier for a resource that does not inherently have a URI e.g. a person. A list of unique resource identifiers (URIs) can be created as follows:
java org.w3c.rdf.examples.CreateUniqueURIs [<number of URIs>]

Cryptographic digests of RDF models and statements

The default implementation of the API interfaces supports computing cryptographic digests of models and statements. This approach provides a straightforward way of digital signing of RDF content (as opposed to signing of serialized RDF), facilitating the "Web of Trust". URIs of statements and models are based on their digests.

Standard SHA-1-based cryptographic digests are used in the algorithm. The digest algorithm for a statement with subject s, predicate p and object o is:

  d1 = SHA1(s)
  d2 = SHA1(p)
  d3 = SHA1(o)

  if(o instanceof Literal)
    rotate left d3 by 8 bits

  statement_digest = SHA1( concat(d1, d2, d3) )

The digest algorithm for models (suggested by Steve Dunham) is

  model_digest = SHA1( concat( sort( statment_digests )))
The statement digests are introduced to the SHA1 algorithm sorted bytewise in an increasing order. The digests of URIs and literals are computed over UTF-8 encoded strings.


To: Sergey Melnik
Cc: www-rdf-interest@w3.org