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