You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by fc...@apache.org on 2011/10/06 17:46:26 UTC

svn commit: r1179672 - in /incubator/stanbol/trunk/commons: jsonld/src/main/java/org/apache/stanbol/commons/jsonld/ jsonld/src/test/java/org/apache/stanbol/commons/jsonld/ web/base/src/main/java/org/apache/stanbol/commons/web/base/format/ web/base/src/...

Author: fchrist
Date: Thu Oct  6 15:46:25 2011
New Revision: 1179672

URL: http://svn.apache.org/viewvc?rev=1179672&view=rev
Log:
STANBOL-339 The JSON-LD serializer got a little bit smarter and tries to avoid CURIEs if possible. If not possible, the whole output is serialized using CURIEs as it was before.

Added:
    incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/ShorteningException.java
Modified:
    incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java
    incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java
    incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdProfile.java
    incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java
    incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java
    incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java
    incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdTest.java
    incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/format/NamespaceEnum.java
    incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java
    incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java

Modified: incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java Thu Oct  6 15:46:25 2011
@@ -51,8 +51,6 @@ public class JsonLd extends JsonLdCommon
      * <code>true</code>.
      */
     private boolean useTypeCoercion = true;
-    
-    
 
     /**
      * Adds the given resource to this JsonLd object using the resource's subject as key. If the key is NULL
@@ -94,11 +92,11 @@ public class JsonLd extends JsonLdCommon
     @Override
     public String toString() {
         if (useJointGraphs) {
-            Map<String,Object> json = createJointGraph();
+            Map<String,Object> json = createJsonMap();
 
             return JsonSerializer.toString(json);
         } else {
-            List<Object> json = createDisjointGraph();
+            List<Object> json = createJsonList();
 
             return JsonSerializer.toString(json);
         }
@@ -114,17 +112,51 @@ public class JsonLd extends JsonLdCommon
      */
     public String toString(int indent) {
         if (useJointGraphs) {
-            Map<String,Object> json = createJointGraph();
+            Map<String,Object> json = createJsonMap();
 
             return JsonSerializer.toString(json, indent);
         } else {
-            List<Object> json = createDisjointGraph();
+            List<Object> json = createJsonList();
 
             return JsonSerializer.toString(json, indent);
         }
     }
+    
+    private Map<String,Object> createJsonMap() {
+        Map<String,Object> json = null;
+        try {
+            json = createJointGraph();
+        } catch (ShorteningException e) {
+            // problems while using the shortening algorithm
+            this.setUseCuries(true);
+            this.usedNamespaces.clear();
+            try {
+                json = createJointGraph();
+            } catch (ShorteningException e1) {
+                // ignore this
+            }
+        }
+        return json;
+    }
+    
+    private List<Object> createJsonList() {
+        List<Object> json = null;
+        try {
+            json = createDisjointGraph();
+        } catch (ShorteningException e) {
+            // problems while using the shortening algorithm
+            this.setUseCuries(true);
+            this.usedNamespaces.clear();
+            try {
+                json = createDisjointGraph();
+            } catch (ShorteningException e1) {
+                // ignore this
+            }
+        }
+        return json;
+    }
 
