jenkins-bot has submitted this change and it was merged.

Change subject: Addressed several FIXMEs in RDF related code
......................................................................


Addressed several FIXMEs in RDF related code

- Add date cleanup
- Improve handling of non-literal values
- Add comments to producer
- Made adding used properties and mentioned entities configurable. I still 
think it's two separate use cases.

Change-Id: I51d6377511b42eb9cf638af975e3a940550643e6
---
M repo/includes/LinkedData/EntityDataSerializationService.php
M repo/includes/rdf/RdfBuilder.php
M repo/includes/rdf/RdfProducer.php
M repo/includes/rdf/RdfSerializer.php
M repo/tests/phpunit/data/rdf/Q4.json
M repo/tests/phpunit/data/rdf/Q4_all_statements.nt
M repo/tests/phpunit/data/rdf/Q4_claims.nt
M repo/tests/phpunit/data/rdf/Q4_props.nt
A repo/tests/phpunit/data/rdf/Q4_resolved.nt
M repo/tests/phpunit/data/rdf/Q4_truthy_statements.nt
M repo/tests/phpunit/data/rdf/Q4_values.nt
M repo/tests/phpunit/data/rdf/Q6.json
M repo/tests/phpunit/data/rdf/Q6_no_qualifiers.nt
M repo/tests/phpunit/data/rdf/Q6_qualifiers.nt
M repo/tests/phpunit/data/rdf/Q6_with_qualifiers.nt
M repo/tests/phpunit/data/rdf/Q7.json
M repo/tests/phpunit/data/rdf/Q7_references.nt
M repo/tests/phpunit/data/rdf/Q7_refs.nt
A repo/tests/phpunit/data/rdf/Q8.json
A repo/tests/phpunit/data/rdf/Q8_baddates.nt
M repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
21 files changed, 683 insertions(+), 137 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/LinkedData/EntityDataSerializationService.php 
b/repo/includes/LinkedData/EntityDataSerializationService.php
index ddab55d..0f1391e 100644
--- a/repo/includes/LinkedData/EntityDataSerializationService.php
+++ b/repo/includes/LinkedData/EntityDataSerializationService.php
@@ -493,7 +493,7 @@
                        case 'full':
                                return RdfProducer::PRODUCE_ALL;
                        case 'dump':
-                               return RdfProducer::PRODUCE_ALL_STATEMENTS | 
RdfProducer::PRODUCE_TRUTHY_STATEMENTS | RdfProducer::PRODUCE_QUALIFIERS | 
RdfProducer::PRODUCE_REFERENCES | RdfProducer::PRODUCE_SITELINKS;
+                               return RdfProducer::PRODUCE_ALL_STATEMENTS | 
RdfProducer::PRODUCE_TRUTHY_STATEMENTS | RdfProducer::PRODUCE_QUALIFIERS | 
RdfProducer::PRODUCE_REFERENCES | RdfProducer::PRODUCE_SITELINKS | 
RdfProducer::PRODUCE_FULL_VALUES;
                        case 'long':
                                return RdfProducer::PRODUCE_ALL_STATEMENTS | 
RdfProducer::PRODUCE_QUALIFIERS | RdfProducer::PRODUCE_REFERENCES | 
RdfProducer::PRODUCE_SITELINKS | RdfProducer::PRODUCE_VERSION_INFO;
                        case null: // No flavor given
diff --git a/repo/includes/rdf/RdfBuilder.php b/repo/includes/rdf/RdfBuilder.php
index a98b9f8..bd4146f 100644
--- a/repo/includes/rdf/RdfBuilder.php
+++ b/repo/includes/rdf/RdfBuilder.php
@@ -79,6 +79,10 @@
        // TODO: make the license settable
        const LICENSE = 'http://creativecommons.org/publicdomain/zero/1.0/';
 
