protected function parseAnnotations($response, &$annotations)
 {
     global $smwgSPARQLResultEncoding;
     // PHP strings are always interpreted in ISO-8859-1 but may be actually encoded in
     // another charset.
     if (isset($smwgSPARQLResultEncoding) && $smwgSPARQLResultEncoding == 'UTF-8') {
         $response = utf8_decode($response);
     }
     $dom = simplexml_load_string($response);
     $results = $dom->xpath('//result');
     foreach ($results as $r) {
         $children = $r->children();
         // binding nodes
         $b = $children->binding[0];
         // predicate
         $sv = $b->children()->uri[0];
         $title = TSHelper::getTitleFromURI((string) $sv);
         if (is_null($title)) {
             continue;
         }
         $predicate = SMWPropertyValue::makeUserProperty($title->getText());
         $categories = array();
         $b = $children->binding[1];
         // categories
         $values = array();
         foreach ($b->children()->uri as $sv) {
             $object = TSHelper::getTitleFromURI((string) $sv);
             if (TSHelper::isLocalURI((string) $sv)) {
                 $value = SMWDataValueFactory::newPropertyObjectValue($predicate, $object);
             } else {
                 $value = SMWDataValueFactory::newTypeIDValue('_uri', (string) $sv);
             }
             // add metadata
             $metadata = array();
             foreach ($sv->attributes() as $mdProperty => $mdValue) {
                 if (strpos($mdProperty, "_meta_") === 0) {
                     $value->setMetadata(strtoupper($mdProperty), explode("|||", $mdValue));
                 }
             }
             $values[] = $value;
         }
         foreach ($b->children()->literal as $sv) {
             $literal = array((string) $sv, $sv->attributes()->datatype);
             $value = $this->getLiteral($literal, $predicate);
             // add metadata
             $metadata = array();
             foreach ($sv->attributes() as $mdProperty => $mdValue) {
                 if (strpos($mdProperty, "_meta_") === 0) {
                     $value->setMetadata(strtoupper($mdProperty), explode("|||", $mdValue));
                 }
             }
             $values[] = $value;
         }
         $annotations[] = array($predicate, $values);
     }
 }