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 2011/11/15 12:46:07 UTC

svn commit: r1202139 - in /incubator/jena/Jena2/ARQ/trunk: ./ src/main/java/com/hp/hpl/jena/sparql/expr/nodevalue/ src/main/java/com/hp/hpl/jena/sparql/graph/ src/test/java/com/hp/hpl/jena/sparql/expr/ testing/ARQ/ExprBuiltIns/ testing/DAWG-Final/expr-...

Author: andy
Date: Tue Nov 15 11:46:06 2011
New Revision: 1202139

URL: http://svn.apache.org/viewvc?rev=1202139&view=rev
Log:
RDF 1.1 / SPARQL 1.1 change: DADATYPE(literal-with-lang-tag) is now rdf:langString, not an error.

Added:
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-4.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-4.srx
Modified:
    incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/expr/nodevalue/NodeFunctions.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java
    incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/expr/TestNodeFunctions.java
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/manifest.ttl
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-3.rq
    incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-2.srx
    incubator/jena/Jena2/ARQ/trunk/testing/DAWG-Final/expr-builtin/manifest.ttl

Modified: incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt (original)
+++ incubator/jena/Jena2/ARQ/trunk/ChangeLog.txt Tue Nov 15 11:46:06 2011
@@ -4,6 +4,7 @@ ChangeLog for ARQ
 ==== ARQ 2.8.9
 ** Java 6 is now required for running ARQ.
 
++ SPARQL 1.1 / RDF 1.1 : DATATYPE(literal-with-lang) is now rdf:langString, not an error.
 + DatasetFactory: perferred methods for an in-memory dataset are:
      create() -- will automatically add in-memory named graphs  
      createFixed() -- needs explicitly added extra graph  

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/expr/nodevalue/NodeFunctions.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/expr/nodevalue/NodeFunctions.java?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/expr/nodevalue/NodeFunctions.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/expr/nodevalue/NodeFunctions.java Tue Nov 15 11:46:06 2011
@@ -30,6 +30,7 @@ import com.hp.hpl.jena.iri.Violation ;
 import com.hp.hpl.jena.sparql.expr.ExprEvalException ;
 import com.hp.hpl.jena.sparql.expr.ExprTypeException ;
 import com.hp.hpl.jena.sparql.expr.NodeValue ;
+import com.hp.hpl.jena.sparql.graph.NodeConst ;
 import com.hp.hpl.jena.sparql.util.FmtUtils ;
 import com.hp.hpl.jena.vocabulary.XSD ;
 
@@ -39,7 +40,6 @@ import com.hp.hpl.jena.vocabulary.XSD ;
 public class NodeFunctions
 {
     private static final NodeValue xsdString = NodeValue.makeNode(XSD.xstring.asNode()) ;
-    
 
     // Helper functions
     /** check and get a string (may be a simple literal, literal with language tag or an XSD string). */
@@ -175,7 +175,7 @@ public class NodeFunctions
         {
             boolean simpleLiteral = (node.getLiteralLanguage() == null || node.getLiteralLanguage().equals("") ) ;
             if ( ! simpleLiteral )
-                NodeValue.raise(new ExprTypeException("datatype: Literal has language tag: "+node) );
+                return NodeConst.dtRDFlangString ;
             return XSD.xstring.asNode() ;
         }
         return Node.createURI(s) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/graph/NodeConst.java Tue Nov 15 11:46:06 2011
@@ -39,4 +39,6 @@ public class NodeConst
     public static final Node nodeNil        = RDF.Nodes.nil ;
     
     public static final Node nodeOwlSameAs  = OWL.sameAs.asNode() ;
+    public static final Node dtRDFlangString = Node.createURI(RDF.getURI()+"langString") ;
+
 }

Modified: incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/expr/TestNodeFunctions.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/expr/TestNodeFunctions.java?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/expr/TestNodeFunctions.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/expr/TestNodeFunctions.java Tue Nov 15 11:46:06 2011
@@ -25,6 +25,7 @@ import org.junit.Test ;
 import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.sparql.expr.nodevalue.NodeFunctions ;
+import com.hp.hpl.jena.sparql.graph.NodeConst ;
 import com.hp.hpl.jena.vocabulary.XSD ;
 
 public class TestNodeFunctions extends TestCase
@@ -171,11 +172,16 @@ public class TestNodeFunctions extends T
     @Test public void testDatatype4()
     {
         NodeValue nv = NodeValue.makeNode("abc", "fr", (String)null) ;
-        try {
-            NodeValue r = NodeFunctions.datatype(nv) ;
-            fail("Expect a type exception but call succeeded") ;
-        }
-        catch (ExprTypeException ex) {} 
+        // SPARQL 1.0
+//        try {
+//            NodeValue r = NodeFunctions.datatype(nv) ;
+//            fail("Expect a type exception but call succeeded") ;
+//        }
+//        catch (ExprTypeException ex) {}
+        // SPARQL 1.1 / RDF 1.1
+        NodeValue r = NodeFunctions.datatype(nv) ;
+        NodeValue e = NodeValue.makeNode(NodeConst.dtRDFlangString) ;
+        assertEquals(e, r) ;
     }
 
     @Test public void testDatatype5()