+       // Gregorian calendar link.
+       // I'm not very happy about hardcoding it here but see no better way so 
far
+       const GREGORIAN_CALENDAR = 'http://www.wikidata.org/entity/Q1985727';
+
        public static $rankMap = array(
                Statement::RANK_DEPRECATED => self::WIKIBASE_RANK_DEPRECATED,
                Statement::RANK_NORMAL => self::WIKIBASE_RANK_NORMAL,
@@ -340,23 +344,26 @@
         * Adds meta-information about an entity (such as the ID and type) to 
the RDF graph.
         *
         * @param Entity $entity
+        * @param boolean $produceData Should we also produce Dataset node?
         */
-       private function addEntityMetaData( Entity $entity ) {
+       private function addEntityMetaData( Entity $entity, $produceData = true 
) {
                $entityResource = $this->getEntityResource( $entity->getId() );
                $entityResource->addResource( 'rdf:type', 
$this->getEntityTypeQName( $entity->getType() ) );
                $dataURL = $this->getDataURL( $entity->getId() );
 
-               $dataResource = $this->graph->resource( $dataURL );
-               $dataResource->addResource( 'rdf:type', self::NS_SCHEMA_ORG . 
":Dataset" );
-               $dataResource->addResource( self::NS_SCHEMA_ORG . ':about', 
$entityResource );
+               if( $produceData ) {
+                       $dataResource = $this->graph->resource( $dataURL );
+                       $dataResource->addResource( 'rdf:type', 
self::NS_SCHEMA_ORG . ":Dataset" );
+                       $dataResource->addResource( self::NS_SCHEMA_ORG . 
':about', $entityResource );
 
-               if( $this->shouldProduce( RdfProducer::PRODUCE_VERSION_INFO ) ) 
{
-                       // Dumps don't need version/license info for each 
entity, since it is included in the dump header
-                       $dataResource->addResource( self::NS_CC . ':license', 
self::LICENSE );
-                       $dataResource->addLiteral( self::NS_SCHEMA_ORG . 
':softwareVersion', self::FORMAT_VERSION );
+                       if( $this->shouldProduce( 
RdfProducer::PRODUCE_VERSION_INFO ) ) {
+                               // Dumps don't need version/license info for 
each entity, since it is included in the dump header
+                               $dataResource->addResource( self::NS_CC . 
':license', self::LICENSE );
+                               $dataResource->addLiteral( self::NS_SCHEMA_ORG 
. ':softwareVersion', self::FORMAT_VERSION );
+                       }
                }
 
-               // TODO: add support for property date types to RDF output
+               // TODO: add support for property data types to RDF output
 
                $this->entityResolved( $entity->getId() );
        }
@@ -522,7 +529,7 @@
                        $entityResource->addResource( $propertyQName, 
$statementResource );
                        $this->addSnak( $statementResource, $snak, 
self::NS_VALUE );
 
-                       if ( $this->shouldProduce( 
RdfProducer::PRODUCE_PROPERTIES ) ) { //FIXME: get rid of PRODUCE_PROPERTIES, 
add an option to resolveMentionedEntities instead.
+                       if( $this->shouldProduce( 
RdfProducer::PRODUCE_PROPERTIES) ) {
                                $this->entityMentioned( $snak->getPropertyId() 
);
                        }
 
@@ -601,12 +608,9 @@
                foreach( $props as $prop => $type ) {
                        $getter = "get" . ucfirst( $prop );
                        $data = $value->$getter();
-                       if ( $type == 'url' ) { //FIXME: use the logic from 
addStatementValue recursively here.
-                               $node->addResource( $this->getEntityTypeQName( 
$prop ), $data );
-                               continue;
+                       if( !is_null( $data ) ) {
+                               $this->addValueToNode( $node, 
$this->getEntityTypeQName( $prop ), $type, $data );
                        }
-                       $node->addLiteral( $this->getEntityTypeQName( $prop ),
-                                       new \EasyRdf_Literal( $data, null, 
$type ) ); //FIXME: what happens is $data is not scalar? Avoid hard crash.
                }
        }
 
@@ -633,12 +637,12 @@
                }
 
                //FIXME: use a proper registry / dispatching builder
-               $typeId = "addStatementFor".preg_replace( '/[^\w]/', '', 
ucwords( $typeId ) );
+               $typeFunc = "addStatementFor".preg_replace( '/[^\w]/', '', 
ucwords( $typeId ) );
 
-               if( !is_callable( array( $this, $typeId ) ) ) {
+               if( !is_callable( array( $this, $typeFunc ) ) ) {
                        wfLogWarning( __METHOD__ . ": Unsupported data type: 
$typeId" );
                } else {
-                       $this->$typeId( $target, $propertyValueQName, 
$dataType, $value, $simpleValue );
+                       $this->$typeFunc( $target, $propertyValueQName, 
$dataType, $value, $simpleValue );
                }
                // TODO: add special handling like in WDTK?
                // 
https://github.com/Wikidata/Wikidata-Toolkit/blob/master/wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/extensions/SimpleIdExportExtension.java
@@ -659,7 +663,9 @@
                $entityQName = $this->getEntityQName( self::NS_ENTITY, 
$entityId );
                $entityResource = $this->graph->resource( $entityQName );
                $target->addResource( $propertyValueQName, $entityResource );
-               $this->entityMentioned( $entityId );
+               if( $this->shouldProduce( 
RdfProducer::PRODUCE_RESOLVED_ENTITIES ) ) {
+                       $this->entityMentioned( $entityId );
+               }
        }
 
        /**
@@ -674,13 +680,46 @@
        private function addStatementForString( EasyRdf_Resource $target, 
$propertyValueQName, $dataType,
                        StringValue $value, $simpleValue = false ) {
                if ( $dataType == 'commonsMedia' ) {
-                       $target->addResource( $propertyValueQName, 
$this->getCommonsURI( $value->getValue() ) );
+                       $this->addValueToNode( $target, $propertyValueQName, 
'url', $this->getCommonsURI( $value->getValue() ) );
                } elseif ( $dataType == 'url' ) {
-                       $target->addResource( $propertyValueQName, 
$value->getValue() );
+                       $this->addValueToNode( $target, $propertyValueQName, 
'url', $value->getValue() );
                } else {
                        $target->addLiteral( $propertyValueQName, new 
EasyRdf_Literal( $value->getValue() ) );
                }
        }
+
+       /**
+        * Add value to a node
+        * This function does massaging needed for RDF data types.
+        *
+        * @param EasyRdf_Resource $target
+        * @param string $propertyName
+        * @param string $type
+        * @param string $value
+        */
+       private function addValueToNode( EasyRdf_Resource $target, 
$propertyName, $type, $value ) {
+               if( $type == 'url' ) {
+                       $target->addResource( $propertyName, $value );
+               } elseif( $type == 'xsd:dateTime' ) {
+                       $target->addLiteral( $propertyName,
+                                       new \EasyRdf_Literal_DateTime( 
$this->cleanupDateValue( $value ) ) );
+               } elseif( $type == 'xsd:decimal' ) {
+                       // TODO: handle precision here?
+                       if( $value instanceof DecimalValue ) {
+                               $value = $value->getValue();
+                       }
+                       $target->addLiteral( $propertyName, new 
\EasyRdf_Literal_Decimal( $value ) );
+               } else {
+                       if( !is_scalar( $value ) ) {
+                               // somehow we got a weird value, better not 
risk it and bail
+                               $vtype = gettype( $value );
+                               wfLogWarning( "Bad value passed to 
addValueToNode for {$target->getUri()}:$propertyName: $vtype" );
+                               return;
+                       }
+                       $target->addLiteral( $propertyName, new 
\EasyRdf_Literal( $value, null, $type ) );
+               }
+       }
+
 
        /**
         * Adds specific value
@@ -697,6 +736,73 @@
        }
 
        /**
+        * Clean up Wikidata date value in Gregorian calendar
+        * - remove + from the start - not all data stores like that
+        * - validate month and date value
+        * @param string $dateValue
+        * @return string Value compatible with xsd:dateTime type
+        */
+       private function cleanupDateValue( $dateValue ) {
+               list($date, $time) = explode( "T", $dateValue, 2 );
+               if( $date[0] == "-" ) {
+                       list($y, $m, $d) = explode( "-", substr( $date, 1 ), 3 
);
+                       $y = -(int)$y;
+               } else {
+                       list($y, $m, $d) = explode( "-", $date, 3 );
+                       $y = (int)$y;
+               }
+
+               $m = (int)$m;
+               $d = (int)$d;
+
+               // PHP source docs say PHP gregorian calendar can work down to 
4714 BC
+               // for smaller dates, we ignore month/day
+               if( $y <= -4714 ) {
+                       $d = $m = 1;
+               }
+
+               if( $m <= 0 ) {
+                       $m = 1;
+               }
+               if( $m >= 12 ) {
+                       // Why anybody would do something like that? Anyway, 
better to check.
+                       $m = 12;
+               }
+               if( $d <= 0 ) {
+                       $d = 1;
+               }
+               // check if the date "looks safe". If not, we do deeper check
+               if( !( $d <= 28 || ( $m != 2 && $d <= 30 ) ) ) {
+                       $max = cal_days_in_month( CAL_GREGORIAN, $m, $y );
+                       // We just put it as the last day in month, won't 
bother further
+                       if( $d > $max ) {
+                               $d = $max;
+                       }
+               }
+               // This is a bit weird since xsd:dateTime requires >=4 digit 
always,
+               // and leading 0 is not allowed for 5 digits
+               // But sprintf counts - as digit
+               // See: http://www.w3.org/TR/xmlschema-2/#dateTime
+               return sprintf( "%s%04d-%02d-%02dT%s", ($y < 0)? "-":"", abs( 
$y ), $m, $d, $time );
+       }
+
+       /**
+        * Get literal that reperesent the date in RDF
+        * If we can convert it to xsd:dateTime, we'll do that.
+        * Otherwise, we leave it as string
+        * @param TimeValue $value
+        * @return EasyRdf_Literal
+        */
+       private function getDateLiteral( TimeValue $value ) {
+               $calendar = $value->getCalendarModel();
+               if( $calendar == self::GREGORIAN_CALENDAR ) {
+                       return new \EasyRdf_Literal_DateTime( 
$this->cleanupDateValue( $value->getTime() ) );
+               }
+               // TODO: add handling for Julian values
+               return new EasyRdf_Literal( $value->getTime() );
+       }
+
+       /**
         * Adds specific value
         *
         * @param EasyRdf_Resource $target
@@ -707,11 +813,12 @@
         */
        private function addStatementForTime( EasyRdf_Resource $target, 
$propertyValueQName, $dataType,
                        TimeValue $value, $simpleValue = false ) {
-               // TODO: we may want to deal with Julian dates here? //FIXME: 
EasyRdf_Literal_DateTime may fail hard on non-iso dates! Needs error handling / 
fallback.
-               $target->addLiteral( $propertyValueQName, new 
\EasyRdf_Literal_DateTime( $value->getTime() ) );
+
+               $target->addLiteral( $propertyValueQName, 
$this->getDateLiteral( $value ) );
+
                if ( !$simpleValue && $this->shouldProduce( 
RdfProducer::PRODUCE_FULL_VALUES ) ) { //FIXME: register separate generators 
for different output flavors.
                        $this->addExpandedValue( $target, $propertyValueQName, 
$value,
-                                       array(  'time' => 'xsd:dateTime', 
//FIXME: only true for gregorian!
+                                       array(  'time' => '',
                                                        // TODO: eventually use 
identifier here
                                                        'precision' => 
'xsd:integer',
                                                        'timezone' => 
'xsd:integer',
@@ -780,7 +887,7 @@
         *
         * @param EntityLookup $entityLookup
         */
-       public function resolvedMentionedEntities( EntityLookup $entityLookup ) 
{ //FIXME: needs test
+       public function resolveMentionedEntities( EntityLookup $entityLookup ) 
{ //FIXME: needs test
                // @todo inject a DispatchingEntityIdParser
                $idParser = new BasicEntityIdParser();
 
@@ -825,7 +932,7 @@
         * @param Entity $entity
         */
        private function addEntityStub( Entity $entity ) {
-               $this->addEntityMetaData( $entity );
+               $this->addEntityMetaData( $entity, false );
                $this->addLabels( $entity );
                $this->addDescriptions( $entity );
        }
diff --git a/repo/includes/rdf/RdfProducer.php 
b/repo/includes/rdf/RdfProducer.php
index e9660c8..24f722d 100644
--- a/repo/includes/rdf/RdfProducer.php
+++ b/repo/includes/rdf/RdfProducer.php
@@ -7,15 +7,57 @@
  */
 interface RdfProducer {
 
-       //FIXME: documentation needed
+       /** Produce "truthy" statements, i.e. best ranked
+        * entity-property-value without qualifiers or expanded values
+        */
        const PRODUCE_TRUTHY_STATEMENTS = 1;
+
+       /**
+        * Produce all statements
+        */
        const PRODUCE_ALL_STATEMENTS    = 2;
+
+       /**
+        * Produce qualifiers for statements
+        * Should be used together with PRODUCE_ALL_STATEMENTS.
+        */
        const PRODUCE_QUALIFIERS        = 4;
+
+       /**
+        * Produce references for statements
+        * Should be used together with PRODUCE_ALL_STATEMENTS.
+        */
        const PRODUCE_REFERENCES        = 8;
+
+       /**
+        * Produce links and badges
+        */
        const PRODUCE_SITELINKS         = 16;
+
+       /**
+        * Add entity definitions for properties used in the dump.
+        */
        const PRODUCE_PROPERTIES        = 32;
+
+       /**
+        * Produce full expanded values as nodes.
+        * Should be used together with PRODUCE_ALL_STATEMENTS.
+        * @var unknown
+        */
        const PRODUCE_FULL_VALUES       = 64;
+
+       /**
+        * Produce metadata header containing software version info and 
copyright.
+        */
        const PRODUCE_VERSION_INFO      = 128;
 
-       const PRODUCE_ALL = 0xFF;
+       /**
+        * Produce definitions for all entities used in the dump
+        */
+       const PRODUCE_RESOLVED_ENTITIES = 256;
+
+       /**
+        * All options turned on.
+        */
+       const PRODUCE_ALL = 0xFFFF;
 }
\ No newline at end of file
diff --git a/repo/includes/rdf/RdfSerializer.php 
b/repo/includes/rdf/RdfSerializer.php
index f9fc98a..23836b6 100644
--- a/repo/includes/rdf/RdfSerializer.php
+++ b/repo/includes/rdf/RdfSerializer.php
@@ -145,7 +145,7 @@
 
                $builder->addEntity( $entityRevision->getEntity() );
 
-               $builder->resolvedMentionedEntities( $this->entityLookup ); 
//TODO: optional
+               $builder->resolveMentionedEntities( $this->entityLookup ); 
//TODO: optional
 
                $graph = $builder->getGraph();
                return $graph;
diff --git a/repo/tests/phpunit/data/rdf/Q4.json 
b/repo/tests/phpunit/data/rdf/Q4.json
index 15032b1..0b70c4a 100644
--- a/repo/tests/phpunit/data/rdf/Q4.json
+++ b/repo/tests/phpunit/data/rdf/Q4.json
@@ -74,8 +74,7 @@
                         "value": {
                             "latitude": 12.345,
                             "longitude": 67.89,
-                            "altitude": null,
-                            "precision": null,
+                            "precision": 0.01,
                             "globe": "http:\/\/www.wikidata.org\/entity\/Q2"
                         },
                         "type": "globecoordinate"
@@ -181,7 +180,7 @@
                             "before": 0,
                             "after": 0,
                             "precision": 9,
-                            "calendarmodel": "http:\/\/calendar.acme.test\/"
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
                         },
                         "type": "time"
                     }
@@ -207,4 +206,4 @@
             }
         ]
     }
-}
\ No newline at end of file
+}
diff --git a/repo/tests/phpunit/data/rdf/Q4_all_statements.nt 
b/repo/tests/phpunit/data/rdf/Q4_all_statements.nt
index 60c38a6..5bf09be 100644
--- a/repo/tests/phpunit/data/rdf/Q4_all_statements.nt
+++ b/repo/tests/phpunit/data/rdf/Q4_all_statements.nt
@@ -41,7 +41,7 @@
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://acme.test/value/P7> "simplestring" .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
-<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 
<http://acme.test/statement/TEST-Statement-9-2669d541dfd2d6cc0105927bff02bbe0eec0e921>
 <http://acme.test/value/P9> <http://url.acme.test/> .
diff --git a/repo/tests/phpunit/data/rdf/Q4_claims.nt 
b/repo/tests/phpunit/data/rdf/Q4_claims.nt
index 4b1c616..853e11b 100644
--- a/repo/tests/phpunit/data/rdf/Q4_claims.nt
+++ b/repo/tests/phpunit/data/rdf/Q4_claims.nt
@@ -18,7 +18,7 @@
 <http://acme.test/Q4> <http://acme.test/assert/P5> 
<http://www.wikidata.org/ontology-0.0.1#Somevalue> .
 <http://acme.test/Q4> <http://acme.test/assert/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/Q4> <http://acme.test/assert/P7> "simplestring" .
-<http://acme.test/Q4> <http://acme.test/assert/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q4> <http://acme.test/assert/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://acme.test/Q4> <http://acme.test/assert/P9> <http://url.acme.test/> .
 <http://acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
 
<http://acme.test/statement/TEST-Statement-2-423614cd831ed4e8da1138c9229cb65cf96f9366>
 <http://acme.test/value/P2> <http://acme.test/Q42> .
@@ -33,7 +33,7 @@
 
<http://acme.test/statement/TEST-Statement-3-b181ddac61642fe80bbf8e4a8eaa1da425cb0ac9>
 <http://acme.test/value/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
 
<http://acme.test/statement/TEST-Statement-3-b181ddac61642fe80bbf8e4a8eaa1da425cb0ac9>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-3-b181ddac61642fe80bbf8e4a8eaa1da425cb0ac9>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
-<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://acme.test/value/P4-value> 
<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> .
+<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://acme.test/value/P4-value> 
<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> .
 
<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://acme.test/value/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
 
<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
@@ -53,8 +53,8 @@
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://acme.test/value/P7> "simplestring" .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
-<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8-value> 
<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> .
-<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8-value> 
<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> .
+<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 
<http://acme.test/statement/TEST-Statement-9-2669d541dfd2d6cc0105927bff02bbe0eec0e921>
 <http://acme.test/value/P9> <http://url.acme.test/> .
@@ -66,18 +66,18 @@
 <http://data.acme.test/Q4> <http://schema.org/softwareVersion> "0.0.1" .
 <http://data.acme.test/Q4> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
 <http://data.acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
""^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"0.01"^^<http://www.w3.org/2001/XMLSchema#decimal> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Amount> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#LowerBound> 
"+19.766999999999999459987520822323858737945556640625"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Unit> "1" .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#UpperBound> 
"+19.76899999999999835154085303656756877899169921875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://calendar.acme.test/> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Time> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Time> "-00000000200-00-00T00:00:00Z" .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
diff --git a/repo/tests/phpunit/data/rdf/Q4_props.nt 
b/repo/tests/phpunit/data/rdf/Q4_props.nt
index 60c38a6..86ea306 100644
--- a/repo/tests/phpunit/data/rdf/Q4_props.nt
+++ b/repo/tests/phpunit/data/rdf/Q4_props.nt
@@ -41,7 +41,7 @@
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://acme.test/value/P7> "simplestring" .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
-<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 
<http://acme.test/statement/TEST-Statement-9-2669d541dfd2d6cc0105927bff02bbe0eec0e921>
 <http://acme.test/value/P9> <http://url.acme.test/> .
@@ -51,3 +51,35 @@
 <http://data.acme.test/Q4> <http://schema.org/dateModified> 
"2013-10-04T03:31:05Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://data.acme.test/Q4> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
 <http://data.acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
+<http://acme.test/P2> <http://schema.org/name> "Property2"@en .
+<http://acme.test/P2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P2> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property2"@en .
+<http://acme.test/P2> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property2"@en .
+<http://acme.test/P3> <http://schema.org/name> "Property3"@en .
+<http://acme.test/P3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P3> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property3"@en .
+<http://acme.test/P3> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property3"@en .
+<http://acme.test/P4> <http://schema.org/name> "Property4"@en .
+<http://acme.test/P4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P4> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property4"@en .
+<http://acme.test/P4> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property4"@en .
+<http://acme.test/P5> <http://schema.org/name> "Property5"@en .
+<http://acme.test/P5> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P5> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property5"@en .
+<http://acme.test/P5> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property5"@en .
+<http://acme.test/P6> <http://schema.org/name> "Property6"@en .
+<http://acme.test/P6> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P6> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property6"@en .
+<http://acme.test/P6> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property6"@en .
+<http://acme.test/P7> <http://schema.org/name> "Property7"@en .
+<http://acme.test/P7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P7> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property7"@en .
+<http://acme.test/P7> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property7"@en .
+<http://acme.test/P8> <http://schema.org/name> "Property8"@en .
+<http://acme.test/P8> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P8> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property8"@en .
+<http://acme.test/P8> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property8"@en .
+<http://acme.test/P9> <http://schema.org/name> "Property9"@en .
+<http://acme.test/P9> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Property> .
+<http://acme.test/P9> <http://www.w3.org/2000/01/rdf-schema#label> 
"Property9"@en .
+<http://acme.test/P9> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Property9"@en .
diff --git a/repo/tests/phpunit/data/rdf/Q4_resolved.nt 
b/repo/tests/phpunit/data/rdf/Q4_resolved.nt
new file mode 100644
index 0000000..734f503
--- /dev/null
+++ b/repo/tests/phpunit/data/rdf/Q4_resolved.nt
@@ -0,0 +1,19 @@
+<http://acme.test/Q4> <http://acme.test/assert/P2> <http://acme.test/Q42> .
+<http://acme.test/Q4> <http://acme.test/assert/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
+<http://acme.test/Q4> <http://acme.test/assert/P3> 
<http://www.wikidata.org/ontology-0.0.1#Novalue> .
+<http://acme.test/Q4> <http://acme.test/assert/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
+<http://acme.test/Q4> <http://acme.test/assert/P5> 
"\u043F\u0440\u0435\u0432\u0435\u0434"@ru .
+<http://acme.test/Q4> <http://acme.test/assert/P5> 
<http://www.wikidata.org/ontology-0.0.1#Somevalue> .
+<http://acme.test/Q4> <http://acme.test/assert/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
+<http://acme.test/Q4> <http://acme.test/assert/P7> "simplestring" .
+<http://acme.test/Q4> <http://acme.test/assert/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q4> <http://acme.test/assert/P9> <http://url.acme.test/> .
+<http://acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
+<http://data.acme.test/Q4> <http://schema.org/about> <http://acme.test/Q4> .
+<http://data.acme.test/Q4> <http://schema.org/dateModified> 
"2013-10-04T03:31:05Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://data.acme.test/Q4> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
+<http://acme.test/Q42> <http://schema.org/name> "Item42"@en .
+<http://acme.test/Q42> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
+<http://acme.test/Q42> <http://www.w3.org/2000/01/rdf-schema#label> 
"Item42"@en .
+<http://acme.test/Q42> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"Item42"@en .
diff --git a/repo/tests/phpunit/data/rdf/Q4_truthy_statements.nt 
b/repo/tests/phpunit/data/rdf/Q4_truthy_statements.nt
index c0341ba..030de15 100644
--- a/repo/tests/phpunit/data/rdf/Q4_truthy_statements.nt
+++ b/repo/tests/phpunit/data/rdf/Q4_truthy_statements.nt
@@ -6,7 +6,7 @@
 <http://acme.test/Q4> <http://acme.test/assert/P5> 
<http://www.wikidata.org/ontology-0.0.1#Somevalue> .
 <http://acme.test/Q4> <http://acme.test/assert/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/Q4> <http://acme.test/assert/P7> "simplestring" .
-<http://acme.test/Q4> <http://acme.test/assert/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q4> <http://acme.test/assert/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://acme.test/Q4> <http://acme.test/assert/P9> <http://url.acme.test/> .
 <http://acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
 <http://data.acme.test/Q4> <http://schema.org/about> <http://acme.test/Q4> .
diff --git a/repo/tests/phpunit/data/rdf/Q4_values.nt 
b/repo/tests/phpunit/data/rdf/Q4_values.nt
index 3b923a5..9e751a8 100644
--- a/repo/tests/phpunit/data/rdf/Q4_values.nt
+++ b/repo/tests/phpunit/data/rdf/Q4_values.nt
@@ -23,7 +23,7 @@
 
<http://acme.test/statement/TEST-Statement-3-b181ddac61642fe80bbf8e4a8eaa1da425cb0ac9>
 <http://acme.test/value/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
 
<http://acme.test/statement/TEST-Statement-3-b181ddac61642fe80bbf8e4a8eaa1da425cb0ac9>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-3-b181ddac61642fe80bbf8e4a8eaa1da425cb0ac9>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
-<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://acme.test/value/P4-value> 
<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> .
+<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://acme.test/value/P4-value> 
<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> .
 
<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://acme.test/value/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
 
<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-4-8749fa158a249e1befa6ed077f648c56197a2b2d>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
@@ -43,8 +43,8 @@
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://acme.test/value/P7> "simplestring" .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-7-6063d202e584b79a2e9f89ab92b51e7f22ef9886>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
-<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8-value> 
<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> .
-<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8-value> 
<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> .
+<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
 
<http://acme.test/statement/TEST-Statement-8-5dd0f6624a7545401bc306a068ac1bbe8148bfac>
 <http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 
<http://acme.test/statement/TEST-Statement-9-2669d541dfd2d6cc0105927bff02bbe0eec0e921>
 <http://acme.test/value/P9> <http://url.acme.test/> .
@@ -54,18 +54,18 @@
 <http://data.acme.test/Q4> <http://schema.org/dateModified> 
"2013-10-04T03:31:05Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://data.acme.test/Q4> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
 <http://data.acme.test/Q4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
""^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/974afffbe8c12ab5579f4b521ae2bd5d> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"0.01"^^<http://www.w3.org/2001/XMLSchema#decimal> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Amount> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#LowerBound> 
"+19.766999999999999459987520822323858737945556640625"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Unit> "1" .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#UpperBound> 
"+19.76899999999999835154085303656756877899169921875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://calendar.acme.test/> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Time> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Time> "-00000000200-00-00T00:00:00Z" .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
diff --git a/repo/tests/phpunit/data/rdf/Q6.json 
b/repo/tests/phpunit/data/rdf/Q6.json
index 8bb2e9c..a815e68 100644
--- a/repo/tests/phpunit/data/rdf/Q6.json
+++ b/repo/tests/phpunit/data/rdf/Q6.json
@@ -70,8 +70,7 @@
                                 "value": {
                                     "latitude": 12.345,
                                     "longitude": 67.89,
-                                    "altitude": null,
-                                    "precision": null,
+                                    "precision": 0.1,
                                     "globe": 
"http:\/\/www.wikidata.org\/entity\/Q2"
                                 },
                                 "type": "globecoordinate"
@@ -153,7 +152,7 @@
                                     "before": 0,
                                     "after": 0,
                                     "precision": 9,
-                                    "calendarmodel": 
"http:\/\/calendar.acme.test\/"
+                                    "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
                                 },
                                 "type": "time"
                             }
@@ -187,4 +186,4 @@
             }
         ]
     }
