/**
  * Get XML tree
  *
  * @return  xml.Tree
  */
 public function getTree()
 {
     foreach ($this->tables as $t) {
         $constKeyList = [];
         $tn = $this->doc->root()->nodeAt(0)->addChild(new \xml\Node('table', null, ['name' => $t->name]));
         if ($constraint = $t->getFirstForeignKeyConstraint()) {
             do {
                 if (isset($constKeyList[$this->constraintKey($constraint)])) {
                     $this->cat && $this->cat->warn($t->name, 'has a double constraint' . "\n" . \xp::stringOf($constraint));
                     continue;
                 }
                 $constKeyList[$this->constraintKey($constraint)] = true;
                 $cn = $tn->addChild(new \xml\Node('constraint', null, ['name' => trim($constraint->getName())]));
                 $fgn = $cn->addChild(new \xml\Node('reference', null, ['table' => $constraint->getSource(), 'role' => DBXMLNamingContext::referencingForeignKeyConstraintName($t, $constraint)]));
                 foreach ($constraint->getKeys() as $attribute => $sourceattribute) {
                     $fgn->addChild(new \xml\Node('key', null, ['attribute' => $attribute, 'sourceattribute' => $sourceattribute]));
                 }
             } while ($constraint = $t->getNextForeignKeyConstraint());
         }
     }
     return $this->doc;
 }