jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1549606 - in /jena/trunk/jena-arq: ReleaseNotes.txt src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java
Date Mon, 09 Dec 2013 16:25:37 GMT
Author: andy
Date: Mon Dec  9 16:25:37 2013
New Revision: 1549606

URL: http://svn.apache.org/r1549606
Log:
JENA-606 : pass resolved URI to StreamRDF and hence to model prefix mapping.

Modified:
    jena/trunk/jena-arq/ReleaseNotes.txt
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java

Modified: jena/trunk/jena-arq/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/ReleaseNotes.txt?rev=1549606&r1=1549605&r2=1549606&view=diff
==============================================================================
--- jena/trunk/jena-arq/ReleaseNotes.txt (original)
+++ jena/trunk/jena-arq/ReleaseNotes.txt Mon Dec  9 16:25:37 2013
@@ -4,6 +4,11 @@ ChangeLog for ARQ
 
 ==== Jena 2.11.1
 
+RDF 1.1 Language support (Turtle, TriG, N-Triples, N-Quads)
+
++ JENA-606 : URIs for prefixes are resolved (made absolute) before adding
+             to a models prefix mapping. Previously, they were left as
+             relative, ifrelative URis in the document.
 + Fix a couple of possible deadlock conditions when using PipedRDFIterator
 
 ==== Jena 2.11.0

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java?rev=1549606&r1=1549605&r2=1549606&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangTurtleBase.java Mon Dec
 9 16:25:37 2013
@@ -159,10 +159,9 @@ public abstract class LangTurtleBase ext
         if ( !lookingAt(IRI) )
             exception(peekToken(), "@prefix requires an IRI (found '" + peekToken() + "')")
;
         String iriStr = peekToken().getImage() ;
-        dest.prefix(prefix, iriStr) ;
         IRI iri = profile.makeIRI(iriStr, currLine, currCol) ;
         profile.getPrologue().getPrefixMap().add(prefix, iri) ;
-
+        emitPrefix(prefix, iri.toString()) ;
         nextToken() ;
     }
 
@@ -170,14 +169,15 @@ public abstract class LangTurtleBase ext
         Token token = peekToken() ;
         if ( !lookingAt(IRI) )
             exception(token, "@base requires an IRI (found '" + token + "')") ;
-
         String baseStr = token.getImage() ;
-        dest.base(baseStr) ;
         IRI baseIRI = profile.makeIRI(baseStr, currLine, currCol) ;
+        emitBase(baseIRI.toString()) ;
         nextToken() ;
         profile.getPrologue().setBaseURI(baseIRI) ;
     }
 
+    
+
     // Unlike many operations in this parser suite
     // this does not assume that we have definitely
     // entering this state. It does checks and may
@@ -348,7 +348,7 @@ public abstract class LangTurtleBase ext
     protected final void objectList(Node subject, Node predicate) {
         for (;;) {
             Node object = triplesNode() ;
-            checkEmitTriple(subject, predicate, object) ;
+            emitTriple(subject, predicate, object) ;
 
             if ( !moreTokens() )
                 break ;
@@ -456,10 +456,10 @@ public abstract class LangTurtleBase ext
             if ( listHead == null )
                 listHead = nextCell ;
             if ( lastCell != null )
-                checkEmitTriple(lastCell, NodeConst.nodeRest, nextCell) ;
+                emitTriple(lastCell, NodeConst.nodeRest, nextCell) ;
             lastCell = nextCell ;
 
-            checkEmitTriple(nextCell, NodeConst.nodeFirst, n) ;
+            emitTriple(nextCell, NodeConst.nodeFirst, n) ;
 
             if ( !moreTokens() ) // Error.
                 break ;
@@ -471,7 +471,7 @@ public abstract class LangTurtleBase ext
             return NodeConst.nodeNil ;
 
         // Finish list.
-        checkEmitTriple(lastCell, NodeConst.nodeRest, NodeConst.nodeNil) ;
+        emitTriple(lastCell, NodeConst.nodeRest, NodeConst.nodeNil) ;
 
         finishList() ;
 
@@ -484,10 +484,18 @@ public abstract class LangTurtleBase ext
     // Signal end of a list
     protected void startList() {}
 
-    protected final void checkEmitTriple(Node subject, Node predicate, Node object) {
+    protected final void emitTriple(Node subject, Node predicate, Node object) {
         emit(subject, predicate, object) ;
     }
 
+    private final void emitPrefix(String prefix, String iriStr) {
+        dest.prefix(prefix, iriStr) ; 
+    }
+
+    private final void emitBase(String baseStr) { 
+        dest.base(baseStr);
+    }
+
     protected final Node tokenAsNode(Token token) {
         return profile.create(currentGraph, token) ;
     }

Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java?rev=1549606&r1=1549605&r2=1549606&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLangTurtle.java Mon Dec
 9 16:25:37 2013
@@ -79,7 +79,7 @@ public class TestLangTurtle extends Base
     }
 
     
-    @Test public void updatePrefixMapping()
+    @Test public void updatePrefixMapping1()
     {
         Model model = ModelFactory.createDefaultModel() ;
         StringReader reader = new StringReader("@prefix x: <http://example/x>.") ;
@@ -88,6 +88,17 @@ public class TestLangTurtle extends Base
         assertEquals("http://example/x", model.getNsPrefixURI("x")) ;
     }
     
+    @Test public void updatePrefixMapping2()
+    {
+        // Test that prefixes are resolved
+        Model model = ModelFactory.createDefaultModel() ;
+        StringReader reader = new StringReader("BASE <http://example/> PREFIX x: <abc>")
;
+        RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE) ;
+        assertEquals(1, model.getNsPrefixMap().size()) ;
+        assertEquals("http://example/abc", model.getNsPrefixURI("x")) ;
+    }
+    
+
     @Test public void optionalDotInPrefix()
     {
         Model model = ModelFactory.createDefaultModel() ;



Mime
View raw message