-}
\ No newline at end of file
+}
diff --git a/repo/tests/phpunit/data/rdf/Q6_no_qualifiers.nt 
b/repo/tests/phpunit/data/rdf/Q6_no_qualifiers.nt
index 5dedf99..7d8812b 100644
--- a/repo/tests/phpunit/data/rdf/Q6_no_qualifiers.nt
+++ b/repo/tests/phpunit/data/rdf/Q6_no_qualifiers.nt
@@ -1,4 +1,3 @@
-
 <http://acme.test/Q6> <http://acme.test/P7> 
<http://acme.test/statement/TEST-Qualifiers> .
 <http://acme.test/Q6> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/value/P7> 
"string" .
@@ -7,4 +6,4 @@
 <http://data.acme.test/Q6> <http://schema.org/about> <http://acme.test/Q6> .
 <http://data.acme.test/Q6> <http://schema.org/dateModified> 
"2013-10-04T03:31:05Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://data.acme.test/Q6> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
-<http://data.acme.test/Q6> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
\ No newline at end of file
+<http://data.acme.test/Q6> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
diff --git a/repo/tests/phpunit/data/rdf/Q6_qualifiers.nt 
b/repo/tests/phpunit/data/rdf/Q6_qualifiers.nt
index 8c053bd..1ff4040 100644
--- a/repo/tests/phpunit/data/rdf/Q6_qualifiers.nt
+++ b/repo/tests/phpunit/data/rdf/Q6_qualifiers.nt
@@ -5,7 +5,7 @@
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P2> 
<http://acme.test/Q666> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P3> 
<http://www.wikidata.org/ontology-0.0.1#Novalue> .
-<http://acme.test/statement/TEST-Qualifiers> 
<http://acme.test/qualifier/P4-value> 
<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> .
+<http://acme.test/statement/TEST-Qualifiers> 
<http://acme.test/qualifier/P4-value> 
<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P4> 
"Point(12.345 67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P5> 
"\u0431\u0440\u0435\u0434"@ru .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P5> 
"\u043F\u0440\u0435\u0432\u0435\u0434"@ru .
@@ -13,8 +13,8 @@
 <http://acme.test/statement/TEST-Qualifiers> 
