4 * The interface definition for Rules to generate output.
6 namespace Masterminds\HTML5\Serializer;
9 * To create a new rule set for writing output the RulesInterface needs to be
11 * The resulting class can be specified in the options with the
14 * For an example implementation see \Masterminds\HTML5\Serializer\OutputRules.
16 interface RulesInterface
20 * The class constructor.
22 * Note, before the rules can be used a traverser must be registered.
24 * @param mixed $output
25 * The output stream to write output to.
26 * @param array $options
27 * An array of options.
29 public function __construct($output, $options = array());
32 * Register the traverser used in but the rules.
34 * Note, only one traverser can be used by the rules.
36 * @param \Masterminds\HTML5\Serializer\Traverser $traverser
37 * The traverser used in the rules.
38 * @return \Masterminds\HTML5\Serializer\RulesInterface $this for the current object.
40 public function setTraverser(\Masterminds\HTML5\Serializer\Traverser $traverser);
43 * Write a document element (\DOMDocument).
45 * Instead of returning the result write it to the output stream ($output)
46 * that was passed into the constructor.
48 * @param \DOMDocument $dom
50 public function document($dom);
55 * Instead of returning the result write it to the output stream ($output)
56 * that was passed into the constructor.
60 public function element($ele);
65 * Instead of returning the result write it to the output stream ($output)
66 * that was passed into the constructor.
70 public function text($ele);
75 * Instead of returning the result write it to the output stream ($output)
76 * that was passed into the constructor.
80 public function cdata($ele);
83 * Write a comment node.
85 * Instead of returning the result write it to the output stream ($output)
86 * that was passed into the constructor.
90 public function comment($ele);
93 * Write a processor instruction.
95 * To learn about processor instructions see \Masterminds\HTML5\InstructionProcessor
97 * Instead of returning the result write it to the output stream ($output)
98 * that was passed into the constructor.
102 public function processorInstruction($ele);