2 #ifndef EL_DOM_SGML_SGML_H
3 #define EL_DOM_SGML_SGML_H
8 #include "dom/string.h"
10 /* The flags stored in the attribute sgml node info data */
11 /* TODO: Other potential flags (there can be only 16)
13 * - interaction info for forms (diabled, readonly, maxlength) maybe tabindex,
15 * - generic layout style attributes maybe giving color values an additional flag,
16 * - meta information (rel, rev, title, alt, summary, caption, standby, lang),
17 * - scripting hooks (onblur, ...)
18 * - information about the referenced content (hreflang, codetype, media, type)
20 * Anyway the flags should of course optimally have a purpose to speed things up
21 * by quickly making it possible to identify certain attribute groups. --jonas */
22 enum sgml_attribute_flags
{
23 /* The value uniquely identifies the owner */
24 SGML_ATTRIBUTE_IDENTIFIER
= 1,
25 /* The value contains an URI of some sort */
26 SGML_ATTRIBUTE_REFERENCE
= 2,
29 /* TODO: We also need an element flag to signal to the parser that all the
30 * content should be skipped; possible with some ugly hacks to not use the
31 * scanner since it could get confused. The purpose of this flag is to group
32 * all element content in one text node. Kind of like a ``verbatim'' thing
33 * where not parsing should be done. For HTML the <script> and <style> tags
35 enum sgml_element_flags
{
36 /* The start and end tags are optional */
37 SGML_ELEMENT_OPTIONAL
= 1,
39 /* The element is empty and end tags are forbidden */
40 SGML_ELEMENT_EMPTY
= 2,
42 /* The end tag is obtional */
43 SGML_ELEMENT_END_OPTIONAL
= 4,
46 struct sgml_node_info
{
47 struct dom_string string
;
52 /* The header node is special. It is used for storing the number of nodes and
53 * for returning the default 'unknown' node. */
54 #define SGML_NODE_HEAD(doctype, nodetype) \
55 { INIT_DOM_STRING(NULL, doctype##_##nodetype##S - 1), doctype##_##nodetype##_UNKNOWN }
57 #define SGML_NODE_INFO(doctype, nodetype, name, data) \
58 { INIT_DOM_STRING(#name, sizeof(#name) - 1), doctype##_##nodetype##_##name, data }
60 #define SGML_NODE_INF2(doctype, nodetype, name, ident, data) \
61 { INIT_DOM_STRING(ident, sizeof(ident) - 1), doctype##_##nodetype##_##name, data }
63 #define SGML_NODE_INFO_TYPE(doctype, nodetype, name) doctype##_##nodetype##_##name
65 int sgml_info_strcmp(const void *key
, const void *node
);
67 static inline struct sgml_node_info
*
68 get_sgml_node_info(struct sgml_node_info list
[], struct dom_node
*node
)
70 struct sgml_node_info
*map
= &list
[1];
71 size_t map_size
= list
->string
.length
;
72 size_t obj_size
= sizeof(struct sgml_node_info
);
73 void *match
= bsearch(node
, map
, map_size
, obj_size
, sgml_info_strcmp
);
75 return match
? match
: list
;
78 enum sgml_document_type
{
87 enum sgml_document_type doctype
;
88 struct sgml_node_info
*attributes
;
89 struct sgml_node_info
*elements
;
92 struct sgml_info
*get_sgml_info(enum sgml_document_type doctype
);