<http://acme.test/qualifier/P6-value> 
<http://acme.test/value/1e09d673624819aacd170165aae555a1> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P7> 
"simplestring" .
-<http://acme.test/statement/TEST-Qualifiers> 
<http://acme.test/qualifier/P8-value> 
<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> .
-<http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Qualifiers> 
<http://acme.test/qualifier/P8-value> 
<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> .
+<http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P9> 
<http://url.acme.test/> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/value/P7> 
"string" .
 <http://acme.test/statement/TEST-Qualifiers> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
@@ -25,18 +25,18 @@
 <http://data.acme.test/Q6> <http://schema.org/softwareVersion> "0.0.1" .
 <http://data.acme.test/Q6> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
 <http://data.acme.test/Q6> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
""^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"0.1"^^<http://www.w3.org/2001/XMLSchema#decimal> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Amount> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#LowerBound> 
"+19.766999999999999459987520822323858737945556640625"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Unit> "1" .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#UpperBound> 
"+19.76899999999999835154085303656756877899169921875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://calendar.acme.test/> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Time> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Time> "-00000000200-00-00T00:00:00Z" .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
diff --git a/repo/tests/phpunit/data/rdf/Q6_with_qualifiers.nt 
b/repo/tests/phpunit/data/rdf/Q6_with_qualifiers.nt
index 1a5b946..16fdd5b 100644
--- a/repo/tests/phpunit/data/rdf/Q6_with_qualifiers.nt
+++ b/repo/tests/phpunit/data/rdf/Q6_with_qualifiers.nt
@@ -10,7 +10,7 @@
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P5> 
<http://www.wikidata.org/ontology-0.0.1#Somevalue> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P7> 
"simplestring" .
-<http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/qualifier/P9> 
<http://url.acme.test/> .
 <http://acme.test/statement/TEST-Qualifiers> <http://acme.test/value/P7> 
