You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/02/20 20:17:37 UTC
svn commit: r1448354 - in /jena/Experimental/riot-output: ./
src/main/java/dev/ src/main/java/riot/ src/main/java/riot/system/
src/main/java/riot/writer/ src/test/java/riot/writer/ testing/RIOT/Writer/
Author: andy
Date: Wed Feb 20 19:17:37 2013
New Revision: 1448354
URL: http://svn.apache.org/r1448354
Log:
Tidy up constants
Added:
jena/Experimental/riot-output/EX.ttl
jena/Experimental/riot-output/testing/RIOT/Writer/writer-rt-17.ttl
Modified:
jena/Experimental/riot-output/.classpath
jena/Experimental/riot-output/riot-output-doc.mdtest
jena/Experimental/riot-output/src/main/java/dev/MainWriter.java
jena/Experimental/riot-output/src/main/java/dev/PROJECT_RiotWriter.java
jena/Experimental/riot-output/src/main/java/riot/RDFFormat.java
jena/Experimental/riot-output/src/main/java/riot/RDFWriterRegistry.java
jena/Experimental/riot-output/src/main/java/riot/system/IO_Jena2.java
jena/Experimental/riot-output/src/main/java/riot/writer/TurtleShell.java
jena/Experimental/riot-output/src/main/java/riot/writer/WriterConst.java
jena/Experimental/riot-output/src/main/java/riot/writer/WriterStreamRDFBlocks.java
jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterDataset.java
jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterGraph.java
Modified: jena/Experimental/riot-output/.classpath
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/.classpath?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/.classpath (original)
+++ jena/Experimental/riot-output/.classpath Wed Feb 20 19:17:37 2013
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
- <classpathentry including="**/*.java" kind="src" path="src/test/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry combineaccessrules="false" kind="src" path="/jena-arq"/>
- <classpathentry combineaccessrules="false" kind="src" path="/jena-core"/>
- <classpathentry kind="lib" path="/home/afs/.m2/repo/org/apache/jena/jena-iri/0.9.5-SNAPSHOT/jena-iri-0.9.5-SNAPSHOT.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/jena-tdb"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.4/jcl-over-slf4j-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.4/jcl-over-slf4j-1.6.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar"/>
- <classpathentry kind="output" path="classes"/>
+ <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+ <classpathentry including="**/*.java" kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-arq"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-core"/>
+ <classpathentry kind="lib" path="/home/afs/.m2/repo/org/apache/jena/jena-iri/0.9.6-SNAPSHOT/jena-iri-0.9.6-SNAPSHOT.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-tdb"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.4/jcl-over-slf4j-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.4/jcl-over-slf4j-1.6.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar"/>
+ <classpathentry kind="output" path="classes"/>
</classpath>
Added: jena/Experimental/riot-output/EX.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/EX.ttl?rev=1448354&view=auto
==============================================================================
--- jena/Experimental/riot-output/EX.ttl (added)
+++ jena/Experimental/riot-output/EX.ttl Wed Feb 20 19:17:37 2013
@@ -0,0 +1,16 @@
+@prefix : <http://example/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix dc: <http://purl.org/dc/elements/1.1/> .
+
+:a a foaf:Person ;
+ foaf:name "Alice" ;
+ foaf:knows [ foaf:name "Bob" ]
+ .
+
+:b foaf:knows :a .
+
+
+:book dc:author ( :a :b ) .
+
+
Modified: jena/Experimental/riot-output/riot-output-doc.mdtest
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/riot-output-doc.mdtest?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/riot-output-doc.mdtest (original)
+++ jena/Experimental/riot-output/riot-output-doc.mdtest Wed Feb 20 19:17:37 2013
@@ -1,20 +1,42 @@
Title: Reading and Writing RDF in Apache Jena
-## Output
+This page describes the RIOT(RDF I/O technology) output capabilities.
+
+See [Reading RDF](index.html) for details of the RIOT Reader system.
+
+- [API](API)
+- [RDFFormat](rdfformat)
+- [`RDFFormat`s and Jena syntax names](rdfformats-and-jena-syntax-names)
+- [Formats](formats)
+ - [Normal Printing](normal-printing)
+ - [Pretty Printed Languages](pretty-printed-formats)
+ - [Streamed Block Formats](streamed-block-formats)
+ - [Line printed formats](line-printed-formats)
+ - [N-triples and N-Quads](n-triples-and-n-quads)
+ - [RDF/XML](rdfxml)
+- [Examples](examples)
+- [Notes](Notes)
+
+## API
There are two ways to write RDF data using Apache Jena RIOT,
-either via the `RDFDataMgr` or using the `model` API.
+either via the `RDFDataMgr`
RDFDataMgr.write(OutputStream, Model, RDFFormat) ;
RDFDataMgr.write(OutputStream, Dataset, RDFFormat) ;
-and with the `model` API:
+or using the `model` API:
- model.write(output, "format") ;
+ model.write(output, "<i>format</i>") ;
+
+The `<i>format</i>` names are described below; they are a superset of the
+names Jena has supported before RIOT.
Many variations of these methods exist. See the full javadoc for details.
-Output using RIOT depend on the format, which involves both the language (syntax)
+## `RDFFormat`
+
+Output using RIOT depends on the format, which involves both the language (syntax)
being written and the variant of that syntax.
The RIOT writer architecture is extensible. The following languages
@@ -29,16 +51,19 @@ are available as part of the standard se
In addition, there are variants of Trutle, TriG for pretty printing,
streamed output and flat output. RDF/XML has variants for pretty printing
-and plain output. Jena RIOT uses `RDFFormat` as a way to identfy the language
-and variant to be written.
+and plain output. Jena RIOT uses `org.apache.jena.riot.RDFFormat` as a way
+to identfy the language and variant to be written. The class contains constants
+for the standard supported formats.
Note:
+
* RDF/JSON is not JSON-LD. See the [description of RDF/JSON](rdf-json.html)].
* N3 is treated as Turtle for output.
-## Relationship between `RDFFormat`s and Jena syntax names
+## `RDFFormat`s and Jena syntax names
-The string name traditionally used in `model.write` is mapped to RIOT `RDFFormat` as:
+The string name traditionally used in `model.write` is mapped to RIOT `RDFFormat`
+as follows:
| Jena writer name | RIOT RDFFormat |
|----------------------|------------------|
@@ -53,29 +78,38 @@ The string name traditionally used in `m
| `"N3"` | `N3` |
| `"RDF/JSON"` | `RDFJSON` |
-## Normal Printing
+## Formats
+
+### Normal Printing
A `Lang` can be used for the writer format, in which case it is mapped to
an `RDFFormat` internally. The normal writers are:
-| RDFFormat or Lang | |
-|-------------------|------------------------|
-| TURTLE | Turtle, pretty printed |
-| TTL | Same |
-| NTRIPLES | N-triples |
-| TRIG | TriG, pretty printed |
-| NQUADS | |
+| RDFFormat or Lang | |
+|-------------------|-------------------------|
+| TURTLE | Turtle, pretty printed |
+| TTL | Same |
+| NTRIPLES | N-triples |
+| TRIG | TriG, pretty printed |
+| NQUADS | |
| RDFXML | RDF/XML, pretty printed |
Pretty printed RDF/XML is also known as RDF/XML-ABBREV
-## Pretty Printed Languages
+### Pretty Printed Languages
+
+All Turtle and TriG formats use
+prefix names, and short forms for literals.
-The pretty printed versions of Turtle and TriG
+The pretty printed versions of Turtle and TriG prints
+data with the same subject in the same graph together.
+All the properties for a given subject are sorted
+into a predefined order. RDF lists are printed as
+`(...)` and `[...]` is used for blank nodes where possible.
The analysis for determing what can be pretty printed requires
temporary datastructures and also a scan of the whole graph before
-writing starts. Theerfore, pretty printed formats are not suitable
+writing begins. Therefore, pretty printed formats are not suitable
for writing persistent graphs and datasets.
When writing at scale use either a "blocked" version of Turtle or TriG,
@@ -83,7 +117,18 @@ or write N-triples/N-Quads.
Example:
-@@TODO
+ @prefix : <http://example/> .
+ @prefix dc: <http://purl.org/dc/elements/1.1/> .
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+
+ :book dc:author ( :a :b ) .
+
+ :a a foaf:Person ;
+ foaf:knows [ foaf:name "Bob" ] ;
+ foaf:name "Alice" .
+
+ :b foaf:knows :a .
Pretty printed formats:
@@ -93,22 +138,41 @@ Pretty printed formats:
| TRIG_PRETTY | TRIG |
| RDFXML_PRETTY | RDFXML_ABBREV, RDFXML |
-## Streamed Block Formats
+### Streamed Block Formats
-The streamed formats writes a stream of triples or quads,
-and writes them in blocks, clustered by adjacent subject or graph/subject
+The streamed formats write triples or quads as given.
+They group together data by adjacent subject or graph/subject
in the output stream.
The written data is like the pretty printed forms but without
-RDF lists being written in the '(...)' form, nor bNodes using `[...]`.
+RDF lists being written in the '(...)' form, and it does not
+use the blank node form `[...]`.
-This gives a degree of readability while not requiring temporary datastructure.
-Data of any size can be written but bnode labels need to be tracked in order
-to use the short label form.
+This gives some degree of readability while not requiring
+excessive temporary datastructure. Data of any size can be written
+but blank node labels need to be tracked in order to use the short
+label form.
Example:
-@@TODO
+The streaming writer writes each triple as it is presented. It can abbreviate
+IRIs and literals, and do some alignment.
+
+ @prefix : <http://example/> .
+ @prefix dc: <http://purl.org/dc/elements/1.1/> .
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+
+ _:b0 foaf:name "Bob" .
+ :book dc:author _:b1 .
+ _:b2 rdf:rest rdf:nil ;
+ rdf:first :b .
+ :a foaf:knows _:b0 ;
+ foaf:name "Alice" ;
+ rdf:type foaf:Person .
+ _:b1 rdf:rest _:b2 ;
+ rdf:first :a .
+ :b foaf:knows :a .
Formats:
@@ -117,7 +181,7 @@ Formats:
| TURTLE_BLOCKS |
| TRIG_BLOCKS |
-## Line printed
+### Line printed
There are writers for Turtle and Trig that use the abbreviated formats for
prefix names and short forms for literals. They write each triple or quad
@@ -126,38 +190,77 @@ on a single line.
The regularity of the output can be useful for test processing data.
These formats do not offer more scalabilty than the stream forms.
+Example:
+
+The FLAT writers abbreviates IRIs, literals and blank node labels
+but always writes one complete triple on one line (no use of `;`).
+
+ @prefix : <http://example/> .
+ @prefix dc: <http://purl.org/dc/elements/1.1/> .
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ _:b0 foaf:name "Bob" .
+ :book dc:author _:b1 .
+ _:b2 rdf:rest rdf:nil .
+ _:b2 rdf:first :b .
+ :a foaf:knows _:b0 .
+ :a foaf:name "Alice" .
+ :a rdf:type foaf:Person .
+ _:b1 rdf:rest _:b2 .
+ _:b1 rdf:first :a .
+ :b foaf:knows :a .
+
+
| RDFFormat |
-|------------ |
+|-------------|
| TURTLE_FLAT |
| TRIG_FLAT |
-## N-triples / N-Quads
+### N-triples and N-Quads
-These provide the formats that are fastest to written,
+These provide the formats that are fastest to write,
and data of any size can be output. They do not use any
internal state. They maximise the
-interoperability with other systems and are used
+interoperability with other systems and are useful
for database dumps. They are not human readable,
even at moderate scale.
The files can be large but they compress well with gzip.
-Compression ratios of x8-x10 can often be achieved.
+Compression ratios of x8-x10 can often be obtained.
+
+Example:
+
+The N-Triples writer makes no attempt to make it's output readable.
+It uses internal blank nodes to ensure correct labeling without
+needing any writer state.
+
+ _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7fff <http://xmlns.com/foaf/0.1/name> "Bob" .
+ <http://example/book> <http://purl.org/dc/elements/1.1/author> _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7ffe .
+ _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7ffd <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
+ _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7ffd <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example/b> .
+ <http://example/a> <http://xmlns.com/foaf/0.1/knows> _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7fff .
+ <http://example/a> <http://xmlns.com/foaf/0.1/name> "Alice" .
+ <http://example/a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
+ _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7ffe <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7ffd .
+ _:BX2Dc2b3371X3A13cf8faaf53X3AX2D7ffe <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example/a> .
+ <http://example/b> <http://xmlns.com/foaf/0.1/knows> <http://example/a> .
+
| RDFFormat | Other names |
|-----------|-----------------|
| NTRIPLE | NTRIPLE, NT, NQ |
| NQUADS | NQUADS |
-## RDF/XML
+### RDF/XML
-RIOT support output in RDF/XML. RIOt RDFFormats defaults to pretty printed RDF/XML,
+RIOT supports output in RDF/XML. RIOT RDFFormats defaults to pretty printed RDF/XML,
while the jena writer writer name defaults to a streaming plain output.
| RDFFormat | Other names | Jena writer name |
|-----------|--------------------------|-----------------------------|
| RDFXML | RDFXML_PRETTY, RDF_XML_ABBREV | "RDF/XML-ABBREV" |
| RDFXML_PLAIN | | "RDF/XML" |
-
+
## Notes
Using `OutputStream`s is strongly encouraged. This allows the writers
Modified: jena/Experimental/riot-output/src/main/java/dev/MainWriter.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/dev/MainWriter.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/dev/MainWriter.java (original)
+++ jena/Experimental/riot-output/src/main/java/dev/MainWriter.java Wed Feb 20 19:17:37 2013
@@ -47,20 +47,10 @@ public class MainWriter
{
public static void main(String ...args)
{
-// writeAll() ;
-// System.exit(0) ;
-
-// Dataset ds = RDFDataMgr.loadDataset("W.trig") ;
-// RDFWriterMgr.write(System.out, ds, RDFFormat.TRIG_FLAT ) ;
-// System.out.println("DONE") ;
-// System.exit(0) ;
-
- Model m = RDFDataMgr.loadModel("D.ttl") ;
- RDFWriterMgr.write(System.out, m, RDFFormat.TTL ) ;
- System.out.println("DONE") ;
+ writeAll() ;
System.exit(0) ;
- //
-// String fn = "D.ttl" ;
+
+// String fn = "D.ttl" ;
//
// Model m = RDFDataMgr.loadModel(fn) ;
// Writer out = new OutputStreamWriter(System.out) ;
@@ -81,7 +71,7 @@ public class MainWriter
public static void writeAll()
{
- String fn = "D.ttl" ;
+ String fn = "EX.ttl" ;
Model m = RDFDataMgr.loadModel(fn) ;
RDFFormat formats[] = {
@@ -90,12 +80,12 @@ public class MainWriter
, RDFFormat.TURTLE_BLOCKS
, RDFFormat.TURTLE_FLAT
, RDFFormat.NTRIPLES
- , RDFFormat.TRIG
- , RDFFormat.TRIG_BLOCKS
- , RDFFormat.TRIG_FLAT
- , RDFFormat.NQUADS
- , RDFFormat.RDFXML
- , RDFFormat.RDFXML_PLAIN
+// , RDFFormat.TRIG
+// , RDFFormat.TRIG_BLOCKS
+// , RDFFormat.TRIG_FLAT
+// , RDFFormat.NQUADS
+// , RDFFormat.RDFXML
+// , RDFFormat.RDFXML_PLAIN
} ;
for ( RDFFormat f : formats )
Modified: jena/Experimental/riot-output/src/main/java/dev/PROJECT_RiotWriter.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/dev/PROJECT_RiotWriter.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/dev/PROJECT_RiotWriter.java (original)
+++ jena/Experimental/riot-output/src/main/java/dev/PROJECT_RiotWriter.java Wed Feb 20 19:17:37 2013
@@ -23,20 +23,20 @@ public class PROJECT_RiotWriter
{
// JSON-LD
- // * Internationalization tests ?
// * riot --out FMT (later?)
// * Migration: RDFWriter -> RDFDataMgr
- // * Create test files for long subject/predicate/object
// RDFDataMgr.write(filename)
+ // Writer names in FusekiLib
+
// Options.
- // Migration
+ // ** Migration
// RIOT.init to call RDFWriterRegistry.init()
// Remove some RIOT.init calls.
-
- // Documentation.
-}
+ // RDFWriter -> RDFDataMgr
+ // IO_Jena2 to JenaReadersWriters
-
\ No newline at end of file
+ // Examples in documentation
+}
\ No newline at end of file
Modified: jena/Experimental/riot-output/src/main/java/riot/RDFFormat.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/riot/RDFFormat.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/riot/RDFFormat.java (original)
+++ jena/Experimental/riot-output/src/main/java/riot/RDFFormat.java Wed Feb 20 19:17:37 2013
@@ -48,8 +48,8 @@ public class RDFFormat
public static RDFFormat TRIG_BLOCKS = new RDFFormat(Lang.TRIG, wvBlocks) ;
public static RDFFormat TRIG_FLAT = new RDFFormat(Lang.TRIG, wvFlat) ;
+ public static RDFFormatVariant wvAbbrev = new RDFFormatVariant("pretty" ) ;
public static RDFFormatVariant wvPlain = new RDFFormatVariant("plain" ) ;
- public static RDFFormatVariant wvAbbrev = new RDFFormatVariant("flat" ) ;
public static RDFFormat RDFXML_PRETTY = new RDFFormat(Lang.RDFXML, wvAbbrev) ;
public static RDFFormat RDFXML_ABBREV = RDFXML_PRETTY ;
public static RDFFormat RDFXML = RDFXML_PRETTY ;
Modified: jena/Experimental/riot-output/src/main/java/riot/RDFWriterRegistry.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/riot/RDFWriterRegistry.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/riot/RDFWriterRegistry.java (original)
+++ jena/Experimental/riot-output/src/main/java/riot/RDFWriterRegistry.java Wed Feb 20 19:17:37 2013
@@ -203,22 +203,23 @@ public class RDFWriterRegistry
private static Map<String, RDFFormat> mapJenaNameToFormat = new HashMap<>() ;
static {
- mapJenaNameToFormat.put("RDF/XML", RDFFormat.RDFXML_PLAIN) ;
- mapJenaNameToFormat.put("RDF/XML-ABBREV", RDFFormat.RDFXML_ABBREV) ;
- mapJenaNameToFormat.put("N-TRIPLE", RDFFormat.NTRIPLES) ;
- mapJenaNameToFormat.put("NT", RDFFormat.NTRIPLES) ;
- mapJenaNameToFormat.put("N-TRIPLES", RDFFormat.NTRIPLES) ;
- mapJenaNameToFormat.put("N3", RDFFormat.TURTLE) ;
+ mapJenaNameToFormat.put("RDF/XML", RDFFormat.RDFXML_PLAIN) ;
+ mapJenaNameToFormat.put("RDF/XML-ABBREV", RDFFormat.RDFXML_ABBREV) ;
+ mapJenaNameToFormat.put("N-TRIPLE", RDFFormat.NTRIPLES) ;
+ mapJenaNameToFormat.put("NT", RDFFormat.NTRIPLES) ;
+ mapJenaNameToFormat.put("N-TRIPLES", RDFFormat.NTRIPLES) ;
+ mapJenaNameToFormat.put("N-Triples", RDFFormat.NTRIPLES) ;
+ mapJenaNameToFormat.put("N3", RDFFormat.TURTLE) ;
mapJenaNameToFormat.put(N3JenaWriter.n3WriterPrettyPrinter, RDFFormat.TURTLE_PRETTY) ;
- mapJenaNameToFormat.put(N3JenaWriter.n3WriterPlain, RDFFormat.TURTLE_BLOCKS) ;
- mapJenaNameToFormat.put(N3JenaWriter.n3WriterTriples, RDFFormat.TURTLE_FLAT) ;
- mapJenaNameToFormat.put(N3JenaWriter.n3WriterTriplesAlt, RDFFormat.TURTLE_FLAT) ;
- mapJenaNameToFormat.put(N3JenaWriter.turtleWriter, RDFFormat.TURTLE) ;
- mapJenaNameToFormat.put(N3JenaWriter.turtleWriterAlt1, RDFFormat.TURTLE) ;
- mapJenaNameToFormat.put(N3JenaWriter.turtleWriterAlt2, RDFFormat.TURTLE) ;
+ mapJenaNameToFormat.put(N3JenaWriter.n3WriterPlain, RDFFormat.TURTLE_BLOCKS) ;
+ mapJenaNameToFormat.put(N3JenaWriter.n3WriterTriples, RDFFormat.TURTLE_FLAT) ;
+ mapJenaNameToFormat.put(N3JenaWriter.n3WriterTriplesAlt, RDFFormat.TURTLE_FLAT) ;
+ mapJenaNameToFormat.put(N3JenaWriter.turtleWriter, RDFFormat.TURTLE) ;
+ mapJenaNameToFormat.put(N3JenaWriter.turtleWriterAlt1, RDFFormat.TURTLE) ;
+ mapJenaNameToFormat.put(N3JenaWriter.turtleWriterAlt2, RDFFormat.TURTLE) ;
- mapJenaNameToFormat.put("RDF/JSON", RDFFormat.RDFJSON) ;
- mapJenaNameToFormat.put("RDFJSON", RDFFormat.RDFJSON) ;
+ mapJenaNameToFormat.put("RDF/JSON", RDFFormat.RDFJSON) ;
+ mapJenaNameToFormat.put("RDFJSON", RDFFormat.RDFJSON) ;
}
/** return the RDFFormat for the exisin g Jena writer name, or null */
Modified: jena/Experimental/riot-output/src/main/java/riot/system/IO_Jena2.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/riot/system/IO_Jena2.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/riot/system/IO_Jena2.java (original)
+++ jena/Experimental/riot-output/src/main/java/riot/system/IO_Jena2.java Wed Feb 20 19:17:37 2013
@@ -27,9 +27,9 @@ import com.hp.hpl.jena.rdf.model.impl.RD
public class IO_Jena2
{
// Jena writer adapters
+ // To adapters.JenaReadersWriters
public static class RDFWriterRIOT_RDFXML extends RDFWriterRIOT { public RDFWriterRIOT_RDFXML() { super("RDF/XML") ; } }
public static class RDFWriterRIOT_RDFXMLAbbrev extends RDFWriterRIOT { public RDFWriterRIOT_RDFXMLAbbrev() { super("RDF/XML-ABBREV") ; } }
- public static class RDFWriterRIOT_NTriple extends RDFWriterRIOT { public RDFWriterRIOT_NTriple() { super("N-TRIPLE") ; } }
public static class RDFWriterRIOT_NTriples extends RDFWriterRIOT { public RDFWriterRIOT_NTriples() { super("N-TRIPLES") ; } }
public static class RDFWriterRIOT_N3 extends RDFWriterRIOT { public RDFWriterRIOT_N3() { super("N3") ; } }
public static class RDFWriterRIOT_N3_PP extends RDFWriterRIOT { public RDFWriterRIOT_N3_PP() { super(N3JenaWriter.n3WriterPrettyPrinter) ; } }
@@ -39,24 +39,31 @@ public class IO_Jena2
public static class RDFWriterRIOT_Turtle extends RDFWriterRIOT { public RDFWriterRIOT_Turtle() { super(N3JenaWriter.turtleWriter) ; } }
public static class RDFWriterRIOT_Turtle1 extends RDFWriterRIOT { public RDFWriterRIOT_Turtle1() { super(N3JenaWriter.turtleWriterAlt1) ; } }
public static class RDFWriterRIOT_Turtle2 extends RDFWriterRIOT { public RDFWriterRIOT_Turtle2() { super(N3JenaWriter.turtleWriterAlt2) ; } }
+ public static class RDFWriterRIOT_RDFJSON extends RDFWriterRIOT { public RDFWriterRIOT_RDFJSON() { super("RDF/JSON") ; } }
public static void wireIntoJenaW()
{
// RDFWriterFImpl.LANGS
// RDFWriterFImpl.DEFAULTWRITER
RDFWriterFImpl.setBaseWriterClassName("RDF/XML", RDFWriterRIOT_RDFXML.class.getName()) ;
- RDFWriterFImpl.setBaseWriterClassName("RDF/XML", RDFWriterRIOT_RDFXML.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName("RDF/XML-ABBREV", RDFWriterRIOT_RDFXMLAbbrev.class.getName()) ;
- RDFWriterFImpl.setBaseWriterClassName("N-TRIPLE", RDFWriterRIOT_NTriple.class.getName()) ;
+ RDFWriterFImpl.setBaseWriterClassName("N-TRIPLE", RDFWriterRIOT_NTriples.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName("N-TRIPLES", RDFWriterRIOT_NTriples.class.getName()) ;
+ RDFWriterFImpl.setBaseWriterClassName("N-Triples", RDFWriterRIOT_NTriples.class.getName()) ;
+ RDFWriterFImpl.setBaseWriterClassName("NT", RDFWriterRIOT_NTriples.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName("N3", RDFWriterRIOT_N3.class.getName()) ;
+
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.n3WriterPrettyPrinter, RDFWriterRIOT_N3_PP.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.n3WriterPlain, RDFWriterRIOT_N3Plain.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.n3WriterTriples, RDFWriterRIOT_N3Triples.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.n3WriterTriplesAlt, RDFWriterRIOT_N3TriplesAlt.class.getName()) ;
+
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.turtleWriter, RDFWriterRIOT_Turtle.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.turtleWriterAlt1, RDFWriterRIOT_Turtle1.class.getName()) ;
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.turtleWriterAlt2, RDFWriterRIOT_Turtle2.class.getName()) ;
+
+ RDFWriterFImpl.setBaseWriterClassName("RDF/JSON", RDFWriterRIOT_RDFJSON.class.getName()) ;
+ RDFWriterFImpl.setBaseWriterClassName("RDFJSON", RDFWriterRIOT_RDFJSON.class.getName()) ;
}
public static void resetJenaW()
@@ -67,6 +74,7 @@ public class IO_Jena2
RDFWriterFImpl.setBaseWriterClassName("N-TRIPLE", Jena.PATH + ".rdf.model.impl.NTripleWriter") ;
RDFWriterFImpl.setBaseWriterClassName("N-TRIPLES", Jena.PATH + ".rdf.model.impl.NTripleWriter") ;
+ RDFWriterFImpl.setBaseWriterClassName("N-Triples", Jena.PATH + ".rdf.model.impl.NTripleWriter") ;
RDFWriterFImpl.setBaseWriterClassName("N3", Jena.PATH + ".n3.N3JenaWriter") ;
RDFWriterFImpl.setBaseWriterClassName(N3JenaWriter.n3WriterPrettyPrinter, Jena.PATH + ".n3.N3JenaWriterPP") ;
Modified: jena/Experimental/riot-output/src/main/java/riot/writer/TurtleShell.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/riot/writer/TurtleShell.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/riot/writer/TurtleShell.java (original)
+++ jena/Experimental/riot-output/src/main/java/riot/writer/TurtleShell.java Wed Feb 20 19:17:37 2013
@@ -20,11 +20,12 @@
package riot.writer;
import static org.apache.jena.atlas.lib.Lib.equal ;
+import static riot.writer.WriterConst.GAP_P_O ;
+import static riot.writer.WriterConst.GAP_S_P ;
import static riot.writer.WriterConst.INDENT_OBJECT ;
import static riot.writer.WriterConst.INDENT_PREDICATE ;
import static riot.writer.WriterConst.LONG_PREDICATE ;
import static riot.writer.WriterConst.LONG_SUBJECT ;
-import static riot.writer.WriterConst.MIN_GAP ;
import static riot.writer.WriterConst.OBJECT_LISTS ;
import static riot.writer.WriterConst.RDF_First ;
import static riot.writer.WriterConst.RDF_Nil ;
@@ -292,7 +293,7 @@ public abstract class TurtleShell
if ( out.getCol() > LONG_SUBJECT )
println() ;
else
- gap() ;
+ gap(GAP_S_P) ;
out.incIndent(INDENT_PREDICATE) ;
// ----
// DRY writeCluster.
@@ -384,7 +385,7 @@ public abstract class TurtleShell
if ( out.getCol() > LONG_SUBJECT )
out.println() ;
else
- gap() ;
+ gap(GAP_S_P) ;
out.incIndent(INDENT_PREDICATE) ;
out.pad() ;
writePredicateObjectList(cluster) ;
@@ -482,7 +483,7 @@ public abstract class TurtleShell
{
out.pad(predicateMaxWidth) ;
//out.print(' ', predicateMaxWidth-wPredicate) ;
- gap() ;
+ gap(GAP_P_O) ;
}
// Secondary one should be less
@@ -615,9 +616,9 @@ public abstract class TurtleShell
out.print(x) ;
}
- private void gap()
+ private void gap(int gap)
{
- out.print(' ', MIN_GAP) ;
+ out.print(' ', gap) ;
}
// flush aggressively (debugging)
Modified: jena/Experimental/riot-output/src/main/java/riot/writer/WriterConst.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/riot/writer/WriterConst.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/riot/writer/WriterConst.java (original)
+++ jena/Experimental/riot-output/src/main/java/riot/writer/WriterConst.java Wed Feb 20 19:17:37 2013
@@ -23,11 +23,15 @@ import com.hp.hpl.jena.vocabulary.RDF ;
public class WriterConst
{
+ // Constants for the Turtle/Trig pretty writers (TurtleShell)
public static final int LONG_SUBJECT = 20 ;
public static final int LONG_PREDICATE = 30 ;
public static final int MIN_PREDICATE = 4 ;
public static final int PREFIX_IRI = 15;
+ protected static final int GAP_S_P = 2 ;
+ protected static final int GAP_P_O = 2 ;
+
public static final Node RDF_First = RDF.Nodes.first ;
public static final Node RDF_Rest = RDF.Nodes.rest ;
public static final Node RDF_Nil = RDF.Nodes.nil ;
Modified: jena/Experimental/riot-output/src/main/java/riot/writer/WriterStreamRDFBlocks.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/main/java/riot/writer/WriterStreamRDFBlocks.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/main/java/riot/writer/WriterStreamRDFBlocks.java (original)
+++ jena/Experimental/riot-output/src/main/java/riot/writer/WriterStreamRDFBlocks.java Wed Feb 20 19:17:37 2013
@@ -43,14 +43,16 @@ public class WriterStreamRDFBlocks exten
// TODO
// Min width for properties?
- protected static final boolean NL_GDFT_START = false ; // Newline after { of dft graph
- protected static final boolean NL_GNMD_START = true ; // same, but for named graphs
- protected static final boolean NL_GDFT_END = true ; // Whether the closing } is on a new line
- protected static final boolean NL_GNMD_END = true ; // Whether the closing } is on a new line
+ protected static final boolean NL_GDFT_START = false ; // Newline after { of dft graph
+ protected static final boolean NL_GNMD_START = true ; // same, but for named graphs
+ protected static final boolean NL_GDFT_END = true ; // Whether the closing } is on a new line
+ protected static final boolean NL_GNMD_END = true ; // Whether the closing } is on a new line
+
+ protected static final int INDENT_MIN_S = 6 ; // Range of subject indent
+ protected static final int INDENT_MAX_S = 14 ;
+ protected static final int GAP_S_P = 2 ;
+ protected static final int GAP_P_O = 2 ;
- protected static final int INDENT_MIN_S = 4 ; // Range of subject indent
- protected static final int INDENT_MAX_S = 10 ; // i.e. offset of predicate.
-
protected static final int INDENT_GDFT = 2 ; // Default graph indent
protected static final int INDENT_GNMD = 4 ; // Named graph indent
@@ -122,12 +124,12 @@ public class WriterStreamRDFBlocks exten
endTriples() ;
outputNode(s) ;
- out.print(' ') ;
setSubjectIndent(out.getCurrentOffset()) ;
}
out.pad(subjectIndent()) ;
+ out.print(' ', GAP_S_P) ;
outputNode(p) ;
- out.print(' ') ;
+ out.print(' ', GAP_P_O) ;
outputNode(o) ;
lastSubject = s ;
}
Modified: jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterDataset.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterDataset.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterDataset.java (original)
+++ jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterDataset.java Wed Feb 20 19:17:37 2013
@@ -44,12 +44,12 @@ public class TestRiotWriterDataset exten
@Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
- { RDFFormat.RDFNULL } ,
- { RDFFormat.TRIG } ,
- { RDFFormat.TRIG_PRETTY } ,
- { RDFFormat.TRIG_BLOCKS } ,
- { RDFFormat.TRIG_FLAT } ,
- { RDFFormat.NQUADS} ,
+ { RDFFormat.RDFNULL }
+ , { RDFFormat.TRIG }
+ , { RDFFormat.TRIG_PRETTY }
+ , { RDFFormat.TRIG_BLOCKS }
+ , { RDFFormat.TRIG_FLAT }
+ , { RDFFormat.NQUADS}
}) ;
}
Modified: jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterGraph.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterGraph.java?rev=1448354&r1=1448353&r2=1448354&view=diff
==============================================================================
--- jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterGraph.java (original)
+++ jena/Experimental/riot-output/src/test/java/riot/writer/TestRiotWriterGraph.java Wed Feb 20 19:17:37 2013
@@ -44,24 +44,24 @@ public class TestRiotWriterGraph extends
@Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
- { RDFFormat.RDFNULL } ,
+ { RDFFormat.RDFNULL }
- { RDFFormat.NTRIPLES } ,
- { RDFFormat.TURTLE } ,
- { RDFFormat.TURTLE_PRETTY } ,
- { RDFFormat.TURTLE_BLOCKS } ,
- { RDFFormat.TURTLE_FLAT } ,
- { RDFFormat.RDFXML } ,
- { RDFFormat.RDFXML_PRETTY } ,
- { RDFFormat.RDFXML_PLAIN } ,
- { RDFFormat.RDFJSON } ,
+ , { RDFFormat.NTRIPLES }
+ , { RDFFormat.TURTLE }
+ , { RDFFormat.TURTLE_PRETTY }
+ , { RDFFormat.TURTLE_BLOCKS }
+ , { RDFFormat.TURTLE_FLAT }
+ , { RDFFormat.RDFXML }
+ , { RDFFormat.RDFXML_PRETTY }
+ , { RDFFormat.RDFXML_PLAIN }
+ , { RDFFormat.RDFJSON }
// graph in quad formats.
- { RDFFormat.TRIG } ,
- { RDFFormat.TRIG_PRETTY } ,
- { RDFFormat.TRIG_BLOCKS } ,
- { RDFFormat.TRIG_FLAT } ,
- { RDFFormat.NQUADS} ,
+ , { RDFFormat.TRIG }
+ , { RDFFormat.TRIG_PRETTY }
+ , { RDFFormat.TRIG_BLOCKS }
+ , { RDFFormat.TRIG_FLAT }
+ , { RDFFormat.NQUADS}
}) ;
}
@@ -89,6 +89,7 @@ public class TestRiotWriterGraph extends
@Test public void writer14() { test("writer-rt-14.ttl") ; }
@Test public void writer15() { test("writer-rt-15.ttl") ; }
@Test public void writer16() { test("writer-rt-16.ttl") ; }
+ @Test public void writer17() { test("writer-rt-17.ttl") ; }
private void test(String filename)
{
Added: jena/Experimental/riot-output/testing/RIOT/Writer/writer-rt-17.ttl
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-output/testing/RIOT/Writer/writer-rt-17.ttl?rev=1448354&view=auto
==============================================================================
--- jena/Experimental/riot-output/testing/RIOT/Writer/writer-rt-17.ttl (added)
+++ jena/Experimental/riot-output/testing/RIOT/Writer/writer-rt-17.ttl Wed Feb 20 19:17:37 2013
@@ -0,0 +1,30 @@
+@prefix : <http://example/> .
+@prefix ns: <http://example/ns#> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+
+<http://localhost/longsubject/X01234567890_1> :p :o .
+
+<http://localhost/longsubject/X01234567890_2>
+ :p
+ <http://localhost/longobject/X01234567890> ;
+ :p1 123 .
+
+<http://localhost/longsubject/X01234567890_3>
+ <http://localhost/longpredicate/X01234567890>
+ :o .
+
+<http://localhost/longsubject/X01234567890_4>
+ <http://localhost/longpredicate/X01234567890>
+ <http://localhost/longobject/X01234567890> .
+
+:s1
+ <http://localhost/longpredicate/X01234567890>
+ :o .
+
+:s2
+ :p
+ <http://localhost/longobject/X01234567890> .
+
+
+
+