| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 |
<head> |
| 4 |
<title>Whatpm::HTML::Serializer - HTML DOM Serializer</title> |
| 5 |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/pod.css" type="text/css" /> |
| 6 |
<link rev="made" href="mailto:admin@suika.fam.cx" /> |
| 7 |
</head> |
| 8 |
|
| 9 |
<body> |
| 10 |
|
| 11 |
<p><a name="__index__"></a></p> |
| 12 |
<!-- INDEX BEGIN --> |
| 13 |
|
| 14 |
<ul> |
| 15 |
|
| 16 |
<li><a href="#name">NAME</a></li> |
| 17 |
<li><a href="#synopsis">SYNOPSIS</a></li> |
| 18 |
<li><a href="#description">DESCRIPTION</a></li> |
| 19 |
<li><a href="#methods">METHODS</a></li> |
| 20 |
<li><a href="#see_also">SEE ALSO</a></li> |
| 21 |
<li><a href="#author">AUTHOR</a></li> |
| 22 |
<li><a href="#license">LICENSE</a></li> |
| 23 |
</ul> |
| 24 |
<!-- INDEX END --> |
| 25 |
|
| 26 |
<hr /> |
| 27 |
<p> |
| 28 |
</p> |
| 29 |
<h1><a name="name">NAME</a></h1> |
| 30 |
<p>Whatpm::HTML::Serializer - HTML DOM Serializer</p> |
| 31 |
<p> |
| 32 |
</p> |
| 33 |
<hr /> |
| 34 |
<h1><a name="synopsis">SYNOPSIS</a></h1> |
| 35 |
<pre> |
| 36 |
require Whatpm::HTML::Serializer; |
| 37 |
|
| 38 |
## Serialize an HTML document |
| 39 |
my $html = Whatpm::HTML::Serializer->get_inner_html ($doc); |
| 40 |
## NOTE: $html = $doc->inner_html is preferred. |
| 41 |
|
| 42 |
## Serialize an HTML element |
| 43 |
my $html = Whatpm::HTML::Serializer->get_inner_html ($el); |
| 44 |
## NOTE: $html = $el->inner_html is preferred. |
| 45 |
|
| 46 |
## Serialize an HTML document fragment |
| 47 |
my $html = Whatpm::HTML::Serializer->get_inner_html ($df);</pre> |
| 48 |
<p> |
| 49 |
</p> |
| 50 |
<hr /> |
| 51 |
<h1><a name="description">DESCRIPTION</a></h1> |
| 52 |
<p>The <code>Whatpm::HTML::Serializer</code> module provides a function that |
| 53 |
implements the fragment serialization algorithm of HTML5. It can |
| 54 |
be used to serialize a HTML <code>Document</code> or <code>Element</code> node into |
| 55 |
an HTML document or fragment.</p> |
| 56 |
<p>Note that the algorithm cannot be used to serialize an arbitrary |
| 57 |
DOM tree; an attempt to serialize a DOM that cannot be represented |
| 58 |
in a static HTML document (fragment) will result in an invalid |
| 59 |
document or in a document representing different DOM tree.</p> |
| 60 |
<p>For example, the DOM tree:</p> |
| 61 |
<pre> |
| 62 |
+- Element |p| |
| 63 |
+- Element |ul|</pre> |
| 64 |
<p>... cannot be represented in HTML serialization. The serialization |
| 65 |
algorithm will generate an invalid HTML fragment:</p> |
| 66 |
<pre> |
| 67 |
<p><ul></ul></p></pre> |
| 68 |
<p>... which represents another DOM tree:</p> |
| 69 |
<pre> |
| 70 |
+- Element |p| |
| 71 |
+- Element |ul| |
| 72 |
(with "invalid </p>" error)</pre> |
| 73 |
<p>... without raising any error or warning. This is a limitation of |
| 74 |
the HTML serialization format and the fragment serialization algorithm.</p> |
| 75 |
<p><strong>NOTE</strong>: Usually you don't have to call this module directly, |
| 76 |
since <a href="../../Message/DOM/Document.html">the Message::DOM::Document manpage</a> and <a href="../../Message/DOM/Element.html">the Message::DOM::Element manpage</a> |
| 77 |
modules implement the <code>inner_html</code> attribute for |
| 78 |
DOM <code>Document</code> and <code>Element</code> nodes.</p> |
| 79 |
<p> |
| 80 |
</p> |
| 81 |
<hr /> |
| 82 |
<h1><a name="methods">METHODS</a></h1> |
| 83 |
<dl> |
| 84 |
<dt><strong><a name="item_get_inner_html"><em>$html</em> = Whatpm::HTML::Serializer->get_inner_html (<em>$node</em>, [<em>$onerror</em>])</a></strong><br /> |
| 85 |
</dt> |
| 86 |
<dd> |
| 87 |
Serialize a node by the HTML fragment serialization algorithm. |
| 88 |
</dd> |
| 89 |
<dl> |
| 90 |
<dt><strong><a name="item__24node"><em>$node</em></a></strong><br /> |
| 91 |
</dt> |
| 92 |
<dd> |
| 93 |
The node to serialize. The node must be a DOM <code>Document</code>, |
| 94 |
<code>DocumentFragment</code>, or <code>Element</code> node. |
| 95 |
</dd> |
| 96 |
<p></p> |
| 97 |
<dt><strong><a name="item__24onerror"><em>$onerror</em></a></strong><br /> |
| 98 |
</dt> |
| 99 |
<dd> |
| 100 |
A reference to <code>CODE</code>, which will be invoked when an error occurs. |
| 101 |
If the algorithm is required to raise an <code>INVALID_STATE_ERR</code> error, |
| 102 |
i.e. if the algorithm is faced to a <code>Node</code> whose type is different |
| 103 |
from any of ones supported by the algorithm, the <code>CODE</code> is |
| 104 |
invoked with that <code>Node</code> as an argument. It is expected for the |
| 105 |
<code>CODE</code> to raise an exception. If no exception is raised, |
| 106 |
the <code>Node</code> is ignored for the purpose of the algorithm. |
| 107 |
</dd> |
| 108 |
<dd> |
| 109 |
<p>If <em>$onerror</em> is omitted, an empty <code>CODE</code> (which does nothing) |
| 110 |
is assumed.</p> |
| 111 |
</dd> |
| 112 |
<p></p> |
| 113 |
<dt><strong><a name="item__24html"><em>$html</em></a></strong><br /> |
| 114 |
</dt> |
| 115 |
<dd> |
| 116 |
A <code>SCALAR</code> reference to the result of the HTML fragment serialization |
| 117 |
algorithm. |
| 118 |
</dd> |
| 119 |
<p></p></dl> |
| 120 |
</dl> |
| 121 |
<p> |
| 122 |
</p> |
| 123 |
<hr /> |
| 124 |
<h1><a name="see_also">SEE ALSO</a></h1> |
| 125 |
<p>Whatpm <http://suika.fam.cx/www/markup/html/whatpm/readme>.</p> |
| 126 |
<p>HTML5 <http://whatwg.org/html5>.</p> |
| 127 |
<p>manakai's <a href="../../Message/DOM/Document.html">the Message::DOM::Document manpage</a> and <a href="../../Message/DOM/Element.html">the Message::DOM::Element manpage</a> |
| 128 |
modules are implementing the <code>inner_html</code> attribute.</p> |
| 129 |
<p> |
| 130 |
</p> |
| 131 |
<hr /> |
| 132 |
<h1><a name="author">AUTHOR</a></h1> |
| 133 |
<p>Wakaba <<a href="mailto:w@suika.fam.cx">w@suika.fam.cx</a>>.</p> |
| 134 |
<p> |
| 135 |
</p> |
| 136 |
<hr /> |
| 137 |
<h1><a name="license">LICENSE</a></h1> |
| 138 |
<p>Copyright 2007 Wakaba <<a href="mailto:w@suika.fam.cx">w@suika.fam.cx</a>></p> |
| 139 |
<p>This library is free software; you can redistribute it |
| 140 |
and/or modify it under the same terms as Perl itself.</p> |
| 141 |
|
| 142 |
</body> |
| 143 |
|
| 144 |
</html> |