"string" .
 <http://acme.test/statement/TEST-Qualifiers> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
diff --git a/repo/tests/phpunit/data/rdf/Q7.json 
b/repo/tests/phpunit/data/rdf/Q7.json
index 324b294..1ac7d39 100644
--- a/repo/tests/phpunit/data/rdf/Q7.json
+++ b/repo/tests/phpunit/data/rdf/Q7.json
@@ -70,8 +70,7 @@
                                         "value": {
                                             "latitude": 12.345,
                                             "longitude": 67.89,
-                                            "altitude": null,
-                                            "precision": null,
+                                            "precision": 0.1,
                                             "globe": 
"http:\/\/www.wikidata.org\/entity\/Q2"
                                         },
                                         "type": "globecoordinate"
@@ -147,7 +146,7 @@
                                             "before": 0,
                                             "after": 0,
                                             "precision": 9,
-                                            "calendarmodel": 
"http:\/\/calendar.acme.test\/"
+                                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
                                         },
                                         "type": "time"
                                     }
@@ -245,8 +244,7 @@
                                         "value": {
                                             "latitude": 12.345,
                                             "longitude": 67.89,
-                                            "altitude": null,
-                                            "precision": null,
+                                            "precision": 0.1,
                                             "globe": 
"http:\/\/www.wikidata.org\/entity\/Q2"
                                         },
                                         "type": "globecoordinate"
