clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enrid...@apache.org
Subject git commit: CLEREZZA-872 With this change literals of datatype XMLLiteral will be prepared differently, by translating non ascii chars in the XML entity instead.
Date Fri, 07 Feb 2014 16:07:14 GMT
Updated Branches:
  refs/heads/master 26bffb67e -> 0c54ded27


CLEREZZA-872 With this change literals of datatype XMLLiteral will be prepared differently,
by translating non ascii chars in the XML entity instead.


Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/0c54ded2
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/0c54ded2
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/0c54ded2

Branch: refs/heads/master
Commit: 0c54ded27d5583c84ca18b3c700ef70de149554e
Parents: 26bffb6
Author: enridaga <enridaga@apache.org>
Authored: Fri Feb 7 16:07:07 2014 +0000
Committer: enridaga <enridaga@apache.org>
Committed: Fri Feb 7 16:07:07 2014 +0000

----------------------------------------------------------------------
 .../java/rdf/virtuoso/storage/VirtuosoMGraph.java    | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/0c54ded2/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
index b4116d3..63353f7 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
@@ -624,11 +624,14 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 		logger.debug("toVirtTypedLiteral(TypedLiteral {})", object);
 		UriRef dt = object.getDataType();
 		String literal = object.getLexicalForm();//.replaceAll("\"", "\\\\\"");
-		return new StringBuilder().append('"').append('"').append('"').append(prepareString(literal)).append('"').append('"').append('"')
+		StringBuilder prepared;
+		// If XMLLiteral, prepare XML entities
+		prepared = prepareString(literal, dt.getUnicodeString().equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"));
+		return new StringBuilder().append('"').append('"').append('"').append(prepared).append('"').append('"').append('"')
 				.append("^^").append(toVirtIri(dt)).toString();
 	}
 	
-	private StringBuilder prepareString(String str) {
+	private StringBuilder prepareString(String str, boolean xml) {
 		  StringBuilder retStr = new StringBuilder();
 		  for(int i=0; i<str.length(); i++) {
 		    int cp = Character.codePointAt(str, i);
@@ -643,7 +646,11 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 		    if (cp < 128) {
 		      retStr.appendCodePoint(cp);
 		    } else {
-		      retStr.append(String.format("\\u%04x", cp));
+		    	if(xml){
+		    		 retStr.append(String.format("&#x%04x;", cp));
+		    	}else{
+		    		retStr.append(String.format("\\u%04x", cp));
+		    	}
 		    }
 		  }
 		  return retStr;
@@ -659,7 +666,7 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 		logger.debug("toVirtPlainLiteral(PlainLiteral {})", object);
 		Language lang = object.getLanguage();
 		String literal = object.getLexicalForm();//.replaceAll("\"", "\\\\\"");
-		StringBuilder sb = new StringBuilder().append('"').append('"').append('"').append(prepareString(literal))
+		StringBuilder sb = new StringBuilder().append('"').append('"').append('"').append(prepareString(literal,
false))
 				.append('"').append('"').append('"');
 		if (lang == null) {
 			return sb.toString();


Mime
View raw message