/**
  * Get XML tree
  *
  * @return  xml.Tree
  */
 public function getTree()
 {
     foreach ($this->tables as $t) {
         $constKeyList = array();
         $tn = $this->doc->root()->nodeAt(0)->addChild(new Node('table', NULL, array('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 Node('constraint', NULL, array('name' => trim($constraint->getName()))));
                 $fgn = $cn->addChild(new Node('reference', NULL, array('table' => $constraint->getSource(), 'role' => DBXMLNamingContext::referencingForeignKeyConstraintName($t, $constraint))));
                 foreach ($constraint->getKeys() as $attribute => $sourceattribute) {
                     $fgn->addChild(new Node('key', NULL, array('attribute' => $attribute, 'sourceattribute' => $sourceattribute)));
                 }
             } while ($constraint = $t->getNextForeignKeyConstraint());
         }
     }
     return $this->doc;
 }