diff options
author | Technosophos <[email protected]> | 2013-04-03 18:43:53 -0500 |
---|---|---|
committer | Technosophos <[email protected]> | 2013-04-03 18:43:53 -0500 |
commit | fab7968face089f31fff8cc1a660ddcf43a777f6 (patch) | |
tree | fbd462eb8897cfafcb4dd28187850b3d274afe15 /src/HTML5 | |
parent | 4c084245f12b99c1607a25a9e9df3c2b1039cd37 (diff) |
The beginnings of a serializer.
Diffstat (limited to 'src/HTML5')
-rw-r--r-- | src/HTML5/Serializer.php | 47 | ||||
-rw-r--r-- | src/HTML5/Traverser.php | 36 |
2 files changed, 83 insertions, 0 deletions
diff --git a/src/HTML5/Serializer.php b/src/HTML5/Serializer.php new file mode 100644 index 0000000..a8bc784 --- /dev/null +++ b/src/HTML5/Serializer.php @@ -0,0 +1,47 @@ +<?php +/** + * A simple serializer that walks the DOM tree and outputs HTML5. + */ +namespace HTML5; + +/** + * Transform a DOM into an HTML5 document. + * + * This provides a serializer that roughly follows the save and load API + * in the native PHP DOM implementation. + * + * For reference, see DOMDocument::save, DOMDocument::saveXML, + * DOMDocument::saveHTML and DOMDocument::saveHTMLFile. + */ +class Serializer { + protected $dom; + + /** + * Create a serializer. + * + * This takes a DOM-like data structure. It SHOULD treat the + * DOMNode as an interface, but this does not do type checking. + * + * @param DOMNode $dom + * A DOMNode-like object. Typically, a DOMDocument should be passed. + */ + public function __construct($dom) { + $this->dom = $dom; + } + + /** + * Save to a file. + * + * @param string $filename + * The full name to the file. This will overwrite the contents of + * any file that it finds. + */ + public function save($filename) { + } + + /** + * Return the DOM as an HTML5 string. + */ + public function saveHTML() { + } +} diff --git a/src/HTML5/Traverser.php b/src/HTML5/Traverser.php new file mode 100644 index 0000000..f0771f0 --- /dev/null +++ b/src/HTML5/Traverser.php @@ -0,0 +1,36 @@ +<?php +namespace HTML5; + +/** + * Traverser for walking a DOM tree. + * + * This is a concrete traverser designed to convert a DOM tree into an + * HTML5 document. It is not intended to be a generic DOMTreeWalker + * implementation. + */ +class Traverser { + + protected $dom; + protected $out; + + /** + * Create a traverser. + * + * @param DOMNode $dom + * The document or node to traverse. + * @param resource $out + * A stream that allows writing. The traverser will output into this + * stream. + */ + public function __construct($dom, $out) { + $this->dom = $dom; + $this->out = $out; + } + + /** + * Tell the traverser to walk the DOM. + */ + public function walk() { + } + +} |