Hoa central
Public Member Functions | List of all members
Hoa\Xml\Element\Write Class Reference
Inheritance diagram for Hoa\Xml\Element\Write:

Public Member Functions

 write ($string, $length)
 
 writeString ($string)
 
 writeCharacter ($char)
 
 writeBoolean ($boolean)
 
 writeInteger ($integer)
 
 writeFloat ($float)
 
 writeArray (Array $array)
 
 writeLine ($line)
 
 writeAll ($string)
 
 truncate ($size)
 
 writeDOM (\DOMNode $dom)
 
 writeAttributes (Array $attributes)
 
 writeAttribute ($name, $value)
 
 removeAttribute ($name)
 
- Public Member Functions inherited from Hoa\Xml\Element\Basic
 selectRoot ()
 
 selectAnyElements ()
 
 selectElements ($E=null)
 
 selectDescendantElements ($F=null)
 
 selectChildElements ($F=null)
 
 selectAdjacentSiblingElement ($F)
 
 selectSiblingElements ($F=null)
 
 querySelector ($query)
 
 querySelectorAll ($query)
 
 readAttributes ()
 
 readAttribute ($name)
 
 attributeExists ($name)
 
 readAttributesAsList ()
 
 readAttributeAsList ($name)
 
 readCustomAttributes ($set)
 
 readCustomAttributesAsList ($set)
 
 readAttributesAsString ()
 
 readXML ()
 
 readDOM ()
 
 readAsPhrasingModel ($namespace= '', $element= '__text')
 
 useNamespace ($namespace)
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Xml\Element\Basic
static getCssToXPathInstance ()
 
- Static Protected Attributes inherited from Hoa\Xml\Element\Basic
static $_cssToXPath = null
 
static $_buffer = null
 

Detailed Description

Class .

Write a XML element.

Definition at line 51 of file Write.php.

Member Function Documentation

Hoa\Xml\Element\Write::removeAttribute (   $name)

Remove an attribute.

Parameters
string$nameName.
Returns
void

Definition at line 302 of file Write.php.

303  {
304  unset($this[$name]);
305 
306  return;
307  }
Hoa\Xml\Element\Write::truncate (   $size)

Truncate to a given length.

Parameters
int$sizeSize.
Returns
bool

Implements Hoa\Stream\IStream\Out.

Definition at line 244 of file Write.php.

245  {
246  return parent::$_buffer->truncate($size);
247  }
Hoa\Xml\Element\Write::write (   $string,
  $length 
)

Write n characters.

Parameters
string$stringString.
int$lengthLength.
Returns
mixed
Exceptions

Implements Hoa\Stream\IStream\Out.

Definition at line 61 of file Write.php.

62  {
63  if (0 > $length) {
64  throw new Xml\Exception(
65  'Length must be greater than 0, given %d.',
66  0,
67  $length
68  );
69  }
70 
71  if (null === parent::$_buffer) {
72  parent::$_buffer = new Stringbuffer\ReadWrite();
73  parent::$_buffer->initializeWith($this->__toString());
74  }
75 
76  $l = parent::$_buffer->write($string, $length);
77 
78  if ($l !== $length) {
79  return false;
80  }
81 
82  $this[0] = parent::$_buffer->readAll();
83 
84  return $l;
85  }

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeAll (   $string)

Write all, i.e. as much as possible.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 233 of file Write.php.

234  {
235  return $this->write($string, strlen($string));
236  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeArray ( Array  $array)

Write an array.

Parameters
array$arrayArray.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 154 of file Write.php.

155  {
156  $document = $this->readDOM()->ownerDocument;
157 
158  foreach ($array as $name => $value) {
159  if (is_object($value)) {
160  if (!isset($this->{$name})) {
161  $this->addChild($name);
162  }
163 
164  $this->{$name}->readDOM()->parentNode->appendChild(
165  $document->importNode(clone $value->readDOM(), true)
166  );
167  } elseif (is_array($value) && !empty($value)) {
168  if (!isset($value[0])) {
169  $handle = $this->addChild($name);
170  }
171 
172  foreach ($value as $subname => $subvalue) {
173  if (is_object($subvalue)) {
174  if (!isset($this->{$name})) {
175  $this->addChild($name);
176  }
177 
178  $this->{$name}->readDOM()->parentNode->appendChild(
179  $document->importNode(clone $subvalue->readDOM(), true)
180  );
181  } else {
182  if (!isset($this->{$name})) {
183  $this->addChild($name);
184  }
185 
186  if (is_array($subvalue)) {
187  $handle->addChild($subname, null)
188  ->writeArray($subvalue);
189 
190  continue;
191  }
192 
193  if (is_bool($subvalue)) {
194  $subvalue = $subvalue ? 'true' : 'false';
195  }
196 
197  if (is_string($subname)) {
198  $handle->addChild($subname, $subvalue);
199  } else {
200  $this->addChild($name, $subvalue);
201  }
202  }
203  }
204  }
205  }
206 
207  return;
208  }

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeAttribute (   $name,
  $value 
)

Write an attribute. If the attribute does not exist, it will be created.

Parameters
string$nameName.
string$valueValue.
Returns
void

Definition at line 289 of file Write.php.

290  {
291  $this[$name] = $value;
292 
293  return;
294  }

Here is the caller graph for this function:

Hoa\Xml\Element\Write::writeAttributes ( Array  $attributes)

Write attributes. If an attribute does not exist, it will be created.

Parameters
array$attributesAttributes.
Returns
void

Definition at line 272 of file Write.php.

273  {
274  foreach ($attributes as $name => $value) {
275  $this->writeAttribute($name, $value);
276  }
277 
278  return;
279  }
writeAttribute($name, $value)
Definition: Write.php:289

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeBoolean (   $boolean)

Write a boolean.

Parameters
bool$booleanBoolean.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 117 of file Write.php.

118  {
119  return $this->write((string) (bool) $boolean, 1);
120  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeCharacter (   $char)

Write a character.

Parameters
string$charCharacter.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 106 of file Write.php.

107  {
108  return $this->write((string) $char[0], 1);
109  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeDOM ( \DOMNode  $dom)

Write a DOM tree.

Parameters
\DOMNode$domDOM tree.
Returns
mixed
Todo:

Definition at line 256 of file Write.php.

257  {
258  $sx = simplexml_import_dom($dom, __CLASS__);
259 
260  throw new Xml\Exception('Hmm, TODO?', 42);
261 
262  return true;
263  }
Hoa\Xml\Element\Write::writeFloat (   $float)

Write a float.

Parameters
float$floatFloat.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 141 of file Write.php.

142  {
143  $float = (string) (float) $float;
144 
145  return $this->write($float, strlen($float));
146  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeInteger (   $integer)

Write an integer.

Parameters
int$integerInteger.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 128 of file Write.php.

129  {
130  $integer = (string) (int) $integer;
131 
132  return $this->write($integer, strlen($integer));
133  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeLine (   $line)

Write a line.

Parameters
string$lineLine.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 216 of file Write.php.

217  {
218  if (false === $n = strpos($line, "\n")) {
219  return $this->write($line . "\n", strlen($line) + 1);
220  }
221 
222  ++$n;
223 
224  return $this->write(substr($line, 0, $n), $n);
225  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:

Hoa\Xml\Element\Write::writeString (   $string)

Write a string.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 93 of file Write.php.

94  {
95  $string = (string) $string;
96 
97  return $this->write($string, strlen($string));
98  }
write($string, $length)
Definition: Write.php:59

Here is the call graph for this function:


The documentation for this class was generated from the following file: