]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/netstring/nethtml.mli
Initial revision
[helm.git] / helm / DEVEL / pxp / netstring / nethtml.mli
1 (* $Id$
2  * ----------------------------------------------------------------------
3  *
4  *)
5
6
7 (* The type 'document' represents parsed HTML documents. 
8  * Element (name, args, subnodes): is an element node for an element of
9  *   type 'name' (i.e. written <name ...>...</name>) with arguments 'args'
10  *   and subnodes 'subnodes' (the material within the element). The arguments
11  *   are simply name/value pairs. Entity references (something like %xy;)
12  *   occuring in the values are NOT resolved.
13  *   Arguments without values (e.g. <select name="x" multiple>: here,
14  *   "multiple" is such an argument) are represented as (name,name), i.e. the
15  *   name is returned as value.
16  *   As argument names are case-insensitive, the names are all lowercase.
17  * Data s: is a character data node. Again, entity references are contained
18  *   as such and not as what they mean.
19  *)
20
21 type document =
22     Element of (string  *  (string*string) list  *  document list)
23   | Data of string
24 ;;
25
26
27 val no_end_tag : string list ref;;
28   (* List of tags which are always empty. This variable is pre-configured,
29    * but you may want to change it.
30    * It is important to know which elements are always empty, because HTML
31    * allows it to omit the end tag for them. For example, 
32    * <a><b>x</a> is parsed as 
33    *   Element("a",[],[ Element("b",[],[]); Data "x" ])
34    * if we know that "a" is an empty element, but it is wrongly parsed as
35    *   Element("a",[],[ Element("b",[], [ Data "x"]) ])
36    * if "a" is actually empty but we do not know it.
37    * An example of such a tag is "br".
38    *)
39
40 val special_tag : string list ref;;
41   (* List of tags with a special rule for recognizing the end.
42    * This variable is pre-configured, but you may want to change it.
43    * The special rule is that the metacharacters '<', '>' and so on lose
44    * their meaning within the element, and that only the corresponding 
45    * end tag stops this kind of scanning. An example is the element
46    * "javascript". Inner elements are not recognized, and the element
47    * can only be ended by </javascript>. (Other elements are also ended
48    * if an embracing element ends, e.g. "j" in <k><j></k>!)
49    *
50    * Note that comments are not recognized within special elements;
51    * comments are returned as character material.
52    *)
53
54 val parse_string : string -> document list
55   (* Parses the HTML document from a string and returns it *)
56
57 val parse_file : in_channel -> document list
58   (* Parses the HTML document from a file and returns it *)
59
60
61 (* ======================================================================
62  * History:
63  * 
64  * $Log$
65  * Revision 1.1  2000/11/17 09:57:28  lpadovan
66  * Initial revision
67  *
68  * Revision 1.1  2000/03/03 01:07:25  gerd
69  *      Initial revision.
70  *
71  * 
72  *)