/** * This method processes a "value" node. * * @access protected * @param \SimpleXMLElement $node a reference to the "value" node * @return mixed the value * @throws Throwable\Instantiation\Exception indicates that problem occurred during * the instantiation */ protected function parseValueElement(\SimpleXMLElement $node) { $children = $node->children(); if (count($children) > 0) { $value = ''; foreach ($children as $child) { switch ($child->getName()) { case 'null': $value = $this->parseNullElement($child); break; default: throw new Throwable\Instantiation\Exception('Unable to initial class.'); break; } } return $value; } else { $attributes = $node->attributes(); $value = dom_import_simplexml($node)->textContent; if (isset($attributes['type'])) { $type = $this->__valueOf($attributes['type']); if (!Spring\Data\XML\Syntax::isPrimitiveType($type)) { throw new Throwable\Instantiation\Exception('Unable to initial class.'); } $value = Core\Convert::changeType($value, $type); } if (is_string($value)) { $attributes = $node->attributes('xml', true); if (isset($attributes['space'])) { $space = $this->__valueOf($attributes['space']); if (!Spring\Data\XML\Syntax::isSpacePreserved($space)) { throw new Throwable\Instantiation\Exception('Unable to initial class.'); } } else { $value = trim($value); } } return $value; } }
/** * This method parses a "value" node. * * @access protected * @param \SimpleXMLElement $root a reference to the root node * @param \SimpleXMLElement $node a reference to the "value" node * @return mixed the value * @throws Throwable\Parse\Exception indicates that problem occurred while * parsing */ protected function parseValueElement(\SimpleXMLElement $root, \SimpleXMLElement $node) { $children = $node->children(); if (count($children) > 0) { $value = ''; foreach ($children as $child) { $name = $child->getName(); switch ($name) { case 'null': $value = $this->parseNullElement($root, $child); break; default: throw new Throwable\Parse\Exception('Unable to process Spring XML. Tag ":tag" has invalid child node ":child".', array(':tag' => 'value', ':child' => $name)); break; } } return $value; } else { $attributes = $node->attributes(); $value = dom_import_simplexml($node)->textContent; if (isset($attributes['type'])) { $type = Spring\Data\XML::valueOf($attributes['type']); if (!Spring\Data\XML\Syntax::isPrimitiveType($type)) { throw new Throwable\Parse\Exception('Unable to process Spring XML. Expected a valid primitive type, but got ":type".', array(':type' => $type)); } $value = Core\Convert::changeType($value, $type); } if (is_string($value)) { $attributes = $node->attributes('xml', true); if (isset($attributes['space'])) { $space = Spring\Data\XML::valueOf($attributes['space']); if (!Spring\Data\XML\Syntax::isSpacePreserved($space)) { throw new Throwable\Parse\Exception('Unable to process Spring XML. Expected a valid "space" token, but got ":token".', array(':token' => $space)); } } else { $value = trim($value); } } return $value; } }