Permalink
Browse files

Do not overwrite @type when converting to RDF

  • Loading branch information...
1 parent 363d3d9 commit 19bdc603af746511edcc4720298fe7ad04c8f019 @lanthaler committed Jun 5, 2013
Showing with 15 additions and 7 deletions.
  1. +15 −7 Value.php
View
@@ -81,16 +81,24 @@ public static function fromJsonLd(Object $element)
: null;
if (is_int($value) || is_float($value)) {
- if ($value == (int) $value) {
- return new TypedValue(sprintf('%d', $value), RdfConstants::XSD_INTEGER);
+ if (($value != (int) $value) || (RdfConstants::XSD_DOUBLE === $type)) {
+ $value = preg_replace('/(0{0,14})E(\+?)/', 'E', sprintf('%1.15E', $value));
+
+ if ((null === $type) && (null === $language)) {
+ return new TypedValue($value, RdfConstants::XSD_DOUBLE);
+ }
} else {
- return new TypedValue(
- preg_replace('/(0{0,14})E(\+?)/', 'E', sprintf('%1.15E', $value)),
- RdfConstants::XSD_DOUBLE
- );
+ $value = sprintf('%d', $value);
+ if ((null === $type) && (null === $language)) {
+ return new TypedValue($value, RdfConstants::XSD_INTEGER);
+ }
}
} elseif (is_bool($value)) {
- return new TypedValue(($value) ? 'true' : 'false', RdfConstants::XSD_BOOLEAN);
+ $value = ($value) ? 'true' : 'false';
+
+ if ((null === $type) && (null === $language)) {
+ return new TypedValue($value, RdfConstants::XSD_BOOLEAN);
+ }
} elseif (false === is_string($value)) {
return false;
}

0 comments on commit 19bdc60

Please sign in to comment.