-    private List<Object> createDisjointGraph() {
+    private List<Object> createDisjointGraph() throws ShorteningException {
         List<Object> json = new ArrayList<Object>();
         if (!resourceMap.isEmpty()) {
 
@@ -134,12 +166,12 @@ public class JsonLd extends JsonLdCommon
 
                 // put subject
                 if (resource.getSubject() != null && !resource.getSubject().isEmpty()) {
-                    subjectObject.put(SUBJECT, handleCURIEs(resource.getSubject()));
+                    subjectObject.put(SUBJECT, shortenURI(resource.getSubject()));
                 }
 
                 // put profile
                 if (resource.getProfile() != null && !resource.getProfile().isEmpty()) {
-                    subjectObject.put(PROFILE, handleCURIEs(resource.getProfile()));
+                    subjectObject.put(PROFILE, shortenURI(resource.getProfile()));
                 }
 
                 // put types
@@ -173,7 +205,7 @@ public class JsonLd extends JsonLdCommon
     }
 
     @SuppressWarnings("unchecked")
-    private Map<String,Object> createJointGraph() {
+    private Map<String,Object> createJointGraph() throws ShorteningException {
         Map<String,Object> json = new TreeMap<String,Object>(new JsonComparator());
         Map<String,String> coercionMap = new TreeMap<String,String>(new JsonComparator());
 
@@ -188,12 +220,12 @@ public class JsonLd extends JsonLdCommon
 
                 // put subject
                 if (resource.getSubject() != null && !resource.getSubject().isEmpty()) {
-                    subjectObject.put(SUBJECT, handleCURIEs(resource.getSubject()));
+                    subjectObject.put(SUBJECT, shortenURI(resource.getSubject()));
                 }
                 
                 // put profile
                 if (resource.getProfile() != null && !resource.getProfile().isEmpty()) {
-                    subjectObject.put(PROFILE, handleCURIEs(resource.getProfile()));
+                    subjectObject.put(PROFILE, shortenURI(resource.getProfile()));
                 }
 
                 // put types
@@ -238,11 +270,11 @@ public class JsonLd extends JsonLdCommon
         return json;
     }
 
-    private void putTypes(Map<String,Object> subjectObject, JsonLdResource resource) {
+    private void putTypes(Map<String,Object> subjectObject, JsonLdResource resource) throws ShorteningException {
         if (!resource.getTypes().isEmpty()) {
             List<String> types = new ArrayList<String>();
             for (String type : resource.getTypes()) {
-                types.add(handleCURIEs(type));
+                types.add(shortenURIWithCuries(type));
             }
             if (types.size() == 1) {
                 subjectObject.put(TYPE, types.get(0));
@@ -260,12 +292,12 @@ public class JsonLd extends JsonLdCommon
         }
     }
 
-    private void putCoercedTypes(Map<String,Object> jsonObject, Map<String,String> coercionMap) {
+    private void putCoercedTypes(Map<String,Object> jsonObject, Map<String,String> coercionMap) throws ShorteningException {
         if (!coercionMap.isEmpty()) {
             Map<String,List<String>> nsCoercionMap = new TreeMap<String,List<String>>(new JsonComparator());
             for (String property : coercionMap.keySet()) {
-                String prop = handleCURIEs(property);
-                String type = handleCURIEs(coercionMap.get(property));
+                String prop = shortenURIIgnoreDuplicates(property);
+                String type = shortenURIWithCuries(coercionMap.get(property));
                 
                 if (nsCoercionMap.get(type) == null) {
                     nsCoercionMap.put(type, new LinkedList<String>());
@@ -277,13 +309,13 @@ public class JsonLd extends JsonLdCommon
         }
     }
 
-    private void putProperties(Map<String,Object> jsonObject, JsonLdResource resource) {
+    private void putProperties(Map<String,Object> jsonObject, JsonLdResource resource) throws ShorteningException {
         putProperties(jsonObject, resource.getPropertyMap(), resource.getCoerceMap());
     }
 
     private void putProperties(Map<String,Object> outputObject,
                                Map<String,Object> inputMap,
-                               Map<String,String> coercionMap) {
+                               Map<String,String> coercionMap) throws ShorteningException {
         for (String property : inputMap.keySet()) {
             Object value = inputMap.get(property);
             value = convertValueType(value);
@@ -294,18 +326,18 @@ public class JsonLd extends JsonLdCommon
                     if (type != null) {
                         if (this.useTypeCoercion) {
                             strValue = (String)doCoerce(strValue, type);
-                            outputObject.put(handleCURIEs(property), handleCURIEs(strValue));
+                            outputObject.put(shortenURI(property), shortenURI(strValue));
                         } else {
                             Object objValue = unCoerce(strValue, type);
-                            outputObject.put(handleCURIEs(property), objValue);
+                            outputObject.put(shortenURI(property), objValue);
                         }
                     }
                     else {
-                        outputObject.put(handleCURIEs(property), handleCURIEs(strValue));
+                        outputObject.put(shortenURI(property), shortenURI(strValue));
                     }
                 }
                 else {
-                    outputObject.put(handleCURIEs(property), handleCURIEs(strValue));
+                    outputObject.put(shortenURI(property), shortenURI(strValue));
                 }
             } else if (value instanceof Object[]) {
                 Object[] arrayValue = (Object[]) value;
@@ -313,13 +345,13 @@ public class JsonLd extends JsonLdCommon
             } else if (value instanceof Map<?,?>) {
                 Map<String,Object> valueMap = (Map<String,Object>) value;
                 Map<String,Object> subOutputObject = new HashMap<String,Object>();
-                outputObject.put(handleCURIEs(property), subOutputObject);
+                outputObject.put(shortenURI(property), subOutputObject);
                 putProperties(subOutputObject, valueMap, coercionMap);
             } else if (value instanceof JsonLdIRI) {
                 JsonLdIRI iriValue = (JsonLdIRI) value;
                 Map<String,Object> iriObject = new HashMap<String,Object>();
-                iriObject.put(IRI, handleCURIEs(iriValue.getIRI()));
-                outputObject.put(handleCURIEs(property), iriObject);
+                iriObject.put(IRI, shortenURI(iriValue.getIRI()));
+                outputObject.put(shortenURI(property), iriObject);
             } else {
                 if (coercionMap != null) {
                     String type = coercionMap.get(property);
@@ -333,16 +365,16 @@ public class JsonLd extends JsonLdCommon
                         
                         if (objValue instanceof String) {
                             String strValue = (String) objValue;
-                            outputObject.put(handleCURIEs(property), handleCURIEs(strValue));
+                            outputObject.put(shortenURI(property), shortenURI(strValue));
                         }
                         else {
-                            outputObject.put(handleCURIEs(property), objValue);
+                            outputObject.put(shortenURI(property), objValue);
                         }
                     } else {
-                        outputObject.put(handleCURIEs(property), value);
+                        outputObject.put(shortenURI(property), value);
                     }
                 } else {
-                    outputObject.put(handleCURIEs(property), value);
+                    outputObject.put(shortenURI(property), value);
                 }
             }
         }
@@ -351,7 +383,7 @@ public class JsonLd extends JsonLdCommon
     private void putProperties(Map<String,Object> outputObject,
                                String property,
                                Object[] arrayValue,
-                               Map<String,String> coercionMap) {
+                               Map<String,String> coercionMap) throws ShorteningException {
 
         String type = null;
         if (coercionMap != null && !this.useTypeCoercion) {
@@ -372,15 +404,15 @@ public class JsonLd extends JsonLdCommon
                     valueList.add(iriValue.getIRI());
                 } else {
                     Map<String,Object> iriObject = new HashMap<String,Object>();
-                    iriObject.put(IRI, handleCURIEs(iriValue.getIRI()));
+                    iriObject.put(IRI, shortenURI(iriValue.getIRI()));
                     valueList.add(iriObject);
                 }
             } else if (object instanceof String) {
                 String strValue = (String) object;
                 if (type != null) {
-                    valueList.add(unCoerce(handleCURIEs(strValue), type));
+                    valueList.add(unCoerce(shortenURI(strValue), type));
                 } else {
-                    valueList.add(handleCURIEs(strValue));
+                    valueList.add(shortenURI(strValue));
                 }
             } else {
                 // Don't know what it is - just add it
@@ -389,7 +421,7 @@ public class JsonLd extends JsonLdCommon
         }
 
         // Add the converted values
-        outputObject.put(handleCURIEs(property), valueList);
+        outputObject.put(shortenURI(property), valueList);
     }
 
     /**
@@ -398,12 +430,13 @@ public class JsonLd extends JsonLdCommon
      * @param strValue
      * @param type
      * @return
+     * @throws ShorteningException 
      */
-    private Map<String, Object> unCoerce(Object value, String type) {
+    private Map<String, Object> unCoerce(Object value, String type) throws ShorteningException {
         Map<String, Object> typeDef = new TreeMap<String,Object>(new JsonComparator());
         
         typeDef.put(LITERAL, String.valueOf(value));
-        typeDef.put(DATATYPE, handleCURIEs(type));
+        typeDef.put(DATATYPE, shortenURI(type));
         
         return typeDef;
     }
@@ -438,11 +471,24 @@ public class JsonLd extends JsonLdCommon
     private Object convertValueType(Object value) {
         if (value instanceof String) {
             String strValue = (String) value;
+            
+            // check if value can be interpreted as long
+            try {
+                return Long.valueOf(strValue);
+            }
+            catch (Throwable t) {};
+            
             // check if value can be interpreted as integer
             try {
                 return Integer.valueOf(strValue);
             }
             catch (Throwable t) {};
+
+            // check if it is a float double
+            try {
+                return Double.valueOf(strValue);
+            }
+            catch (Throwable t) {};
             
             // check if it is a float value
             try {

Modified: incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java Thu Oct  6 15:46:25 2011
@@ -19,6 +19,12 @@ package org.apache.stanbol.commons.jsonl
 import java.util.HashMap;
 import java.util.Map;
 
+/**
+ *
+ *
+ * @author Fabian Christ
+ *
+ */
 public abstract class JsonLdCommon {
 
     public static final String CONTEXT = "@context";
@@ -50,6 +56,8 @@ public abstract class JsonLdCommon {
      * serialization. Default value is <code>true</code>.
      */
     protected boolean applyNamespaces = true;
+    
+    protected boolean useCuries = false;
 
     /**
      * Get the known namespace to prefix mapping.
@@ -105,6 +113,20 @@ public abstract class JsonLdCommon {
     public void setApplyNamespaces(boolean applyNamespaces) {
         this.applyNamespaces = applyNamespaces;
     }
+    
+    /**
+     * @return
+     */
+    public boolean isUseCuries() {
+        return useCuries;
+    }
+
+    /**
+     * @param useCuries
+     */
+    public void setUseCuries(boolean useCuries) {
+        this.useCuries = useCuries;
+    }
 
     /**
      * Convert URI to CURIE if namespaces should be applied and CURIEs to URIs if namespaces should not be
@@ -113,20 +135,43 @@ public abstract class JsonLdCommon {
      * @param uri
      *            That may be in CURIE form.
      * @return
+     * @throws ShorteningException 
      */
-    protected String handleCURIEs(String uri) {
+    protected String shortenURI(String uri) throws ShorteningException {
         if (this.applyNamespaces) {
-            uri = doCURIE(uri);
+            uri = doCURIE(uri, this.useCuries, false);
         } else {
             uri = unCURIE(uri);
         }
 
         return uri;
     }
+    
+    protected String shortenURIIgnoreDuplicates(String uri) throws ShorteningException {
+        if (this.applyNamespaces) {
+            uri = doCURIE(uri, this.useCuries, true);
+        } else {
+            uri = unCURIE(uri);
+        }
 
-    public String doCURIE(String uri) {
-        String curie = uri;
+        return uri;
+    }
+    
+    protected String shortenURIWithCuries(String uri) throws ShorteningException {
+        if (this.applyNamespaces) {
+            uri = doCURIE(uri, true, false);
+        } else {
+            uri = unCURIE(uri);
+        }
+
+        return uri;
+    }
+
+    private String doCURIE(String uri, boolean useCURIEs, boolean ignoreDuplicates) throws ShorteningException {
+        String shortened = uri;
         if (uri != null) {
+            String curie = uri;
+            String curieNamespace = null;
             for (String namespace : namespacePrefixMap.keySet()) {
                 String prefix = namespacePrefixMap.get(namespace);
                 String prefixEx = prefix + ":";
@@ -136,18 +181,52 @@ public abstract class JsonLdCommon {
                     
                     if (!uri.equals(curie)) {
                         // we mark this namespace as being used
-                        this.usedNamespaces.put(namespace, prefix);
+                        curieNamespace = namespace;
                         break;
                     }
                 }
                 else {
                     // we mark this namespace as being used
-                    this.usedNamespaces.put(namespace, prefix);
+                    curieNamespace = namespace;
                     break;
                 }
             }
+            
+            if (curieNamespace != null) {
+                String usedPrefix = this.namespacePrefixMap.get(curieNamespace);
+                if (useCURIEs) {
+                    shortened = curie;
+                    this.usedNamespaces.put(curieNamespace, usedPrefix);
+                }
+                else {
+                    String propName = curie.replace(usedPrefix + ":", "");
+                    String namespaceOfProp = null;
+                    for (String ns : this.usedNamespaces.keySet()) {
+                        if (propName.equals(this.usedNamespaces.get(ns))) {
+                            // this shortened version is already in use
+                            namespaceOfProp = ns;
+                            break;
+                        }
+                    }
+                    if (namespaceOfProp != null) {
+                        if (namespaceOfProp.equals(curieNamespace + propName)) {
+                            shortened = propName;
+                        }
+                        else if (ignoreDuplicates) {
+                            shortened = propName;
+                        } else {
+                            System.out.println("Fallback to CURIEs because of property " + propName + " with NS " + namespaceOfProp + " and other is " + curieNamespace + propName);
+                            throw new ShorteningException();
+                        }
+                    }
+                    else {
+                        shortened = propName;
+                        this.usedNamespaces.put(curieNamespace + propName, propName);
+                    }
+                }
+            }
         }
-        return curie;
+        return shortened;
     }
 
     public String unCURIE(String uri) {

Modified: incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdProfile.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdProfile.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdProfile.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdProfile.java Thu Oct  6 15:46:25 2011
@@ -53,18 +53,32 @@ public class JsonLdProfile extends JsonL
     }
 
     public String toString() {
-        Map<String,Object> json = createJson();
-
-        return JsonSerializer.toString(json);
+        return JsonSerializer.toString(this.createJsonMap());
     }
 
     public String toString(int indent) {
-        Map<String,Object> json = createJson();
-
-        return JsonSerializer.toString(json, indent);
+        return JsonSerializer.toString(this.createJsonMap(), indent);
+    }
+    
+    private Map<String,Object> createJsonMap() {
+        Map<String,Object> json = null;
+        try {
+            json = createJson();
+        } catch (ShorteningException e) {
+            // problems while using the shortening algorithm
+            this.setUseCuries(true);
+            this.usedNamespaces.clear();
+            try {
+                json = createJson();
+            } catch (ShorteningException e1) {
+                // ignore this
+            }
+        }
+        
+        return json;
     }
 
-    private Map<String,Object> createJson() {
+    private Map<String,Object> createJson() throws ShorteningException {
         Map<String,Object> json = new TreeMap<String,Object>(new JsonComparator());
 
         // put the namespaces
@@ -78,13 +92,13 @@ public class JsonLdProfile extends JsonL
         for (String property : this.typesMap.keySet()) {
             List<String> types = this.typesMap.get(property);
             if (types.size() == 1) {
-                typesObject.put(handleCURIEs(property), handleCURIEs(types.get(0)));
+                typesObject.put(shortenURI(property), shortenURI(types.get(0)));
             } else {
                 JSONArray typesArray = new JSONArray();
                 for (String type : types) {
-                    typesArray.put(handleCURIEs(type));
+                    typesArray.put(shortenURI(type));
                 }
-                typesObject.put(handleCURIEs(property), typesArray);
+                typesObject.put(shortenURI(property), typesArray);
             }
         }
         contextObject.put(JsonLdCommon.TYPES, typesObject);

Added: incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/ShorteningException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/ShorteningException.java?rev=1179672&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/ShorteningException.java (added)
+++ incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/ShorteningException.java Thu Oct  6 15:46:25 2011
@@ -0,0 +1,10 @@
+package org.apache.stanbol.commons.jsonld;
+
+public class ShorteningException extends Exception {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+}

Modified: incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java Thu Oct  6 15:46:25 2011
@@ -28,6 +28,7 @@ public class JsonLdParserTest {
         
         JsonLd jsonLd = JsonLdParser.parse(jsonldInput);
         jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(true);
         
         String actual = jsonLd.toString();
         String expected = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}}";
@@ -58,7 +59,7 @@ public class JsonLdParserTest {
         jsonLd.setApplyNamespaces(true);
         
         String actual = jsonLd.toString();
-        String expected = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:fchrist\"}}]}";
+        String expected = "{\"@context\":{\"bnagel\":\"http://upb.de/persons/bnagel\",\"employeeOf\":\"http://iks-project.eu/ont/employeeOf\",\"fchrist\":\"http://upb.de/persons/fchrist\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"fchrist\"}}]}";
         assertEquals(expected, actual);
         assertNotNull(jsonLd);
     }
@@ -71,6 +72,7 @@ public class JsonLdParserTest {
         jsonLd.setUseTypeCoercion(true);
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseJointGraphs(false);
+        jsonLd.setUseCuries(true);
         
         String actual = jsonLd.toString();
         String expected = "[{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":\"_:bnode2\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:fchrist\"}}]";
@@ -88,7 +90,7 @@ public class JsonLdParserTest {
         jsonLd.setUseJointGraphs(true);
         
         String actual = jsonLd.toString();
-        String expected = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"iks:friendOf\",\"friend\":{\"@iri\":\"upb:fchrist\"},\"person\":{\"@iri\":\"upb:bnagel\"}}]}";
+        String expected = "{\"@context\":{\"bnagel\":\"http://upb.de/persons/bnagel\",\"employeeOf\":\"http://iks-project.eu/ont/employeeOf\",\"fchrist\":\"http://upb.de/persons/fchrist\",\"friendOf\":\"http://iks-project.eu/ont/friendOf\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"friendOf\",\"friend\":{\"@iri\":\"fchrist\"},\"person\":{\"@iri\":\"bnagel\"}}]}";
         assertEquals(expected, actual);
         assertNotNull(jsonLd);
     }
@@ -101,6 +103,7 @@ public class JsonLdParserTest {
         jsonLd.setUseTypeCoercion(true);
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseJointGraphs(true);
+        jsonLd.setUseCuries(true);
         
         String actual = jsonLd.toString();
         String expected = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\"},\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":\"UniPaderborn\",\"person\":\"Benjamin\"}";

Modified: incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java Thu Oct  6 15:46:25 2011
@@ -29,6 +29,7 @@ public class JsonLdProfileParserTest {
         String jsonldInput = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"person\":\"iks:person\",\"organization\":\"iks:organization\"}}}";
         
         JsonLdProfile profile = JsonLdProfileParser.parseProfile(jsonldInput);
+        profile.setUseCuries(true);
         
         String actual = profile.toString();
         String expected = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}";

Modified: incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java Thu Oct  6 15:46:25 2011
@@ -26,6 +26,7 @@ public class JsonLdProfileTest {
     @Test
     public void testDefineProfile() {
         JsonLdProfile profile = new JsonLdProfile();
+        profile.setUseCuries(true);
         profile.addNamespacePrefix("http://iks-project.eu/ont/", "iks");
         
         profile.addType("person", "iks:person");

Modified: incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdTest.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdTest.java (original)
+++ incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdTest.java Thu Oct  6 15:46:25 2011
@@ -40,6 +40,7 @@ public class JsonLdTest {
     public void testSpecExample1() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://example.org/myvocab#", "myvocab");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
         jsonLd.addNamespacePrefix("http://sioc.org/vocab/1/", "sioc");
@@ -60,12 +61,35 @@ public class JsonLdTest {
         String expectedIndent = "{\n    \"@context\": {\n        \"foaf\": \"http://xmlns.com/foaf/0.1/\",\n        \"myvocab\": \"http://example.org/myvocab#\",\n        \"sioc\": \"http://sioc.org/vocab/1/\"\n    },\n    \"@type\": \"foaf:Person\",\n    \"foaf:homepage\": \"<http://manu.sporny.org/>\",\n    \"foaf:name\": \"Manu Sporny\",\n    \"myvocab:credits\": 500,\n    \"sioc:avatar\": \"<http://twitter.com/account/profile_image/manusporny>\"\n}";
         assertEquals(expectedIndent, actualIndent);
     }
+    
+    @Test
+    public void testSpecExample1NoCuries() {
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(false);
+        jsonLd.addNamespacePrefix("http://example.org/myvocab#", "myvocab");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+        jsonLd.addNamespacePrefix("http://sioc.org/vocab/1/", "sioc");
+
+        JsonLdResource jsonLdResource = new JsonLdResource();
+        jsonLdResource.addType("foaf:Person");
+        jsonLdResource.putProperty("foaf:name", "Manu Sporny");
+        jsonLdResource.putProperty("foaf:homepage", "http://manu.sporny.org/");
+        jsonLdResource.putProperty("sioc:avatar", "http://twitter.com/account/profile_image/manusporny");
+        jsonLdResource.putProperty("myvocab:credits", 500);
+        jsonLd.put(jsonLdResource);
+
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"avatar\":\"http://sioc.org/vocab/1/avatar\",\"credits\":\"http://example.org/myvocab#credits\",\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"homepage\":\"http://xmlns.com/foaf/0.1/homepage\",\"name\":\"http://xmlns.com/foaf/0.1/name\"},\"@type\":\"foaf:Person\",\"avatar\":\"http://twitter.com/account/profile_image/manusporny\",\"credits\":500,\"homepage\":\"http://manu.sporny.org/\",\"name\":\"Manu Sporny\"}";
+        assertEquals(expected, actual);        
+    }
 
     @Test
     public void testSpecExample2_JointGraph() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
         jsonLd.setUseJointGraphs(true);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
 
         JsonLdResource r1 = new JsonLdResource();
@@ -97,11 +121,46 @@ public class JsonLdTest {
         String expectedIndent = "{\n    \"@context\": {\n        \"foaf\": \"http://xmlns.com/foaf/0.1/\"\n    },\n    \"@subject\": [\n        {\n            \"@subject\": \"_:bnode1\",\n            \"@type\": \"foaf:Person\",\n            \"foaf:homepage\": \"<http://example.com/bob>\",\n            \"foaf:name\": \"Bob\"\n        },\n        {\n            \"@subject\": \"_:bnode2\",\n            \"@type\": \"foaf:Person\",\n            \"foaf:homepage\": \"<http://example.com/eve>\",\n            \"foaf:name\": \"Eve\"\n        },\n        {\n            \"@subject\": \"_:bnode3\",\n            \"@type\": \"foaf:Person\",\n            \"foaf:homepage\": \"<http://example.com/bert>\",\n            \"foaf:name\": \"Bert\"\n        }\n    ]\n}";
         assertEquals(expectedIndent, actualIndent);
     }
+    
+    @Test
+    public void testSpecExample2_JointGraphNoCuries() {
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseJointGraphs(true);
+        jsonLd.setUseCuries(false);
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.addType("http://xmlns.com/foaf/0.1/Person");
+        r1.putProperty("http://xmlns.com/foaf/0.1/homepage", "<http://example.com/bob>");
+        r1.putProperty("http://xmlns.com/foaf/0.1/name", "Bob");
+        jsonLd.put(r1.getSubject(), r1);
+
+        JsonLdResource r2 = new JsonLdResource();
+        r2.setSubject("_:bnode2");
+        r2.addType("http://xmlns.com/foaf/0.1/Person");
+        r2.putProperty("http://xmlns.com/foaf/0.1/homepage", "<http://example.com/eve>");
+        r2.putProperty("http://xmlns.com/foaf/0.1/name", "Eve");
+        jsonLd.put(r2.getSubject(), r2);
+
+        JsonLdResource r3 = new JsonLdResource();
+        r3.setSubject("_:bnode3");
+        r3.addType("http://xmlns.com/foaf/0.1/Person");
+        r3.putProperty("http://xmlns.com/foaf/0.1/homepage", "<http://example.com/bert>");
+        r3.putProperty("http://xmlns.com/foaf/0.1/name", "Bert");
+        jsonLd.put(r3.getSubject(), r3);
+
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"homepage\":\"http://xmlns.com/foaf/0.1/homepage\",\"name\":\"http://xmlns.com/foaf/0.1/name\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@type\":\"foaf:Person\",\"homepage\":\"<http://example.com/bob>\",\"name\":\"Bob\"},{\"@subject\":\"_:bnode2\",\"@type\":\"foaf:Person\",\"homepage\":\"<http://example.com/eve>\",\"name\":\"Eve\"},{\"@subject\":\"_:bnode3\",\"@type\":\"foaf:Person\",\"homepage\":\"<http://example.com/bert>\",\"name\":\"Bert\"}]}";
+        assertEquals(expected, actual);
+    }
 
     @Test
     public void testSpecExample2_DisjointGraph() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.setUseJointGraphs(false);
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
 
@@ -134,11 +193,46 @@ public class JsonLdTest {
         String expectedIndent = "[\n    {\n        \"@context\": {\n            \"foaf\": \"http://xmlns.com/foaf/0.1/\"\n        },\n        \"@subject\": \"_:bnode1\",\n        \"@type\": \"foaf:Person\",\n        \"foaf:homepage\": \"<http://example.com/bob>\",\n        \"foaf:name\": \"Bob\"\n    },\n    {\n        \"@context\": {\n            \"foaf\": \"http://xmlns.com/foaf/0.1/\"\n        },\n        \"@subject\": \"_:bnode2\",\n        \"@type\": \"foaf:Person\",\n        \"foaf:homepage\": \"<http://example.com/eve>\",\n        \"foaf:name\": \"Eve\"\n    },\n    {\n        \"@context\": {\n            \"foaf\": \"http://xmlns.com/foaf/0.1/\"\n        },\n        \"@subject\": \"_:bnode3\",\n        \"@type\": \"foaf:Person\",\n        \"foaf:homepage\": \"<http://example.com/eve>\",\n        \"foaf:name\": \"Eve\"\n    }\n]";
         assertEquals(expectedIndent, actualIndent);
     }
+    
+    @Test
+    public void testSpecExample2_DisjointGraphNoCuries() {
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(false);
+        jsonLd.setUseJointGraphs(false);
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.addType("foaf:Person");
+        r1.putProperty("foaf:homepage", "<http://example.com/bob>");
+        r1.putProperty("foaf:name", "Bob");
+        jsonLd.put(r1.getSubject(), r1);
+
+        JsonLdResource r2 = new JsonLdResource();
+        r2.setSubject("_:bnode2");
+        r2.addType("foaf:Person");
+        r2.putProperty("foaf:homepage", "<http://example.com/eve>");
+        r2.putProperty("foaf:name", "Eve");
+        jsonLd.put(r2.getSubject(), r2);
+
+        JsonLdResource r3 = new JsonLdResource();
+        r3.setSubject("_:bnode3");
+        r3.addType("foaf:Person");
+        r3.putProperty("foaf:homepage", "<http://example.com/eve>");
+        r3.putProperty("foaf:name", "Eve");
+        jsonLd.put(r3.getSubject(), r3);
+
+        String actual = jsonLd.toString();
+        String expected = "[{\"@context\":{\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"homepage\":\"http://xmlns.com/foaf/0.1/homepage\",\"name\":\"http://xmlns.com/foaf/0.1/name\"},\"@subject\":\"_:bnode1\",\"@type\":\"foaf:Person\",\"homepage\":\"<http://example.com/bob>\",\"name\":\"Bob\"},{\"@context\":{\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"homepage\":\"http://xmlns.com/foaf/0.1/homepage\",\"name\":\"http://xmlns.com/foaf/0.1/name\"},\"@subject\":\"_:bnode2\",\"@type\":\"foaf:Person\",\"homepage\":\"<http://example.com/eve>\",\"name\":\"Eve\"},{\"@context\":{\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"homepage\":\"http://xmlns.com/foaf/0.1/homepage\",\"name\":\"http://xmlns.com/foaf/0.1/name\"},\"@subject\":\"_:bnode3\",\"@type\":\"foaf:Person\",\"homepage\":\"<http://example.com/eve>\",\"name\":\"Eve\"}]";
+        assertEquals(expected, actual);
+    }
 
     @Test
     public void testSpecExample3() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://microformats.org/profile/hcard#vcard", "vcard");
         jsonLd.addNamespacePrefix("http://microformats.org/profile/hcard#url", "url");
         jsonLd.addNamespacePrefix("http://microformats.org/profile/hcard#fn", "fn");
@@ -185,6 +279,7 @@ public class JsonLdTest {
     public void testSpecExample4Microformats() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.setUseJointGraphs(false);
 
         JsonLdResource r1 = new JsonLdResource();
@@ -221,6 +316,7 @@ public class JsonLdTest {
     public void testSpecExample5TypedLiterals() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://purl.org/dc/terms/", "dc");
 
@@ -259,6 +355,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -276,6 +373,28 @@ public class JsonLdTest {
     }
     
     @Test
+    public void testSpecExample5TypedLiteralsNsCoercionNoCuries() {
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setApplyNamespaces(true);
+        jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(false);
+        
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("http://example.org/people#joebob");
+        String nick = "\"stu\"^^http://www.w3.org/2001/XMLSchema#string";
+        r1.putProperty("http://xmlns.com/foaf/0.1/nick", nick);
+        r1.putPropertyType("http://xmlns.com/foaf/0.1/nick", "xsd:string");
+        jsonLd.put(r1);
+
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"nick\":\"http://xmlns.com/foaf/0.1/nick\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:string\":\"nick\"}},\"@subject\":\"http://example.org/people#joebob\",\"nick\":\"stu\"}";
+        assertEquals(expected, actual);
+    }
+    
+    @Test
     public void testSpecExample5TypedLiteralsNoCoercion() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(false);
@@ -300,6 +419,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -319,6 +439,7 @@ public class JsonLdTest {
     public void testSpecExample6MultipleObjects() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
 
@@ -337,6 +458,7 @@ public class JsonLdTest {
     public void testSpecExample6MultipleTypedObjects() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
 
@@ -361,6 +483,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(false);
         jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
 
@@ -375,11 +498,33 @@ public class JsonLdTest {
         String expected = "{\"@context\":{\"@coerce\":{\"http://www.w3.org/2001/XMLSchema#string\":\"http://xmlns.com/foaf/0.1/nick\"}},\"@subject\":\"<http://example.org/people#joebob>\",\"http://xmlns.com/foaf/0.1/nick\":[\"stu\",\"groknar\",\"radface\"]}";
         assertEquals(expected, actual);
     }
+    
+    @Test
+    public void testSpecExample6MultipleObjectsCoerceNoCuries() {
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setApplyNamespaces(true);
+        jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(false);
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("<http://example.org/people#joebob>");
+        String [] nicks = new String [] {"stu", "groknar", "radface"};
+        r1.putProperty("foaf:nick", nicks);
+        r1.putPropertyType("foaf:nick", "xsd:string");
+        jsonLd.put(r1);
+
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"nick\":\"http://xmlns.com/foaf/0.1/nick\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:string\":\"nick\"}},\"@subject\":\"<http://example.org/people#joebob>\",\"nick\":[\"stu\",\"groknar\",\"radface\"]}";
+        assertEquals(expected, actual);
+    }
 
     @Test
     public void testSpecExample6MultipleObjectsNsCoerce() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(true);
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
 
@@ -453,6 +598,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(false);
         jsonLd.setApplyNamespaces(true);
+        jsonLd.setUseCuries(true);
 
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -479,6 +625,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setUseTypeCoercion(true);
         jsonLd.setApplyNamespaces(true);
+        jsonLd.setUseCuries(true);
 
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -504,6 +651,7 @@ public class JsonLdTest {
     @Test
     public void testUseProfile() {
         JsonLd jsonLd = new JsonLd();
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -523,6 +671,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -547,6 +696,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -567,6 +717,7 @@ public class JsonLdTest {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -583,10 +734,32 @@ public class JsonLdTest {
     }
     
     @Test
+    public void testFloatValueNoCuries() {
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setApplyNamespaces(true);
+        jsonLd.setUseTypeCoercion(true);
+        jsonLd.setUseCuries(false);
+        
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+        
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.putProperty("http://xmlns.com/foaf/0.1/age", 31.533567);
+        r1.putPropertyType("http://xmlns.com/foaf/0.1/age", "http://www.w3.org/2001/XMLSchema#int");
+        jsonLd.put(r1);
+        
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"age\":\"http://xmlns.com/foaf/0.1/age\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:int\":\"age\"}},\"@subject\":\"_:bnode1\",\"age\":31.533567}";
+        assertEquals(expected, actual);        
+    }
+    
+    @Test
     public void testFloatValueNoCoerce() {
         JsonLd jsonLd = new JsonLd();
         jsonLd.setApplyNamespaces(true);
         jsonLd.setUseTypeCoercion(false);
+        jsonLd.setUseCuries(true);
         
         jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
         jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
@@ -602,6 +775,98 @@ public class JsonLdTest {
         assertEquals(expected, actual);        
     }
     
+    @Test
+    public void testDuplicateProperties() {
+        JsonLd jsonLd = new JsonLd();
+        
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+        jsonLd.addNamespacePrefix("http://onto.test.org/", "onto");
+        
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.putProperty("http://xmlns.com/foaf/0.1/age", 31.533567);
+        r1.putPropertyType("http://xmlns.com/foaf/0.1/age", "http://www.w3.org/2001/XMLSchema#float");
+        r1.putProperty("http://onto.test.org/age", 456);
+        r1.putPropertyType("http://onto.test.org/age", "http://www.w3.org/2001/XMLSchema#int");
+        jsonLd.put(r1);
+        
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"onto\":\"http://onto.test.org/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:float\":\"foaf:age\",\"xsd:int\":\"onto:age\"}},\"@subject\":\"_:bnode1\",\"foaf:age\":31.533567,\"onto:age\":456}";
+        assertEquals(expected, actual); 
+    }
+    
+    @Test
+    public void testSubjectWithSeveralTypes() {
+        JsonLd jsonLd = new JsonLd();
+        
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+        jsonLd.addNamespacePrefix("http://onto.test.org/", "onto");
+        
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.addType("xsd:String");
+        r1.addType("foaf:name");
+        r1.putProperty("http://xmlns.com/foaf/0.1/age", 31.533567);
+        r1.putPropertyType("http://xmlns.com/foaf/0.1/age", "http://www.w3.org/2001/XMLSchema#float");
+        jsonLd.put(r1);
+        
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"age\":\"http://xmlns.com/foaf/0.1/age\",\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:float\":\"age\"}},\"@subject\":\"_:bnode1\",\"@type\":[\"foaf:name\",\"xsd:String\"],\"age\":31.533567}";
+        assertEquals(expected, actual); 
+    }
+    
+    @Test
+    public void testSubjectWithSeveralSameTypes() {
+        JsonLd jsonLd = new JsonLd();
+        
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+        jsonLd.addNamespacePrefix("http://onto.test.org/", "onto");
+        
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.addType("xsd:String");
+        r1.addType("foaf:String");
+        r1.putProperty("http://xmlns.com/foaf/0.1/age", 31.533567);
+        r1.putPropertyType("http://xmlns.com/foaf/0.1/age", "http://www.w3.org/2001/XMLSchema#float");
+        jsonLd.put(r1);
+        
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"age\":\"http://xmlns.com/foaf/0.1/age\",\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:float\":\"age\"}},\"@subject\":\"_:bnode1\",\"@type\":[\"foaf:String\",\"xsd:String\"],\"age\":31.533567}";
+        assertEquals(expected, actual); 
+    }
+    
+    @Test
+    public void testSubjectsWithSeveralTypes() {
+        JsonLd jsonLd = new JsonLd();
+        
+        jsonLd.addNamespacePrefix("http://www.w3.org/2001/XMLSchema#", "xsd");
+        jsonLd.addNamespacePrefix("http://xmlns.com/foaf/0.1/", "foaf");
+        jsonLd.addNamespacePrefix("http://onto.test.org/", "onto");
+        
+        JsonLdResource r1 = new JsonLdResource();
+        r1.setSubject("_:bnode1");
+        r1.addType("xsd:String");
+        r1.addType("foaf:name");
+        r1.putProperty("http://xmlns.com/foaf/0.1/age", 31.533567);
+        r1.putPropertyType("http://xmlns.com/foaf/0.1/age", "http://www.w3.org/2001/XMLSchema#float");
+        jsonLd.put(r1);
+        
+        JsonLdResource r2 = new JsonLdResource();
+        r2.setSubject("_:bnode2");
+        r2.addType("xsd:String");
+        r2.addType("foaf:name");
+        r2.putProperty("http://xmlns.com/foaf/0.1/age", 31.533567);
+        r2.putPropertyType("http://xmlns.com/foaf/0.1/age", "http://www.w3.org/2001/XMLSchema#float");
+        jsonLd.put(r2);
+        
+        String actual = jsonLd.toString();
+        String expected = "{\"@context\":{\"age\":\"http://xmlns.com/foaf/0.1/age\",\"foaf\":\"http://xmlns.com/foaf/0.1/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"xsd:float\":\"age\"}},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@type\":[\"foaf:name\",\"xsd:String\"],\"age\":31.533567},{\"@subject\":\"_:bnode2\",\"@type\":[\"foaf:name\",\"xsd:String\"],\"age\":31.533567}]}";
+        assertEquals(expected, actual); 
+    }
+    
     @SuppressWarnings("unused")
     private void toConsole(String actual) {
         System.out.println(actual);

Modified: incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/format/NamespaceEnum.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/format/NamespaceEnum.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/format/NamespaceEnum.java (original)
+++ incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/format/NamespaceEnum.java Thu Oct  6 15:46:25 2011
@@ -20,6 +20,8 @@ public enum NamespaceEnum {
 
     // TODO: change the namespace as soon as STANBOL-3 defines a namespace to be used for stanbol
     enhancer("http://fise.iks-project.eu/ontology/"),
+    rickModel("http://www.iks-project.eu/ontology/rick/model/"),
+    rickQuery("http://www.iks-project.eu/ontology/rick/query/"),
     
     atom("http://www.w3.org/2005/Atom"),
     bio("dc-bio","http://purl.org/vocab/bio/0.1/"),

Modified: incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java (original)
+++ incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java Thu Oct  6 15:46:25 2011
@@ -157,17 +157,38 @@ public class JsonLdSerializerProvider im
     }
     
     private Object convertValueType(String strValue) {
-        // check if value can be interpreted as integer
+        String trimedValue = strValue.replaceAll("\"", "");
+        
+        // check if value can be interpreted as Long
+        try {
+            return Long.valueOf(trimedValue);
+        }
+        catch (Throwable t) {};
+        
+        // check if value can be interpreted as Integer
+        try {
+            return Integer.valueOf(trimedValue);
+        }
+        catch (Throwable t) {};
+        
+        // check if it is a Float value
+        try {
+            return Float.valueOf(trimedValue);
+        }
+        catch (Throwable t) {};
+        
+        // check if it is a Double value
         try {
-            return Integer.valueOf(strValue);
+            return Double.valueOf(trimedValue);
         }
         catch (Throwable t) {};
         
         // check if value can be interpreted as boolean
-        if (strValue.equalsIgnoreCase("true") || strValue.equalsIgnoreCase("false")) {
-            return Boolean.valueOf(strValue);
+        if (trimedValue.equalsIgnoreCase("true") || trimedValue.equalsIgnoreCase("false")) {
+            return Boolean.valueOf(trimedValue);
         }
         
+        // nothing matched - leave untouched
         return strValue;
     }    
 

Modified: incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java?rev=1179672&r1=1179671&r2=1179672&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java (original)
+++ incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java Thu Oct  6 15:46:25 2011
@@ -102,7 +102,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setUseTypeCoercion(false);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
         
-        String expected = "{\"@context\":{\"dc\":\"http://purl.org/dc/terms/\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\"},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"dc:created\":{\"@literal\":\"" + this.expectedW3CFormattedDate + "\",\"@datatype\":\"xsd:dateTime\"},\"dc:creator\":{\"@literal\":\"urn:iks-project:enhancer:test:dummyEngine\",\"@datatype\":\"@iri\"},\"dc:type\":{\"@literal\":\"http://dbpedia.org/ontology/Person\",\"@datatype\":\"@iri\"},\"enhancer:end\":{\"@literal\":\"20\",\"@datatype\":\"xsd:int\"},\"enhancer:selected-text\":{\"@literal\":\"Patrick Marshall\",\"@datatype\":\"xsd:string\"},\"enhancer:selection-context\":{\"@literal\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"@datatype\":\"xsd:string\"},\"enhancer:start\":{\"@
 literal\":\"4\",\"@datatype\":\"xsd:int\"}}";
+        String expected = "{\"@context\":{\"created\":\"http://purl.org/dc/terms/created\",\"creator\":\"http://purl.org/dc/terms/creator\",\"dateTime\":\"http://www.w3.org/2001/XMLSchema#dateTime\",\"end\":\"http://fise.iks-project.eu/ontology/end\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"int\":\"http://www.w3.org/2001/XMLSchema#int\",\"selected-text\":\"http://fise.iks-project.eu/ontology/selected-text\",\"selection-context\":\"http://fise.iks-project.eu/ontology/selection-context\",\"start\":\"http://fise.iks-project.eu/ontology/start\",\"string\":\"http://www.w3.org/2001/XMLSchema#string\",\"type\":\"http://purl.org/dc/terms/type\"},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"created\":{\"@literal\":\""+this.expectedW3CFormattedDate+"\",\"@datatype\":\"dateTime\"},\"creator\":{\"@literal\":\"urn:iks-project:enhancer:test:dummyEngine\",\"@datatype\":\"@iri\"},\"end
 \":{\"@literal\":\"20\",\"@datatype\":\"int\"},\"selected-text\":{\"@literal\":\"Patrick Marshall\",\"@datatype\":\"string\"},\"selection-context\":{\"@literal\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"@datatype\":\"string\"},\"start\":{\"@literal\":\"4\",\"@datatype\":\"int\"},\"type\":{\"@literal\":\"http://dbpedia.org/ontology/Person\",\"@datatype\":\"@iri\"}}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }
@@ -119,7 +119,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setIndentation(0);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
         
-        String expected = "{\"@context\":{\"dbp-ont\":\"http://dbpedia.org/ontology/\",\"dc\":\"http://purl.org/dc/terms/\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"@iri\":[\"dc:creator\",\"dc:type\"],\"xsd:dateTime\":\"dc:created\",\"xsd:int\":[\"enhancer:end\",\"enhancer:start\"],\"xsd:string\":[\"enhancer:selected-text\",\"enhancer:selection-context\"]}},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"dc:created\":\""+this.expectedW3CFormattedDate+"\",\"dc:creator\":\"urn:iks-project:enhancer:test:dummyEngine\",\"dc:type\":\"dbp-ont:Person\",\"enhancer:end\":20,\"enhancer:selected-text\":\"Patrick Marshall\",\"enhancer:selection-context\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"enhancer:start\":4}";
+        String expected = "{\"@context\":{\"created\":\"http://purl.org/dc/terms/created\",\"creator\":\"http://purl.org/dc/terms/creator\",\"end\":\"http://fise.iks-project.eu/ontology/end\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"Person\":\"http://dbpedia.org/ontology/Person\",\"selected-text\":\"http://fise.iks-project.eu/ontology/selected-text\",\"selection-context\":\"http://fise.iks-project.eu/ontology/selection-context\",\"start\":\"http://fise.iks-project.eu/ontology/start\",\"type\":\"http://purl.org/dc/terms/type\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"@iri\":[\"creator\",\"type\"],\"xsd:dateTime\":\"created\",\"xsd:int\":[\"end\",\"start\"],\"xsd:string\":[\"selected-text\",\"selection-context\"]}},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"created\":\""+this.expectedW3CFormattedDate+"\",\"creator\":\"urn:iks-project:enhancer:test:du
 mmyEngine\",\"end\":20,\"selected-text\":\"Patrick Marshall\",\"selection-context\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"start\":4,\"type\":\"Person\"}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }
@@ -135,7 +135,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setUseTypeCoercion(false);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
 
-        String expected = "{\n  \"@context\": {\n    \"dc\": \"http://purl.org/dc/terms/\",\n    \"enhancer\": \"http://fise.iks-project.eu/ontology/\",\n    \"xsd\": \"http://www.w3.org/2001/XMLSchema#\"\n  },\n  \"@subject\": \"urn:iks-project:enhancer:test:text-annotation:Person\",\n  \"@type\": [\n    \"enhancer:Enhancement\",\n    \"enhancer:TextAnnotation\"\n  ],\n  \"dc:created\": {\n    \"@literal\": \""+this.expectedW3CFormattedDate+"\",\n    \"@datatype\": \"xsd:dateTime\"\n  },\n  \"dc:creator\": {\n    \"@literal\": \"urn:iks-project:enhancer:test:dummyEngine\",\n    \"@datatype\": \"@iri\"\n  },\n  \"dc:type\": {\n    \"@literal\": \"http://dbpedia.org/ontology/Person\",\n    \"@datatype\": \"@iri\"\n  },\n  \"enhancer:end\": {\n    \"@literal\": \"20\",\n    \"@datatype\": \"xsd:int\"\n  },\n  \"enhancer:selected-text\": {\n    \"@literal\": \"Patrick Marshall\",\n    \"@datatype\": \"xsd:string\"\n  },\n  \"enhancer:selection-context\": {\n    \"@literal\": \"
 Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\n    \"@datatype\": \"xsd:string\"\n  },\n  \"enhancer:start\": {\n    \"@literal\": \"4\",\n    \"@datatype\": \"xsd:int\"\n  }\n}";
+        String expected = "{\n  \"@context\": {\n    \"created\": \"http://purl.org/dc/terms/created\",\n    \"creator\": \"http://purl.org/dc/terms/creator\",\n    \"dateTime\": \"http://www.w3.org/2001/XMLSchema#dateTime\",\n    \"end\": \"http://fise.iks-project.eu/ontology/end\",\n    \"enhancer\": \"http://fise.iks-project.eu/ontology/\",\n    \"int\": \"http://www.w3.org/2001/XMLSchema#int\",\n    \"selected-text\": \"http://fise.iks-project.eu/ontology/selected-text\",\n    \"selection-context\": \"http://fise.iks-project.eu/ontology/selection-context\",\n    \"start\": \"http://fise.iks-project.eu/ontology/start\",\n    \"string\": \"http://www.w3.org/2001/XMLSchema#string\",\n    \"type\": \"http://purl.org/dc/terms/type\"\n  },\n  \"@subject\": \"urn:iks-project:enhancer:test:text-annotation:Person\",\n  \"@type\": [\n    \"enhancer:Enhancement\",\n    \"enhancer:TextAnnotation\"\n  ],\n  \"created\": {\n    \"@literal\": \""+this.expectedW3CFormattedDate+"\",\n   
  \"@datatype\": \"dateTime\"\n  },\n  \"creator\": {\n    \"@literal\": \"urn:iks-project:enhancer:test:dummyEngine\",\n    \"@datatype\": \"@iri\"\n  },\n  \"end\": {\n    \"@literal\": \"20\",\n    \"@datatype\": \"int\"\n  },\n  \"selected-text\": {\n    \"@literal\": \"Patrick Marshall\",\n    \"@datatype\": \"string\"\n  },\n  \"selection-context\": {\n    \"@literal\": \"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\n    \"@datatype\": \"string\"\n  },\n  \"start\": {\n    \"@literal\": \"4\",\n    \"@datatype\": \"int\"\n  },\n  \"type\": {\n    \"@literal\": \"http://dbpedia.org/ontology/Person\",\n    \"@datatype\": \"@iri\"\n  }\n}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }
@@ -158,7 +158,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setNamespacePrefixMap(nsMap);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
 
-        String expected = "{\"@context\":{\"dcterms\":\"http://purl.org/dc/terms\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"xmlns\":\"http://www.w3.org/2001/XMLSchema#\"},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"dcterms:/created\":{\"@literal\":\""+this.expectedW3CFormattedDate+"\",\"@datatype\":\"xmlns:dateTime\"},\"dcterms:/creator\":{\"@literal\":\"urn:iks-project:enhancer:test:dummyEngine\",\"@datatype\":\"@iri\"},\"dcterms:/type\":{\"@literal\":\"http://dbpedia.org/ontology/Person\",\"@datatype\":\"@iri\"},\"enhancer:end\":{\"@literal\":\"20\",\"@datatype\":\"xmlns:int\"},\"enhancer:selected-text\":{\"@literal\":\"Patrick Marshall\",\"@datatype\":\"xmlns:string\"},\"enhancer:selection-context\":{\"@literal\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"@datatype\":\"xmlns:strin
 g\"},\"enhancer:start\":{\"@literal\":\"4\",\"@datatype\":\"xmlns:int\"}}";
+        String expected = "{\"@context\":{\"/created\":\"http://purl.org/dc/terms/created\",\"/creator\":\"http://purl.org/dc/terms/creator\",\"/type\":\"http://purl.org/dc/terms/type\",\"dateTime\":\"http://www.w3.org/2001/XMLSchema#dateTime\",\"end\":\"http://fise.iks-project.eu/ontology/end\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"int\":\"http://www.w3.org/2001/XMLSchema#int\",\"selected-text\":\"http://fise.iks-project.eu/ontology/selected-text\",\"selection-context\":\"http://fise.iks-project.eu/ontology/selection-context\",\"start\":\"http://fise.iks-project.eu/ontology/start\",\"string\":\"http://www.w3.org/2001/XMLSchema#string\"},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"/created\":{\"@literal\":\""+this.expectedW3CFormattedDate+"\",\"@datatype\":\"dateTime\"},\"/creator\":{\"@literal\":\"urn:iks-project:enhancer:test:dummyEngine\",\"@datatype\":\"@iri\"},
 \"/type\":{\"@literal\":\"http://dbpedia.org/ontology/Person\",\"@datatype\":\"@iri\"},\"end\":{\"@literal\":\"20\",\"@datatype\":\"int\"},\"selected-text\":{\"@literal\":\"Patrick Marshall\",\"@datatype\":\"string\"},\"selection-context\":{\"@literal\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"@datatype\":\"string\"},\"start\":{\"@literal\":\"4\",\"@datatype\":\"int\"}}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }
@@ -181,7 +181,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setNamespacePrefixMap(nsMap);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
 
-        String expected = "{\"@context\":{\"dbpedia\":\"http://dbpedia.org/ontology/\",\"dcterms\":\"http://purl.org/dc/terms/\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"xmlns\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"@iri\":[\"dcterms:creator\",\"dcterms:type\"],\"xmlns:dateTime\":\"dcterms:created\",\"xmlns:int\":[\"enhancer:end\",\"enhancer:start\"],\"xmlns:string\":[\"enhancer:selected-text\",\"enhancer:selection-context\"]}},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"dcterms:created\":\""+this.expectedW3CFormattedDate+"\",\"dcterms:creator\":\"urn:iks-project:enhancer:test:dummyEngine\",\"dcterms:type\":\"dbpedia:Person\",\"enhancer:end\":20,\"enhancer:selected-text\":\"Patrick Marshall\",\"enhancer:selection-context\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"enh
 ancer:start\":4}";
+        String expected = "{\"@context\":{\"created\":\"http://purl.org/dc/terms/created\",\"creator\":\"http://purl.org/dc/terms/creator\",\"end\":\"http://fise.iks-project.eu/ontology/end\",\"enhancer\":\"http://fise.iks-project.eu/ontology/\",\"Person\":\"http://dbpedia.org/ontology/Person\",\"selected-text\":\"http://fise.iks-project.eu/ontology/selected-text\",\"selection-context\":\"http://fise.iks-project.eu/ontology/selection-context\",\"start\":\"http://fise.iks-project.eu/ontology/start\",\"type\":\"http://purl.org/dc/terms/type\",\"xmlns\":\"http://www.w3.org/2001/XMLSchema#\",\"@coerce\":{\"@iri\":[\"creator\",\"type\"],\"xmlns:dateTime\":\"created\",\"xmlns:int\":[\"end\",\"start\"],\"xmlns:string\":[\"selected-text\",\"selection-context\"]}},\"@subject\":\"urn:iks-project:enhancer:test:text-annotation:Person\",\"@type\":[\"enhancer:Enhancement\",\"enhancer:TextAnnotation\"],\"created\":\""+this.expectedW3CFormattedDate+"\",\"creator\":\"urn:iks-project:enhancer
 :test:dummyEngine\",\"end\":20,\"selected-text\":\"Patrick Marshall\",\"selection-context\":\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\"start\":4,\"type\":\"Person\"}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }    
@@ -204,7 +204,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setNamespacePrefixMap(nsMap);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
 
-        String expected = "{\n    \"@context\": {\n        \"dcterms\": \"http://purl.org/dc/terms/\",\n        \"enhancer\": \"http://fise.iks-project.eu/ontology/\",\n        \"xmlns\": \"http://www.w3.org/2001/XMLSchema#\"\n    },\n    \"@subject\": \"urn:iks-project:enhancer:test:text-annotation:Person\",\n    \"@type\": [\n        \"enhancer:Enhancement\",\n        \"enhancer:TextAnnotation\"\n    ],\n    \"dcterms:created\": {\n        \"@literal\": \""+this.expectedW3CFormattedDate+"\",\n        \"@datatype\": \"xmlns:dateTime\"\n    },\n    \"dcterms:creator\": {\n        \"@literal\": \"urn:iks-project:enhancer:test:dummyEngine\",\n        \"@datatype\": \"@iri\"\n    },\n    \"dcterms:type\": {\n        \"@literal\": \"http://dbpedia.org/ontology/Person\",\n        \"@datatype\": \"@iri\"\n    },\n    \"enhancer:end\": {\n        \"@literal\": \"20\",\n        \"@datatype\": \"xmlns:int\"\n    },\n    \"enhancer:selected-text\": {\n        \"@literal\": \"Patrick M
 arshall\",\n        \"@datatype\": \"xmlns:string\"\n    },\n    \"enhancer:selection-context\": {\n        \"@literal\": \"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\n        \"@datatype\": \"xmlns:string\"\n    },\n    \"enhancer:start\": {\n        \"@literal\": \"4\",\n        \"@datatype\": \"xmlns:int\"\n    }\n}";
+        String expected = "{\n    \"@context\": {\n        \"created\": \"http://purl.org/dc/terms/created\",\n        \"creator\": \"http://purl.org/dc/terms/creator\",\n        \"dateTime\": \"http://www.w3.org/2001/XMLSchema#dateTime\",\n        \"end\": \"http://fise.iks-project.eu/ontology/end\",\n        \"enhancer\": \"http://fise.iks-project.eu/ontology/\",\n        \"int\": \"http://www.w3.org/2001/XMLSchema#int\",\n        \"selected-text\": \"http://fise.iks-project.eu/ontology/selected-text\",\n        \"selection-context\": \"http://fise.iks-project.eu/ontology/selection-context\",\n        \"start\": \"http://fise.iks-project.eu/ontology/start\",\n        \"string\": \"http://www.w3.org/2001/XMLSchema#string\",\n        \"type\": \"http://purl.org/dc/terms/type\"\n    },\n    \"@subject\": \"urn:iks-project:enhancer:test:text-annotation:Person\",\n    \"@type\": [\n        \"enhancer:Enhancement\",\n        \"enhancer:TextAnnotation\"\n    ],\n    \"created\": 
 {\n        \"@literal\": \""+this.expectedW3CFormattedDate+"\",\n        \"@datatype\": \"dateTime\"\n    },\n    \"creator\": {\n        \"@literal\": \"urn:iks-project:enhancer:test:dummyEngine\",\n        \"@datatype\": \"@iri\"\n    },\n    \"end\": {\n        \"@literal\": \"20\",\n        \"@datatype\": \"int\"\n    },\n    \"selected-text\": {\n        \"@literal\": \"Patrick Marshall\",\n        \"@datatype\": \"string\"\n    },\n    \"selection-context\": {\n        \"@literal\": \"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\n        \"@datatype\": \"string\"\n    },\n    \"start\": {\n        \"@literal\": \"4\",\n        \"@datatype\": \"int\"\n    },\n    \"type\": {\n        \"@literal\": \"http://dbpedia.org/ontology/Person\",\n        \"@datatype\": \"@iri\"\n    }\n}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }
@@ -227,7 +227,7 @@ public class JsonLdSerializerProviderTes
         jsonldProvider.setUseTypeCoercion(true);
         jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
 
-        String expected = "{\n    \"@context\": {\n        \"dbpedia\": \"http://dbpedia.org/ontology/\",\n        \"dcterms\": \"http://purl.org/dc/terms/\",\n        \"enhancer\": \"http://fise.iks-project.eu/ontology/\",\n        \"xmlns\": \"http://www.w3.org/2001/XMLSchema#\",\n        \"@coerce\": {\n            \"@iri\": [\n                \"dcterms:creator\",\n                \"dcterms:type\"\n            ],\n            \"xmlns:dateTime\": \"dcterms:created\",\n            \"xmlns:int\": [\n                \"enhancer:end\",\n                \"enhancer:start\"\n            ],\n            \"xmlns:string\": [\n                \"enhancer:selected-text\",\n                \"enhancer:selection-context\"\n            ]\n        }\n    },\n    \"@subject\": \"urn:iks-project:enhancer:test:text-annotation:Person\",\n    \"@type\": [\n        \"enhancer:Enhancement\",\n        \"enhancer:TextAnnotation\"\n    ],\n    \"dcterms:created\": \""+this.expectedW3CFormattedDate+"\"
 ,\n    \"dcterms:creator\": \"urn:iks-project:enhancer:test:dummyEngine\",\n    \"dcterms:type\": \"dbpedia:Person\",\n    \"enhancer:end\": 20,\n    \"enhancer:selected-text\": \"Patrick Marshall\",\n    \"enhancer:selection-context\": \"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\n    \"enhancer:start\": 4\n}";
+        String expected = "{\n    \"@context\": {\n        \"created\": \"http://purl.org/dc/terms/created\",\n        \"creator\": \"http://purl.org/dc/terms/creator\",\n        \"end\": \"http://fise.iks-project.eu/ontology/end\",\n        \"enhancer\": \"http://fise.iks-project.eu/ontology/\",\n        \"Person\": \"http://dbpedia.org/ontology/Person\",\n        \"selected-text\": \"http://fise.iks-project.eu/ontology/selected-text\",\n        \"selection-context\": \"http://fise.iks-project.eu/ontology/selection-context\",\n        \"start\": \"http://fise.iks-project.eu/ontology/start\",\n        \"type\": \"http://purl.org/dc/terms/type\",\n        \"xmlns\": \"http://www.w3.org/2001/XMLSchema#\",\n        \"@coerce\": {\n            \"@iri\": [\n                \"creator\",\n                \"type\"\n            ],\n            \"xmlns:dateTime\": \"created\",\n            \"xmlns:int\": [\n                \"end\",\n                \"start\"\n            ],\n         
    \"xmlns:string\": [\n                \"selected-text\",\n                \"selection-context\"\n            ]\n        }\n    },\n    \"@subject\": \"urn:iks-project:enhancer:test:text-annotation:Person\",\n    \"@type\": [\n        \"enhancer:Enhancement\",\n        \"enhancer:TextAnnotation\"\n    ],\n    \"created\": \""+this.expectedW3CFormattedDate+"\",\n    \"creator\": \"urn:iks-project:enhancer:test:dummyEngine\",\n    \"end\": 20,\n    \"selected-text\": \"Patrick Marshall\",\n    \"selection-context\": \"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\",\n    \"start\": 4,\n    \"type\": \"Person\"\n}";
         String result = serializedGraph.toString();
         Assert.assertEquals(expected, result);
     }