org.openrdf.rio.rdfxml
Class AbbreviatedRdfXmlWriter

java.lang.Object
  extended byorg.openrdf.rio.rdfxml.RdfXmlWriter
      extended byorg.openrdf.rio.rdfxml.AbbreviatedRdfXmlWriter
All Implemented Interfaces:
RdfDocumentWriter

public class AbbreviatedRdfXmlWriter
extends RdfXmlWriter

An extension of RdfXmlWriter that outputs a more concise form of RDF/XML. The resulting output is semantically equivalent to the output of an RdfXmlWriter (it produces the same set of statements), but it is usually easier to read for humans.

This is a quasi-streaming RdfDocumentWriter. Statements are cached as long as the striped syntax is followed (i.e. the subject of the next statement is the object of the previous statement) and written to the output when the stripe is broken.

The abbreviations used are typed node elements, empty property elements and striped syntax. Note that these abbreviations require that statements are written in the appropriate order.

Striped syntax means that when the object of a statement is the subject of the next statement we can nest the descriptions in each other.

Example:

 <rdf:Seq>
    <rdf:li>
       <foaf:Person>
          <foaf:knows>
             <foaf:Person>
                <foaf:mbox rdf:resource="..." />
             </foaf:Person>
          </foaf:knows>
       </foaf:Person>
    </rdf:li>
 </rdf:Seq>
 
Typed node elements means that we write out type information in the short form of
 <foaf:Person>
    ...
 </foaf:Person>
 
instead of
 <rdf:Description>
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
    ...
 </rdf:Description>
 
Empty property elements are of the form
 <foaf:Person>
    <foaf:homepage rdf:resource="http://www.cs.vu.nl/~marta"/>
 </foaf:Person>
 
instead of
 <foaf:Person>
    <foaf:homepage>
       <rdf:Description rdf:about="http://www.cs.vu.nl/~marta"/>
    <foaf:homepage>
 </foaf:Person>
 

Author:
Peter Mika (pmika@cs.vu.nl)

Constructor Summary
AbbreviatedRdfXmlWriter(OutputStream out)
          Creates a new RdfXmlWriter that will write to the supplied OutputStream.
AbbreviatedRdfXmlWriter(Writer out)
          Creates a new RdfXmlWriter that will write to the supplied Writer.
 
Method Summary
 void endDocument()
          Ends the document writing.
 void flush()
           
 void startDocument()
          Starts the document writing.
 void writeComment(String comment)
          Writes a comment to the document.
 void writeStatement(Resource subj, URI pred, Value obj)
          Writes a statement to the document.
 
Methods inherited from class org.openrdf.rio.rdfxml.RdfXmlWriter
addStyleSheet, addStyleSheet, setNamespace
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbbreviatedRdfXmlWriter

public AbbreviatedRdfXmlWriter(OutputStream out)
Creates a new RdfXmlWriter that will write to the supplied OutputStream.

Parameters:
out - The OutputStream to write the RDF/XML document to.

AbbreviatedRdfXmlWriter

public AbbreviatedRdfXmlWriter(Writer out)
Creates a new RdfXmlWriter that will write to the supplied Writer.

Parameters:
out - The Writer to write the RDF/XML document to.
Method Detail

startDocument

public void startDocument()
                   throws IOException
Description copied from interface: RdfDocumentWriter
Starts the document writing.

Specified by:
startDocument in interface RdfDocumentWriter
Overrides:
startDocument in class RdfXmlWriter
Throws:
IOException

endDocument

public void endDocument()
                 throws IOException
Description copied from interface: RdfDocumentWriter
Ends the document writing.

Specified by:
endDocument in interface RdfDocumentWriter
Overrides:
endDocument in class RdfXmlWriter
Throws:
IOException

flush

public void flush()
           throws IOException
Throws:
IOException

writeStatement

public void writeStatement(Resource subj,
                           URI pred,
                           Value obj)
                    throws IOException
Description copied from interface: RdfDocumentWriter
Writes a statement to the document. The startDocument() method should have been called before.

Specified by:
writeStatement in interface RdfDocumentWriter
Overrides:
writeStatement in class RdfXmlWriter
Throws:
IOException

writeComment

public void writeComment(String comment)
                  throws IOException
Description copied from interface: RdfDocumentWriter
Writes a comment to the document. An implementation may ignore these calls if the format doesn't support comments.

Specified by:
writeComment in interface RdfDocumentWriter
Overrides:
writeComment in class RdfXmlWriter
Throws:
IOException


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.