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()) {
96 foreach (libxml_get_errors() as $error) {
97 $message = trim($error->message);
100 $column = $error->column;
101 $errors .=
"$message in '$file' on line $line, column $column\n";
104 throw new \fpoirotte\XRL\Faults\InvalidXmlRpcException(trim($errors));
108 throw new \fpoirotte\XRL\Faults\InvalidXmlRpcException();
113 }
while ($reader->nodeType === \XMLReader::SIGNIFICANT_WHITESPACE);
123 $this->properties = array();
124 foreach ($fields as $field) {
125 $this->properties[$field] = $reader->$field;
127 $name = $reader->localName;
128 if ($reader->namespaceURI !==
'') {
129 $name =
'{' . $reader->namespaceURI .
'}' . $name;
131 $this->properties[
'name'] = $name;
155 if (!isset($this->properties[$field])) {
156 throw new \UnexpectedValueException(
"Unknown property '$field'");
159 return $this->properties[$field];
172 if ($this->properties[
'nodeType'] == \XMLReader::ELEMENT &&
173 $this->properties[
'isEmptyElement'] ==
true) {
174 $this->properties[
'nodeType'] = \XMLReader::END_ELEMENT;
175 $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.