12 namespace fpoirotte\XRL;
32 const XML_ERR_NO_MEMORY = 2;
33 const XML_ERR_DOCUMENT_EMPTY = 4;
34 const XML_ERR_DOCUMENT_END = 5;
35 const XML_ERR_INVALID_CHAR = 9;
36 const XML_ERR_UNKNOWN_ENCODING = 31;
37 const XML_ERR_UNSUPPORTED_ENCODING = 32;
53 public function __construct(\XMLReader $reader, $validate, $subtrees)
59 if (($subtrees && !@$reader->read()) ||
60 (!$subtrees && !@$reader->next())) {
61 $error = libxml_get_last_error();
68 if ($error ===
false) {
69 throw new \InvalidArgumentException(
'End of document');
72 switch ($error->code) {
73 case self::XML_ERR_UNKNOWN_ENCODING:
74 case self::XML_ERR_UNSUPPORTED_ENCODING:
75 throw new \fpoirotte\XRL\Faults\UnsupportedEncodingException();
80 case self::XML_ERR_INTERNAL_ERROR:
81 case self::XML_ERR_NO_MEMORY:
82 throw new \fpoirotte\XRL\Faults\InternalErrorException();
85 case self::XML_ERR_INVALID_CHAR:
86 throw new \fpoirotte\XRL\Faults\InvalidCharacterException();
90 throw new \fpoirotte\XRL\Faults\NotWellFormedException();
94 if ($validate && !$reader->isValid()) {
95 throw new \fpoirotte\XRL\Faults\InvalidXmlRpcException();
99 }
while ($reader->nodeType === \XMLReader::SIGNIFICANT_WHITESPACE);
109 $this->properties = array();
110 foreach ($fields as $field) {
111 $this->properties[$field] = $reader->$field;
113 $name = $reader->localName;
114 if ($reader->namespaceURI !==
'') {
115 $name =
'{' . $reader->namespaceURI .
'}' . $name;
117 $this->properties[
'name'] = $name;
141 if (!isset($this->properties[$field])) {
142 throw new \UnexpectedValueException(
"Unknown property '$field'");
145 return $this->properties[$field];
158 if ($this->properties[
'nodeType'] == \XMLReader::ELEMENT &&
159 $this->properties[
'isEmptyElement'] ==
true) {
160 $this->properties[
'nodeType'] = \XMLReader::END_ELEMENT;
161 $this->properties[
'isEmptyElement'] =
false;
An XML node as read from an XML reader.
__construct(\XMLReader $reader, $validate, $subtrees)
emptyNodeExpansionWorked()
const XML_ERR_INTERNAL_ERROR
Error codes from http://www.xmlsoft.org/html/libxml-xmlerror.html.
$properties
Fields that make up this node.