Modified: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/manifest.ttl
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/manifest.ttl?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/manifest.ttl (original)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/manifest.ttl Tue Nov 15 11:46:06 2011
@@ -61,6 +61,13 @@
               qt:data   <data-builtin-2.ttl> ] ;
         mf:result  <result-datatype-3.srx>
       ]
+      [
+         mf:name "datatype-4 : Literals with a datatype of rdf:langString" ;
+         mf:action
+            [ qt:query  <q-datatype-4.rq> ;
+              qt:data   <data-builtin-2.ttl> ] ;
+        mf:result  <result-datatype-4.srx>
+      ]
 
       [
          mf:name "lang-1 : Literals with a lang tag of some kind" ;

Modified: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-3.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-3.rq?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-3.rq (original)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-3.rq Tue Nov 15 11:46:06 2011
@@ -1,4 +1,4 @@
-# Whichliterals have xsd:string as a datatype
+# Which literals have xsd:string as a datatype
 
 PREFIX : <http://example/> 
 PREFIX  xsd:    <http://www.w3.org/2001/XMLSchema#>

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-4.rq
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-4.rq?rev=1202139&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-4.rq (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/q-datatype-4.rq Tue Nov 15 11:46:06 2011
@@ -0,0 +1,10 @@
+# Which literals have xsd:string as a datatype
+
+PREFIX :        <http://example/> 
+PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
+PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+SELECT ?x
+{ ?x :p ?v . 
+  FILTER( datatype(?v) = rdf:langString ) 
+}

Modified: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-2.srx
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-2.srx?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-2.srx (original)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-2.srx Tue Nov 15 11:46:06 2011
@@ -1,30 +1,32 @@
 <?xml version="1.0"?>
-<sparql
-    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-    xmlns:xs="http://www.w3.org/2001/XMLSchema#"
-    xmlns="http://www.w3.org/2005/sparql-results#" >
+<sparql xmlns="http://www.w3.org/2005/sparql-results#">
   <head>
     <variable name="x"/>
   </head>
   <results>
     <result>
       <binding name="x">
-        <uri>http://example/x1</uri>
+        <uri>http://example/x5</uri>
       </binding>
     </result>
     <result>
       <binding name="x">
-        <uri>http://example/x2</uri>
+        <uri>http://example/x4</uri>
       </binding>
     </result>
     <result>
       <binding name="x">
-        <uri>http://example/x4</uri>
+        <uri>http://example/x3</uri>
       </binding>
     </result>
     <result>
       <binding name="x">
-        <uri>http://example/x5</uri>
+        <uri>http://example/x2</uri>
+      </binding>
+    </result>
+    <result>
+      <binding name="x">
+        <uri>http://example/x1</uri>
       </binding>
     </result>
   </results>

Added: incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-4.srx
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-4.srx?rev=1202139&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-4.srx (added)
+++ incubator/jena/Jena2/ARQ/trunk/testing/ARQ/ExprBuiltIns/result-datatype-4.srx Tue Nov 15 11:46:06 2011
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<sparql xmlns="http://www.w3.org/2005/sparql-results#">
+  <head>
+    <variable name="x"/>
+  </head>
+  <results>
+    <result>
+      <binding name="x">
+        <uri>http://example/x3</uri>
+      </binding>
+    </result>
+  </results>
+</sparql>

Modified: incubator/jena/Jena2/ARQ/trunk/testing/DAWG-Final/expr-builtin/manifest.ttl
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/testing/DAWG-Final/expr-builtin/manifest.ttl?rev=1202139&r1=1202138&r2=1202139&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/testing/DAWG-Final/expr-builtin/manifest.ttl (original)
+++ incubator/jena/Jena2/ARQ/trunk/testing/DAWG-Final/expr-builtin/manifest.ttl Tue Nov 15 11:46:06 2011
@@ -11,7 +11,10 @@
     rdfs:comment  "DAWG Expression tests: Built-ins" ;
     mf:entries
     ( :dawg-str-1 :dawg-str-2 :dawg-str-3 :dawg-str-4
-      :dawg-isBlank-1 :dawg-isLiteral-1 :dawg-datatype-1 :dawg-datatype-2 :dawg-datatype-3
+      :dawg-isBlank-1 :dawg-isLiteral-1 :dawg-datatype-1 
+      ## remove test - chnages for SPARQL 1.1 and RDF 1.1 (rdf:langString)
+      ##:dawg-datatype-2 
+      :dawg-datatype-3
       :dawg-lang-1 :dawg-lang-2 :dawg-lang-3 :dawg-isURI-1
       :dawg-isIRI-1 :dawg-langMatches-1 :dawg-langMatches-2 
       :dawg-langMatches-3 :dawg-langMatches-4 :dawg-langMatches-basic