/** * Constructor. * @param $name element/tag name */ function __construct() { parent::__construct(); $this->name = '!--'; $this->parent = null; $this->attributes = array(); $this->value = null; $this->children = array(); }
public function __construct($resource = null, $copy = true) { try { parent::__construct($resource, $copy); } catch (Exception $e) { parent::__construct(file_get_contents(dirname(__FILE__) . '/templates/FileMetadata.xml')); } $this->registerNS("escidocfile", "http://purl.org/escidoc/metadata/profiles/0.1/file"); $this->registerNS("dc", "http://purl.org/dc/elements/1.1/"); $this->registerNS("xsi", "http://www.w3.org/2001/XMLSchema-instance"); $this->registerNS("dcterms", "http://purl.org/dc/terms/"); }
/** * Constructor. Sets up the XML parser with options, gives it this object as * its XML object, and sets some variables. * * @param string $input What should be used to set up * @param array $options Options to set up with */ function __construct($input = null, $options = array()) { parent::__construct('root'); $this->__parser = xml_parser_create_ns(); xml_set_object($this->__parser, $this); xml_parser_set_option($this->__parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($this->__parser, XML_OPTION_SKIP_WHITE, 1); $this->children = array(); if ($input != null) { $vars = null; if (is_string($input)) { $this->load($input); } elseif (is_array($input)) { $vars = $this->__objectToNode(Set::map($input)); } elseif (is_object($input)) { $vars = $this->__objectToNode($input); } if ($vars != null) { $this->children = $vars; } if (!is_array($this->children)) { $this->children = array($this->children); } } if (Configure::read('App.encoding') !== null) { $this->encoding = Configure::read('App.encoding'); } foreach ($options as $key => $val) { switch ($key) { case 'version': $this->version = $val; break; case 'encoding': $this->encoding = $val; break; } } }