protected function node($name, $in)
 {
     if (is_object($in)) {
         return Node::fromObject($in, $name);
     } else {
         if (is_array($in)) {
             return Node::fromArray($in, $name);
         } else {
             return new Node($name, $in);
         }
     }
 }
 public function dateFormatCallbackWithoutTZ()
 {
     $date = new Date('2009-09-20 21:33:00');
     $this->assertEquals($date->toString('Y-m-d H:i:s T'), $this->runTransformation(Node::fromObject($date, 'date')->getSource(), 'xp.date::format', ['string(/date/value)', "'Y-m-d H:i:s T'"]));
 }
 public function writeInterfaces($description, $output)
 {
     static $purposes = array(HOME_INTERFACE => 'home', REMOTE_INTERFACE => 'remote');
     foreach ($description->getInterfaces() as $type => $interface) {
         $node = Node::fromObject($interface, 'interface');
         $node->setAttribute('purpose', $purposes[$type]);
         $node->addChild(new Node('jndiName', $this->jndi));
         $this->processor->setXMLBuf($node->getSource(INDENT_NONE));
         $this->processor->run();
         $output->append(strtr($interface->getClassName(), '.', '/') . \xp::CLASS_FILE_EXT, $this->processor->output());
     }
 }
 /**
  * Adds an error. The XML representation will look like this:
  * <xmp>
  *   <error
  *    checker="foo.bar.wrapper.MyLoginDataChecker"
  *    type="user_nonexistant"
  *    field="username"                    
  *   />                                                 
  * </xmp>
  *
  * @param   string checker The class checking the input
  * @param   string type The error type
  * @param   string field default '*' The form field corresponding
  * @param   var info default NULL 
  * @return  bool FALSE
  */
 public function addFormError($checker, $type, $field = '*', $info = null)
 {
     if (is_array($info)) {
         $c = \xml\Node::fromArray($info, 'error');
     } else {
         if (is_object($info)) {
             $c = \xml\Node::fromObject($info, 'error');
         } else {
             $c = new \xml\Node('error', $info);
         }
     }
     $c->setAttributes(['type' => $type, 'field' => $field, 'checker' => $checker]);
     $this->document->formerrors->addChild($c);
     return false;
 }