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 2014/11/21 17:53:43 UTC
jena git commit: JENA-816 : RDF 1.1 style output support.
Repository: jena
Updated Branches:
refs/heads/master ee2ec7965 -> 225eea9b4
JENA-816 : RDF 1.1 style output support.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/225eea9b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/225eea9b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/225eea9b
Branch: refs/heads/master
Commit: 225eea9b44eb452897d1a756059c5709a1b4f6ce
Parents: ee2ec79
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Nov 21 16:53:12 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Nov 21 16:53:12 2014 +0000
----------------------------------------------------------------------
.../hpl/jena/rdfxml/xmloutput/impl/Basic.java | 4 +++-
.../jena/rdfxml/xmloutput/impl/Unparser.java | 25 ++++++++++++++++----
2 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/225eea9b/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Basic.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Basic.java b/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Basic.java
index ddec340..8b3869c 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Basic.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Basic.java
@@ -170,8 +170,10 @@ public class Basic extends BaseXMLWriter
writer.print(" " + rdfAt("parseType") + "=" + attributeQuoted( "Literal" )+">");
writer.print( form );
} else {
+ // No lang.
String dt = l.getDatatypeURI();
- if (dt != null) writer.print( " " + rdfAt( "datatype" ) + "=" + substitutedAttribute( dt ) );
+ if ( ! Unparser.isSimpleString(l) )
+ writer.print( " " + rdfAt( "datatype" ) + "=" + substitutedAttribute( dt ) );
writer.print(">");
writer.print( Util.substituteEntitiesInElementContent( form ) );
}
http://git-wip-us.apache.org/repos/asf/jena/blob/225eea9b/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Unparser.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Unparser.java b/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Unparser.java
index 3424473..feab029 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Unparser.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/rdfxml/xmloutput/impl/Unparser.java
@@ -121,8 +121,10 @@ import java.util.*;
import org.apache.xerces.util.XMLChar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.apache.jena.iri.IRI;
+
+import com.hp.hpl.jena.JenaRuntime ;
+import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;
import com.hp.hpl.jena.rdf.model.impl.Util;
@@ -455,13 +457,28 @@ class Unparser {
print(">");
return true;
}
+
+ /** Return true if to be written as a string, without datatype or lang */
+ /*package*/ static boolean isSimpleString(Literal lit) {
+ if ( lit.getDatatypeURI() == null )
+ return true;
+ if ( JenaRuntime.isRDF11 && lit.getDatatypeURI().equals(XSDDatatype.XSDstring.getURI()) )
+ return true;
+ if ( JenaRuntime.isRDF11 && lit.getDatatypeURI().equals(RDF.langString.getId()) )
+ return true;
+
+ return false ;
+ }
private boolean wPropertyEltDatatype(WType wt, Property prop, Statement s,
RDFNode r) {
- if (!((r instanceof Literal) && ((Literal) r).getDatatypeURI() != null)) {
+ if (! (r instanceof Literal) )
+ return false ;
+ Literal lit = ((Literal) r) ;
+ if ( isSimpleString(lit) )
return false;
- }
- // print out.
+
+ // print out with "datatype="
done(s);
tab();
print("<");