@@ -322,7 +320,7 @@
                                             "before": 0,
                                             "after": 0,
                                             "precision": 9,
-                                            "calendarmodel": 
"http:\/\/calendar.acme.test\/"
+                                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
                                         },
                                         "type": "time"
                                     }
@@ -355,4 +353,4 @@
             }
         ]
     }
-}
\ No newline at end of file
+}
diff --git a/repo/tests/phpunit/data/rdf/Q7_references.nt 
b/repo/tests/phpunit/data/rdf/Q7_references.nt
index 27c8518..140b123 100644
--- a/repo/tests/phpunit/data/rdf/Q7_references.nt
+++ b/repo/tests/phpunit/data/rdf/Q7_references.nt
@@ -3,29 +3,29 @@
 <http://acme.test/Q7> <http://acme.test/assert/P7> "string" .
 <http://acme.test/Q7> <http://acme.test/assert/P7> "string2" .
 <http://acme.test/Q7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P2> <http://acme.test/Q42> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P2> <http://acme.test/Q666> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P3> <http://www.wikidata.org/ontology-0.0.1#Novalue> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P4-value> 
<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P5> "\u0431\u0440\u0435\u0434"@ru .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P5> "\u043F\u0440\u0435\u0432\u0435\u0434"@ru .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P5> <http://www.wikidata.org/ontology-0.0.1#Somevalue> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P6-value> 
<http://acme.test/value/1e09d673624819aacd170165aae555a1> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P7> "simplestring" .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P8-value> 
<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P9> <http://url.acme.test/> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Reference> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P2> <http://acme.test/Q42> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P2> <http://acme.test/Q666> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P3> <http://www.wikidata.org/ontology-0.0.1#Novalue> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P4-value> 
<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P5> "\u0431\u0440\u0435\u0434"@ru .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P5> "\u043F\u0440\u0435\u0432\u0435\u0434"@ru .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P5> <http://www.wikidata.org/ontology-0.0.1#Somevalue> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P6-value> 
<http://acme.test/value/1e09d673624819aacd170165aae555a1> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P7> "simplestring" .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P8-value> 
<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P9> <http://url.acme.test/> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Reference> .
 <http://acme.test/statement/TEST-References-2> <http://acme.test/value/P7> 
"string2" .
 <http://acme.test/statement/TEST-References-2> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
-<http://acme.test/statement/TEST-References-2> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> .
+<http://acme.test/statement/TEST-References-2> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> .
 <http://acme.test/statement/TEST-References-2> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 <http://acme.test/statement/TEST-References> <http://acme.test/value/P7> 
"string" .
 <http://acme.test/statement/TEST-References> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
-<http://acme.test/statement/TEST-References> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> .
+<http://acme.test/statement/TEST-References> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> .
 <http://acme.test/statement/TEST-References> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 <http://data.acme.test/Q7> <http://creativecommons.org/ns#license> 
<http://creativecommons.org/publicdomain/zero/1.0/> .
 <http://data.acme.test/Q7> <http://schema.org/about> <http://acme.test/Q7> .
@@ -33,18 +33,18 @@
 <http://data.acme.test/Q7> <http://schema.org/softwareVersion> "0.0.1" .
 <http://data.acme.test/Q7> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
 <http://data.acme.test/Q7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
-<http://acme.test/value/a490f3ae6258459a479723fa2f0d8141> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
""^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Globe> 
<http://www.wikidata.org/entity/Q2> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Latitude> 
"12.345"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Longitude> 
"67.89"^^<http://www.w3.org/2001/XMLSchema#decimal> .
+<http://acme.test/value/aad6b70bccf9875ba61d31c767b7f652> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"0.1"^^<http://www.w3.org/2001/XMLSchema#decimal> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Amount> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#LowerBound> 
"+19.766999999999999459987520822323858737945556640625"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#Unit> "1" .
 <http://acme.test/value/1e09d673624819aacd170165aae555a1> 
<http://www.wikidata.org/ontology-0.0.1#UpperBound> 
"+19.76899999999999835154085303656756877899169921875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://calendar.acme.test/> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Time> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
-<http://acme.test/value/c7499b57a1a474e6a89f4c3b42ca01e7> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Time> "-00000000200-00-00T00:00:00Z" .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
diff --git a/repo/tests/phpunit/data/rdf/Q7_refs.nt 
b/repo/tests/phpunit/data/rdf/Q7_refs.nt
index 638279f..99ac1c7 100644
--- a/repo/tests/phpunit/data/rdf/Q7_refs.nt
+++ b/repo/tests/phpunit/data/rdf/Q7_refs.nt
@@ -1,26 +1,26 @@
 <http://acme.test/Q7> <http://acme.test/P7> 
<http://acme.test/statement/TEST-References-2> .
 <http://acme.test/Q7> <http://acme.test/P7> 
<http://acme.test/statement/TEST-References> .
 <http://acme.test/Q7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P2> <http://acme.test/Q42> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P2> <http://acme.test/Q666> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P3> <http://www.wikidata.org/ontology-0.0.1#Novalue> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P5> "\u0431\u0440\u0435\u0434"@ru .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P5> "\u043F\u0440\u0435\u0432\u0435\u0434"@ru .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P5> <http://www.wikidata.org/ontology-0.0.1#Somevalue> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P7> "simplestring" .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P8> 
"-00000000200-00-00T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://acme.test/value/P9> <http://url.acme.test/> .
-<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Reference> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P2> <http://acme.test/Q42> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P2> <http://acme.test/Q666> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P3> 
<http://commons.wikimedia.org/wiki/Special:FilePath/Universe.svg> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P3> <http://www.wikidata.org/ontology-0.0.1#Novalue> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P4> "Point(12.345 
67.89)"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P5> "\u0431\u0440\u0435\u0434"@ru .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P5> "\u043F\u0440\u0435\u0432\u0435\u0434"@ru .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P5> <http://www.wikidata.org/ontology-0.0.1#Somevalue> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P6> 
"+19.768000000000000682121026329696178436279296875"^^<http://www.w3.org/2001/XMLSchema#decimal>
 .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P7> "simplestring" .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://acme.test/value/P9> <http://url.acme.test/> .
+<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Reference> .
 <http://acme.test/statement/TEST-References-2> <http://acme.test/value/P7> 
"string2" .
 <http://acme.test/statement/TEST-References-2> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
-<http://acme.test/statement/TEST-References-2> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> .
+<http://acme.test/statement/TEST-References-2> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> .
 <http://acme.test/statement/TEST-References-2> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 <http://acme.test/statement/TEST-References> <http://acme.test/value/P7> 
"string" .
 <http://acme.test/statement/TEST-References> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
-<http://acme.test/statement/TEST-References> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/a9059ae62c138ba7535ece019f82fb2e1fb44d13> .
+<http://acme.test/statement/TEST-References> 
<http://www.w3.org/ns/prov#wasDerivedFrom> 
<http://acme.test/reference/94c1119b352b4ed0b6d9182b77a9b249f9ec28c8> .
 <http://acme.test/statement/TEST-References> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
 <http://data.acme.test/Q7> <http://schema.org/about> <http://acme.test/Q7> .
 <http://data.acme.test/Q7> <http://schema.org/dateModified> 
