protected function setNodeValue($xquery, $value)
    {
      $nodeList = $this->document->getXPath()->query($xquery, $this->node);

      if($nodeList->length == 0)
        throw new Exception(__METHOD__ . '; ' . $xquery . ' node is missing');

      if(is_int($value))
        $nodeList->item(0)->nodeValue = $value;
      elseif(is_string($value))
        $nodeList->item(0)->nodeValue = utf8_encode($value);
      elseif(is_bool($value))
        $nodeList->item(0)->nodeValue = ($value ? 'true' : 'false');
    }