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,Closeable,Flushable,AutoCloseable
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()protected voidvoidWrite the givenStatementprotected voidprotected voidwriteIndents(int n) Writes n indents.protected voidwriteStartTag(String namespace, 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 Details
-
RDFXMLPrettyWriter
-
-
Method Details
-
writeHeader
- Overrides:
writeHeaderin classRDFXMLWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
flushPendingStatements
- Overrides:
flushPendingStatementsin classRDFXMLWriter- Throws:
IOExceptionWritingFailed
-
handle
Write the givenStatement- Specified by:
handlein interfaceRDFHandler- Specified by:
handlein interfaceRDFWriter- Overrides:
handlein classRDFXMLWriter- Parameters:
theStmt- the statement to write- Throws:
WritingFailed
-
writeStartTag
- Throws:
IOException
-
writeIndents
Writes n indents.- Throws:
IOException
-