| 1 |
Overriding HTML::StripScripts to allow DDTs (Document Type Declarations) |
| 2 |
------------------------------------------------------------------------ |
| 3 |
|
| 4 |
A Document Type Declaration is the first line of an HTML (or X-HTML) document |
| 5 |
which describes the particular version of HTML that will be used in the |
| 6 |
document. (See http://www.w3.org/TR/html4/struct/global.html#h-7.2) |
| 7 |
|
| 8 |
For instance, strict HTML 4.01 has this declaration: |
| 9 |
|
| 10 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 11 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 12 |
|
| 13 |
By default, DTDs are rejected by HTML::StripScripts. If you would like to |
| 14 |
accept them, you will need to subclass HTML::StripScripts |
| 15 |
(or HTML::StripScripts::Parser) to allow them. |
| 16 |
|
| 17 |
IMPORTANT: More than just allowing them, you should also check the values that |
| 18 |
are passed in. |
| 19 |
|
| 20 |
-------------------------------------------------------------------------------- |
| 21 |
|
| 22 |
To run the example: |
| 23 |
|
| 24 |
- change to the examples/declaration directory: |
| 25 |
|
| 26 |
cd examples/declaration |
| 27 |
|
| 28 |
- then type: |
| 29 |
|
| 30 |
perl declaration.pl |
| 31 |
|
| 32 |
The example parses the same HTML, first with HTML::StripScripts::Parser, then |
| 33 |
with MyStripScripts (a subclass of HTML::StripScripts::Parser) and prints out |
| 34 |
the two versions. |
| 35 |
|
| 36 |
No checking of the values is done. |
| 37 |
|
| 38 |
The example script requires HTML::StripScripts::Parser to work. |