/[suikacvs]/markup/html/whatpm/Whatpm/HTML.html
Suika

Contents of /markup/html/whatpm/Whatpm/HTML.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download) (as text)
Tue May 1 10:47:37 2007 UTC (17 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +16 -15 lines
File MIME type: text/html
s/What::/Whatpm::/ to avoid name confliction

1 wakaba 1.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 wakaba 1.2 <title>Whatpm::HTML - An HTML Parser</title>
5 wakaba 1.1 <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="#to_do">TO DO</a></li>
21     <li><a href="#see_also">SEE ALSO</a></li>
22     <li><a href="#author">AUTHOR</a></li>
23     <li><a href="#license">LICENSE</a></li>
24     </ul>
25     <!-- INDEX END -->
26    
27     <hr />
28     <p>
29     </p>
30     <h1><a name="name">NAME</a></h1>
31 wakaba 1.2 <p>Whatpm::HTML - An HTML Parser</p>
32 wakaba 1.1 <p>
33     </p>
34     <hr />
35     <h1><a name="synopsis">SYNOPSIS</a></h1>
36     <pre>
37 wakaba 1.2 use Whatpm::HTML;
38 wakaba 1.1
39     my $s = q&lt;&lt;!DOCTYPE html&gt;&lt;html&gt;...&lt;/html&gt;&gt;;
40     # $doc = an empty DOM |Document| object
41     my $on_error = sub {
42     my $error_code = shift;
43     warn $error_code, &quot;\n&quot;;
44     };
45    
46 wakaba 1.2 Whatpm::HTML-&gt;parse_string ($s =&gt; $doc, $onerror);
47 wakaba 1.1
48     ## Then, |$doc| is the DOM representation of |$s|.</pre>
49     <p>
50     </p>
51     <hr />
52     <h1><a name="description">DESCRIPTION</a></h1>
53 wakaba 1.2 <p>The <code>Whatpm::HTML</code> module contains HTML parser and serializer.</p>
54 wakaba 1.1 <p>The HTML parser can be used to construct the DOM tree representation
55     from an HTML document. The parsing and tree construction are done
56     as described in the Web Application 1.0 specification.</p>
57     <p>The HTML serializer can be used to obtain the HTML document representation
58     of a DOM tree (or a tree fragment thereof). The serialization
59     is performed as described in the Web Applications 1.0 specification
60     for <code>innerHTML</code> DOM attribute.</p>
61 wakaba 1.2 <p>This module is part of Whatpm - Perl Modules for
62 wakaba 1.1 Web Hypertext Application Technologies.</p>
63     <p>
64     </p>
65     <hr />
66     <h1><a name="methods">METHODS</a></h1>
67     <dl>
68 wakaba 1.2 <dt><strong><a name="item_parse_string">[<em>$doc</em> =] Whatpm::HTML-&gt;parse_string (<em>$s</em>, <em>$doc</em>[, <em>$onerror</em>]);</a></strong><br />
69 wakaba 1.1 </dt>
70     <dd>
71     Parse a string <em>$s</em> as an HTML document.
72     </dd>
73     <dd>
74     <p>The first argument, <em>$s</em>, MUST be a string. It is parsed
75     as a sequence of characters representing an HTML document.</p>
76     </dd>
77     <dd>
78     <p>The second argument, <em>$doc</em>, MUST be an empty read-write
79     DOM <code>Document</code> object. The HTML DOM tree is constructed
80     onto this <code>Document</code> object.</p>
81     </dd>
82     <dd>
83     <p>The third argument, <em>$onerror</em>, MUST be a reference to
84     the error handler code. Whenever a parse error is detected,
85     this code is invoked with an argument that contains a
86     useless string that might describe what is wrong.
87     The code MAY throw an exception, so that whole the parsing
88     process aborts. Otherwise, the parser will continue to
89     process the input. The code MUST NOT modify <em>$s</em> or <em>$doc</em>.
90     If it does, then the result is undefined.
91     This argument is optional; if missing, any
92     parse error makes that string being <code>warn</code>ed.</p>
93     </dd>
94     <dd>
95     <p>The method returns the DOM <code>Document</code> object (i.e. the second argument).</p>
96     </dd>
97     <dd>
98 wakaba 1.2 <p>Note that the <code>Whatpm::NanoDOM</code> module provides a non-conforming
99 wakaba 1.1 implementation of DOM that only implements the subset that
100 wakaba 1.2 is necessary for the purpose of <code>Whatpm::HTML</code>'s parsing and
101 wakaba 1.1 serializing.
102     With this module, creating a new HTML <code>Document</code> object
103     from a string containing HTML document can be coded as:</p>
104     </dd>
105     <dd>
106     <pre>
107 wakaba 1.2 use Whatpm::HTML;
108     use Whatpm::NanoDOM;
109     my $doc = Whatpm::HTML-&gt;parse_string
110     ($s =&gt; Whatpm::NanoDOM::Document-&gt;new, $onerror);</pre>
111 wakaba 1.1 </dd>
112     <p></p>
113 wakaba 1.2 <dt><strong><a name="item_get_inner_html"><em>$s</em> = Whatpm::HTML-&gt;get_inner_html (<em>$node</em>[, <em>$onerror</em>]);</a></strong><br />
114 wakaba 1.1 </dt>
115     <dd>
116     Return the HTML serialization of a DOM node <em>$node</em>.
117     </dd>
118     <dd>
119     <p>The first argument, <em>$node</em>, MUST be a DOM <code>Document</code>,
120     <code>Node</code>, or <code>DocumentFragment</code> object.</p>
121     </dd>
122     <dd>
123     <p>The second argument, <em>$onerror</em>, MUST be a reference to the
124     error handling code. This code will be invoked if a descendant
125     of <code>$node</code> is not of <code>Element</code>, <code>Text</code>, <code>CDATASection</code>,
126     <code>Comment</code>, <code>DocumentType</code>, or <code>EntityReference</code> so
127     that <code>INVALID_STATE_ERR</code> MUST be thrown.
128     The code will be invoked with an argument, which is the node
129     whose type is invalid.
130     This argument is optional; if missing, any such
131     node is simply ignored.</p>
132     </dd>
133     <dd>
134 wakaba 1.2 <p>The method returns a reference to the <code>inner_html</code> attribute
135 wakaba 1.1 value, i.e. the HTML serialization of the <code>$node</code>.</p>
136     </dd>
137     <p></p></dl>
138     <p>
139     </p>
140     <hr />
141     <h1><a name="to_do">TO DO</a></h1>
142     <p>Tokenizer should emit a sequence of character tokens as one token
143     to improve performance.</p>
144     <p>A method that accepts a byte stream as an input.</p>
145     <p>Charset detection algorithm.</p>
146     <p>Setting inner_html.</p>
147     <p>And there are many ``TODO''s and ``ISSUE''s in the source code.</p>
148     <p>
149     </p>
150     <hr />
151     <h1><a name="see_also">SEE ALSO</a></h1>
152     <p>Web Applications 1.0 Working Draft (aka HTML5)
153     &lt;http://whatwg.org/html5&gt;. (Revision 792, 1 May 2007)</p>
154 wakaba 1.2 <p><a href="../Whatpm/NanoDOM.html">the Whatpm::NanoDOM manpage</a></p>
155 wakaba 1.1 <p>
156     </p>
157     <hr />
158     <h1><a name="author">AUTHOR</a></h1>
159     <p>Wakaba &lt;<a href="mailto:w@suika.fam.cx">w@suika.fam.cx</a>&gt;.</p>
160     <p>
161     </p>
162     <hr />
163     <h1><a name="license">LICENSE</a></h1>
164     <p>Copyright 2007 Wakaba &lt;<a href="mailto:w@suika.fam.cx">w@suika.fam.cx</a>&gt;</p>
165     <p>This library is free software; you can redistribute it
166     and/or modify it under the same terms as Perl itself.</p>
167    
168     </body>
169    
170     </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24