/** * Create Primitive. * * @param Node $parent Parent node. * @param \DOMElement|string $element DOM element or node name. * @param string|null $type Primitive type if $element is a string. * * @throws \InvalidArgumentException If $element has invalid namespace. * * @since 1.0 */ public function __construct(Node $parent, $element, $type = null) { if ($element instanceof \DOMElement) { $this->nodeName = $element->localName; parent::__construct($parent, $element); } else { $this->nodeName = (string) $element; parent::__construct($parent); if ($type) { // Prefix "m" registered — no exception $this->setAttribute('m:type', $type); } } }
/** * Create node. * * @param Content $parent Parent node. * @param \DOMElement|null $element DOM element. * * @since 0.3 * * @throws \InvalidArgumentException If $element has invalid namespace. */ public function __construct(Content $parent, $element = null) { parent::__construct($parent, $element); if (null === $element) { // No prefix — no exception $parent->setAttribute('type', 'application/xml'); } /** @var \DOMNodeList $nodes */ // No REQUIRED — no exception $nodes = $this->query('d:*'); foreach ($nodes as $node) { $primitive = new Primitive($this, $node); $this->properties[$primitive->getName()] = $primitive; } }