The SPARQL Results XML Format spec is silent regarding XMLLiteral
datatypes, but the schemas specify that only "text" is allowed in an
srx:literal element. This means that XMLLiteral values must have XML
markup replaced with character entities, or enclosed in a CDATA section.

This is roadblock to fluent processing of RDF data that includes
XMLLiteral values.

Consider for the next revision to specify that XMLLiteral values be
emitted as XML in a non-srx namespace.

The attached patch to the rnc schema (available at
http://www.w3.org/2005/sparql-results) enforces that srx:literal
elements with datatype rdf:XMLLiteral must have element children from a
non-srx namespace.

(The patch also fixes the res: namespace in the schema, which does not
match the namespace URI given in the spec.)

Regards,
--Paul


--- result.rnc	2013-08-21 21:51:05.000000000 -0500
+++ result+xml.rnc	2013-08-21 20:11:03.000000000 -0500
@@ -7,7 +7,7 @@
 #
 
 namespace local = ""
-namespace res = "http://www.w3.org/2007/SPARQL/results#";
+namespace res = "http://www.w3.org/2005/sparql-results#";
 namespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
 datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes";
 
@@ -68,7 +68,7 @@
 # SELECT binding in a solution
 binding = element res:binding {
     nameAttr,
-    ( uri | bnode | literal )
+    ( uri | bnode | literal | xmlLiteral )
 }
 
 uri = element res:uri { 
@@ -84,13 +84,30 @@
     text
 }
 
+xmlLiteral = element res:literal { 
+    datatypeAttrXmlLit, xmlLang?,
+    anyOtherNSElement
+}
+
 indexAttr = attribute local:index {
     xsd:positiveInteger
 }
 
 datatypeAttr = attribute local:datatype {
-    URI-reference
+    URI-referenceNotXmlLit
+}
+
+datatypeAttrXmlLit = attribute local:datatype {
+    "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral";
 }
 
 URI-reference = xsd:anyURI
 
+URI-referenceNotXmlLit = xsd:anyURI - "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral";
+
+anyOtherNSElement =
+  element * - res:* {
+    (attribute * { text }
+     | text
+     | anyOtherNSElement)*
+   }

Reply via email to