"2013-10-04T03:31:05Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
diff --git a/repo/tests/phpunit/data/rdf/Q8.json 
b/repo/tests/phpunit/data/rdf/Q8.json
new file mode 100644
index 0000000..6551dc4
--- /dev/null
+++ b/repo/tests/phpunit/data/rdf/Q8.json
@@ -0,0 +1,218 @@
+{
+    "id": "Q8",
+    "type": "item",
+    "claims": {
+        "P8": [
+            {
+                "id": "TEST-Dates-8-1",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "-00000000200-00-00T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-2",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000000200-10-00T00:00:00Z",
+                            "timezone": 60,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-3",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "-00200000200-04-31T00:00:00Z",
+                            "timezone": -60,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-4",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000000200-02-30T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-5",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000002014-02-29T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-6",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000002014-04-31T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-7",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000002012-02-29T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-8",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000002012-02-29T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985786"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-9",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+00000002012-02-31T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 9,
+                            "calendarmodel": "http:\/\/acme.test\/calendar"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            },
+            {
+                "id": "TEST-Dates-8-10",
+                "mainsnak": {
+                    "snaktype": "value",
+                    "property": "P8",
+                    "datatype": "time",
+                    "datavalue": {
+                        "value": {
+                            "time": "+02000000200-10-00T00:00:00Z",
+                            "timezone": 0,
+                            "before": 0,
+                            "after": 0,
+                            "precision": 5,
+                            "calendarmodel": 
"http:\/\/www.wikidata.org\/entity\/Q1985727"
+                        },
+                        "type": "time"
+                    }
+                },
+                "type": "statement",
+                "rank": "normal"
+            }
+        ]
+    }
+}
diff --git a/repo/tests/phpunit/data/rdf/Q8_baddates.nt 
b/repo/tests/phpunit/data/rdf/Q8_baddates.nt
new file mode 100644
index 0000000..08cd327
--- /dev/null
+++ b/repo/tests/phpunit/data/rdf/Q8_baddates.nt
@@ -0,0 +1,118 @@
+
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-1> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-2> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-3> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-4> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-5> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-6> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-7> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-8> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-9> .
+<http://acme.test/Q8> <http://acme.test/P8> 
<http://acme.test/statement/TEST-Dates-8-10> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"+00000002012-02-29T00:00:00Z" .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"+00000002012-02-31T00:00:00Z" .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"-200000200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"0200-02-28T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"0200-10-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"2012-02-29T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"2014-02-28T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"2014-04-30T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://acme.test/assert/P8> 
"2000000200-10-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q8> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Item> .
+<http://acme.test/statement/TEST-Dates-8-1> <http://acme.test/value/P8-value> 
<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> .
+<http://acme.test/statement/TEST-Dates-8-1> <http://acme.test/value/P8> 
"-0200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-1> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-1> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-2> <http://acme.test/value/P8-value> 
<http://acme.test/value/ae4625a16599af40f05c589f6273c894> .
+<http://acme.test/statement/TEST-Dates-8-2> <http://acme.test/value/P8> 
"0200-10-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-2> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-2> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-3> <http://acme.test/value/P8-value> 
<http://acme.test/value/92f69b0946d4d3eb59aae6ec511cf94d> .
+<http://acme.test/statement/TEST-Dates-8-3> <http://acme.test/value/P8> 
"-200000200-01-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-3> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-3> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-4> <http://acme.test/value/P8-value> 
<http://acme.test/value/1ec2f6dcfcaf97d0cec7783635251b16> .
+<http://acme.test/statement/TEST-Dates-8-4> <http://acme.test/value/P8> 
"0200-02-28T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-4> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-4> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-5> <http://acme.test/value/P8-value> 
<http://acme.test/value/62a81d5d1fa07b119125696dc026e582> .
+<http://acme.test/statement/TEST-Dates-8-5> <http://acme.test/value/P8> 
"2014-02-28T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-5> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-5> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-6> <http://acme.test/value/P8-value> 
<http://acme.test/value/1871749946b1782fe7ea911178d3d77e> .
+<http://acme.test/statement/TEST-Dates-8-6> <http://acme.test/value/P8> 
"2014-04-30T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-6> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-6> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-7> <http://acme.test/value/P8-value> 
<http://acme.test/value/0c34710bafa94befce6a0af682f726e0> .
+<http://acme.test/statement/TEST-Dates-8-7> <http://acme.test/value/P8> 
"2012-02-29T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-7> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-7> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-8> <http://acme.test/value/P8-value> 
<http://acme.test/value/eb39a40d34d89bcd62f2f35610d45b4b> .
+<http://acme.test/statement/TEST-Dates-8-8> <http://acme.test/value/P8> 
"+00000002012-02-29T00:00:00Z" .
+<http://acme.test/statement/TEST-Dates-8-8> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-8> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-9> <http://acme.test/value/P8-value> 
<http://acme.test/value/ab3b140db99072e132f58a967cd2af14> .
+<http://acme.test/statement/TEST-Dates-8-9> <http://acme.test/value/P8> 
"+00000002012-02-31T00:00:00Z" .
+<http://acme.test/statement/TEST-Dates-8-9> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-9> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/statement/TEST-Dates-8-10> <http://acme.test/value/P8-value> 
<http://acme.test/value/91c561aa538cf128add3c43247bf53f8> .
+<http://acme.test/statement/TEST-Dates-8-10> <http://acme.test/value/P8> 
"2000000200-10-01T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/statement/TEST-Dates-8-10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Statement> .
+<http://acme.test/statement/TEST-Dates-8-10> 
<http://www.wikidata.org/ontology-0.0.1#Rank> 
<http://www.wikidata.org/ontology-0.0.1#NormalRank> .
+<http://acme.test/value/1ec2f6dcfcaf97d0cec7783635251b16> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/1ec2f6dcfcaf97d0cec7783635251b16> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/1ec2f6dcfcaf97d0cec7783635251b16> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/1ec2f6dcfcaf97d0cec7783635251b16> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000000200-02-30T00:00:00Z" .
+<http://acme.test/value/1ec2f6dcfcaf97d0cec7783635251b16> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/92f69b0946d4d3eb59aae6ec511cf94d> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/92f69b0946d4d3eb59aae6ec511cf94d> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/92f69b0946d4d3eb59aae6ec511cf94d> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/92f69b0946d4d3eb59aae6ec511cf94d> 
<http://www.wikidata.org/ontology-0.0.1#Time> "-00200000200-04-31T00:00:00Z" .
+<http://acme.test/value/92f69b0946d4d3eb59aae6ec511cf94d> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"-60"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/ae4625a16599af40f05c589f6273c894> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/ae4625a16599af40f05c589f6273c894> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/ae4625a16599af40f05c589f6273c894> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/ae4625a16599af40f05c589f6273c894> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000000200-10-00T00:00:00Z" .
+<http://acme.test/value/ae4625a16599af40f05c589f6273c894> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"60"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/1871749946b1782fe7ea911178d3d77e> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/1871749946b1782fe7ea911178d3d77e> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/1871749946b1782fe7ea911178d3d77e> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/1871749946b1782fe7ea911178d3d77e> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000002014-04-31T00:00:00Z" .
+<http://acme.test/value/1871749946b1782fe7ea911178d3d77e> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/0c34710bafa94befce6a0af682f726e0> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/0c34710bafa94befce6a0af682f726e0> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/0c34710bafa94befce6a0af682f726e0> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/0c34710bafa94befce6a0af682f726e0> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000002012-02-29T00:00:00Z" .
+<http://acme.test/value/0c34710bafa94befce6a0af682f726e0> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/62a81d5d1fa07b119125696dc026e582> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/62a81d5d1fa07b119125696dc026e582> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/62a81d5d1fa07b119125696dc026e582> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/62a81d5d1fa07b119125696dc026e582> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000002014-02-29T00:00:00Z" .
+<http://acme.test/value/62a81d5d1fa07b119125696dc026e582> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Time> "-00000000200-00-00T00:00:00Z" .
+<http://acme.test/value/9b0b2552ae2d72bcd64746da766afcea> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/ab3b140db99072e132f58a967cd2af14> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/ab3b140db99072e132f58a967cd2af14> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://acme.test/calendar> .
+<http://acme.test/value/ab3b140db99072e132f58a967cd2af14> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/ab3b140db99072e132f58a967cd2af14> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000002012-02-31T00:00:00Z" .
+<http://acme.test/value/ab3b140db99072e132f58a967cd2af14> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/eb39a40d34d89bcd62f2f35610d45b4b> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/eb39a40d34d89bcd62f2f35610d45b4b> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985786> .
+<http://acme.test/value/eb39a40d34d89bcd62f2f35610d45b4b> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"9"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/eb39a40d34d89bcd62f2f35610d45b4b> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+00000002012-02-29T00:00:00Z" .
+<http://acme.test/value/eb39a40d34d89bcd62f2f35610d45b4b> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/91c561aa538cf128add3c43247bf53f8> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.wikidata.org/ontology-0.0.1#Value> .
+<http://acme.test/value/91c561aa538cf128add3c43247bf53f8> 
<http://www.wikidata.org/ontology-0.0.1#CalendarModel> 
<http://www.wikidata.org/entity/Q1985727> .
+<http://acme.test/value/91c561aa538cf128add3c43247bf53f8> 
<http://www.wikidata.org/ontology-0.0.1#Precision> 
"5"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://acme.test/value/91c561aa538cf128add3c43247bf53f8> 
<http://www.wikidata.org/ontology-0.0.1#Time> "+02000000200-10-00T00:00:00Z" .
+<http://acme.test/value/91c561aa538cf128add3c43247bf53f8> 
<http://www.wikidata.org/ontology-0.0.1#Timezone> 
"0"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/Q8> <http://creativecommons.org/ns#license> 
<http://creativecommons.org/publicdomain/zero/1.0/> .
+<http://data.acme.test/Q8> <http://schema.org/about> <http://acme.test/Q8> .
+<http://data.acme.test/Q8> <http://schema.org/dateModified> 
"2014-11-04T03:11:05Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://data.acme.test/Q8> <http://schema.org/softwareVersion> "0.0.1" .
+<http://data.acme.test/Q8> <http://schema.org/version> 
"42"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/Q8> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
\ No newline at end of file
diff --git a/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php 
b/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
index 8676387..009bfb9 100644
--- a/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
+++ b/repo/tests/phpunit/includes/rdf/RdfBuilderTest.php
@@ -16,6 +16,8 @@
 use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\DataModel\Entity\Property;
 use Wikibase\Repo\WikibaseRepo;
