Package com.stardog.stark.io.rdfxml
Class RDFXMLPrettyWriter
- java.lang.Object
-
- com.stardog.stark.io.rdfxml.RDFXMLWriter
-
- com.stardog.stark.io.rdfxml.RDFXMLPrettyWriter
-
- All Implemented Interfaces:
RDFHandler
,RDFWriter
,java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public final class RDFXMLPrettyWriter extends RDFXMLWriter implements java.io.Closeable, java.io.Flushable
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 RDFWriter. 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 rdf:about="..."> ... </foaf:Person>
instead of<rdf:Description rdf:about="..."> <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), Michael Grove
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.stardog.stark.io.rdfxml.RDFXMLWriter
RDFXMLWriter.RDFXMLWriterFactory
-
-
Field Summary
-
Fields inherited from class com.stardog.stark.io.rdfxml.RDFXMLWriter
defaultNamespace, headerWritten, lastWrittenSubject, mOptions, mWriter, namespaceTable, writingStarted
-
-
Constructor Summary
Constructors Constructor Description RDFXMLPrettyWriter(java.io.OutputStream theStream, Options theOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
protected void
flushPendingStatements()
void
handle(Statement theStmt)
Write the givenStatement
protected void
writeHeader()
protected void
writeIndents(int n)
Writes n indents.protected void
writeStartTag(java.lang.String namespace, java.lang.String localName)
-
Methods inherited from class com.stardog.stark.io.rdfxml.RDFXMLWriter
comment, end, format, getValidNodeId, namespace, setNamespace, start, writeAttribute, writeAttribute, writeCharacterData, writeEndOfEmptyTag, writeEndOfStartTag, writeEndTag, writeIndent, writeNewLine, writeStartOfStartTag
-
-
-
-
Constructor Detail
-
RDFXMLPrettyWriter
public RDFXMLPrettyWriter(java.io.OutputStream theStream, Options theOptions)
-
-
Method Detail
-
writeHeader
protected void writeHeader() throws java.io.IOException
- Overrides:
writeHeader
in classRDFXMLWriter
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
flushPendingStatements
protected void flushPendingStatements() throws java.io.IOException, WritingFailed
- Overrides:
flushPendingStatements
in classRDFXMLWriter
- Throws:
java.io.IOException
WritingFailed
-
handle
public void handle(@Nonnull Statement theStmt) throws WritingFailed
Write the givenStatement
- Specified by:
handle
in interfaceRDFHandler
- Specified by:
handle
in interfaceRDFWriter
- Overrides:
handle
in classRDFXMLWriter
- Parameters:
theStmt
- the statement to write- Throws:
WritingFailed
-
writeStartTag
protected void writeStartTag(java.lang.String namespace, java.lang.String localName) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIndents
protected void writeIndents(int n) throws java.io.IOException
Writes n indents.- Throws:
java.io.IOException
-
-