+use Wikibase\DataModel\Entity\Item;
+use Wikibase\DataModel\Entity\ItemId;
 
 /**
  * @covers Wikibase\RdfBuilder
@@ -100,13 +102,17 @@
                        $entity = new Property( PropertyId::newFromNumber($id), 
$fingerprint, $type );
                        $repo->putEntity( $entity );
                }
+               $fingerprint = Fingerprint::newEmpty();
+               $fingerprint->setLabel( 'en', "Item42" );
+               $entity = new Item( ItemId::newFromNumber(42), $fingerprint );
+               $repo->putEntity( $entity );
                return $repo;
        }
 
        /**
         * @return RdfBuilder
         */
-       private static function newRdfBuilder($produce = 
RdfProducer::PRODUCE_ALL) {
+       private static function newRdfBuilder( $produce ) {
                return new RdfBuilder(
                        self::getSiteList(),
                        self::URI_BASE,
@@ -176,6 +182,7 @@
                                array('Q5', 'Q5_badges'),
                                array('Q6', 'Q6_qualifiers'),
                                array('Q7', 'Q7_references'),
+                               array('Q8', 'Q8_baddates'),
                );
 
                $testData = array();
@@ -207,7 +214,13 @@
         * @dataProvider getRdfTests
         */
        public function testRdfBuild( Entity $entity, array $correctData ) {
-               $builder = self::newRdfBuilder();
+               $builder = self::newRdfBuilder( 
RdfProducer::PRODUCE_ALL_STATEMENTS |
+                               RdfProducer::PRODUCE_TRUTHY_STATEMENTS |
+                               RdfProducer::PRODUCE_QUALIFIERS |
+                               RdfProducer::PRODUCE_REFERENCES |
+                               RdfProducer::PRODUCE_SITELINKS |
+                               RdfProducer::PRODUCE_VERSION_INFO |
+                               RdfProducer::PRODUCE_FULL_VALUES);
                $builder->addEntity( $entity );
                $builder->addEntityRevisionInfo( $entity->getId(), 42, 
"2014-11-04T03:11:05Z" );
                $this->assertEquals( $correctData, $this->getDataFromBuilder( 
$builder ) );
@@ -225,6 +238,7 @@
                        array( 'Q4', RdfProducer::PRODUCE_ALL_STATEMENTS | 
RdfProducer::PRODUCE_PROPERTIES, 'Q4_props' ),
                        array( 'Q4', RdfProducer::PRODUCE_ALL_STATEMENTS | 
RdfProducer::PRODUCE_FULL_VALUES, 'Q4_values' ),
                        array( 'Q1', RdfProducer::PRODUCE_VERSION_INFO, 
'Q1_info' ),
+                       array( 'Q4', RdfProducer::PRODUCE_TRUTHY_STATEMENTS | 
RdfProducer::PRODUCE_RESOLVED_ENTITIES, 'Q4_resolved' ),
                );
 
                $testData = array();
@@ -242,12 +256,13 @@
                $builder = self::newRdfBuilder( $produceOption );
                $builder->addEntity( $entity );
                $builder->addEntityRevisionInfo( $entity->getId(), 42, 
"2013-10-04T03:31:05Z" );
+               $builder->resolveMentionedEntities( self::getMockRepository() );
                $data = $this->getDataFromBuilder( $builder );
                $this->assertEquals( $correctData, $data);
        }
 
        public function testDumpHeader() {
-               $builder = self::newRdfBuilder();
+               $builder = self::newRdfBuilder( 
RdfProducer::PRODUCE_VERSION_INFO );
                $builder->addDumpHeader( 1426110695 );
                $data = $this->getDataFromBuilder( $builder );
                $this->assertEquals( $this->getSerializedData( 'dumpheader' ),  
$data);

-- 
To view, visit https://gerrit.wikimedia.org/r/196712
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I51d6377511b42eb9cf638af975e3a940550643e6
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to