]> mj.ucw.cz Git - libucw.git/blobdiff - sherlock/xml/dtd.h
make regex and asciidoc work on Darwin without hacking
[libucw.git] / sherlock / xml / dtd.h
index 9b4c6d98c233cd10befe1254b5effdf475871bc4..e2caf98731ca59ea6a52647848b126ae44344142 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Sherlock Library -- A simple XML parser
  *
 /*
  *     Sherlock Library -- A simple XML parser
  *
- *     (c) 2007 Pavel Charvat <pchar@ucw.cz>
+ *     (c) 2007--2008 Pavel Charvat <pchar@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
 
 struct xml_dtd {
   struct mempool *pool;                        /* Memory pool where to allocate DTD */
 
 struct xml_dtd {
   struct mempool *pool;                        /* Memory pool where to allocate DTD */
-  slist gents;                         /* Link list of general entities */
-  slist pents;                         /* Link list of parapeter entities */
+  slist ents;                          /* Link list of general entities */
+  slist pents;                         /* Link list of parameter entities */
   slist notns;                         /* Link list of notations */
   slist elems;                         /* Link list of elements */
   slist notns;                         /* Link list of notations */
   slist elems;                         /* Link list of elements */
-  void *tab_gents;                     /* Hash table of general entities */
+  void *tab_ents;                      /* Hash table of general entities */
   void *tab_pents;                     /* Hash table of parameter entities */
   void *tab_notns;                     /* Hash table of notations */
   void *tab_elems;                     /* Hash table of elements */
   void *tab_pents;                     /* Hash table of parameter entities */
   void *tab_notns;                     /* Hash table of notations */
   void *tab_elems;                     /* Hash table of elements */
@@ -31,38 +31,44 @@ struct xml_dtd {
 /* Notations */
 
 enum xml_dtd_notn_flags {
 /* Notations */
 
 enum xml_dtd_notn_flags {
-  XML_DTD_NOTN_DECLARED = 0x1,         /* The notation has been declared (interbal usage) */
+  XML_DTD_NOTN_DECLARED = 0x1,         /* The notation has been declared (internal usage) */
 };
 
 struct xml_dtd_notn {
   snode n;                             /* Node in xml_dtd.notns */
   uns flags;                           /* XML_DTD_NOTN_x */
   char *name;                          /* Notation name */
 };
 
 struct xml_dtd_notn {
   snode n;                             /* Node in xml_dtd.notns */
   uns flags;                           /* XML_DTD_NOTN_x */
   char *name;                          /* Notation name */
-  struct xml_ext_id eid;               /* External id */
+  char *system_id;                     /* External ID */
+  char *public_id;
+  void *user;                          /* User-defined */
 };
 
 };
 
+struct xml_dtd_notn *xml_dtd_find_notn(struct xml_context *ctx, char *name);
+
 /* Entities */
 
 /* Entities */
 
-enum xml_dtd_ent_flags {
-  XML_DTD_ENT_DECLARED = 0x1,          /* The entity has been declared (internal usage) */
-  XML_DTD_ENT_VISITED = 0x2,           /* Cycle detection (internal usage) */
-  XML_DTD_ENT_PARAMETER = 0x4,         /* Parameter entity, general otherwise */
-  XML_DTD_ENT_EXTERNAL = 0x8,          /* External entity, internal otherwise */
-  XML_DTD_ENT_UNPARSED = 0x10,         /* Unparsed entity, parsed otherwise */
-  XML_DTD_ENT_TRIVIAL = 0x20,          /* Replacement text is a sequence of characters and character references */
+enum xml_dtd_entity_flags {
+  XML_DTD_ENTITY_DECLARED = 0x1,       /* The entity has been declared (internal usage) */
+  XML_DTD_ENTITY_VISITED = 0x2,                /* Cycle detection (internal usage) */
+  XML_DTD_ENTITY_PARAMETER = 0x4,      /* Parameter entity, general otherwise */
+  XML_DTD_ENTITY_EXTERNAL = 0x8,       /* External entity, internal otherwise */
+  XML_DTD_ENTITY_UNPARSED = 0x10,      /* Unparsed entity, parsed otherwise */
+  XML_DTD_ENTITY_TRIVIAL = 0x20,       /* Replacement text is a sequence of characters and character references */
 };
 
 };
 
-struct xml_dtd_ent {
+struct xml_dtd_entity {
   snode n;                             /* Node in xml_dtd.[gp]ents */
   uns flags;                           /* XML_DTD_ENT_x */
   char *name;                          /* Entity name */
   char *text;                          /* Replacement text / expanded replacement text (XML_DTD_ENT_TRIVIAL) */
   uns len;                             /* Text length */
   snode n;                             /* Node in xml_dtd.[gp]ents */
   uns flags;                           /* XML_DTD_ENT_x */
   char *name;                          /* Entity name */
   char *text;                          /* Replacement text / expanded replacement text (XML_DTD_ENT_TRIVIAL) */
   uns len;                             /* Text length */
-  struct xml_ext_id eid;               /* External ID */
+  char *system_id;                     /* External ID */
+  char *public_id;
   struct xml_dtd_notn *notn;           /* Notation (XML_DTD_ENT_UNPARSED only) */
   struct xml_dtd_notn *notn;           /* Notation (XML_DTD_ENT_UNPARSED only) */
+  void *user;                          /* User-defined */
 };
 
 };
 
-struct xml_dtd_ent *xml_dtd_find_gent(struct xml_context *ctx, char *name);
+struct xml_dtd_entity *xml_dtd_find_entity(struct xml_context *ctx, char *name);
 
 /* Elements */
 
 
 /* Elements */
 
@@ -83,6 +89,8 @@ struct xml_dtd_elem {
   uns type;
   char *name;
   struct xml_dtd_elem_node *node;
   uns type;
   char *name;
   struct xml_dtd_elem_node *node;
+  slist attrs;
+  void *user;                          /* User-defined */
 };
 
 struct xml_dtd_elem_node {
 };
 
 struct xml_dtd_elem_node {
@@ -92,6 +100,7 @@ struct xml_dtd_elem_node {
   slist sons;
   uns type;
   uns occur;
   slist sons;
   uns type;
   uns occur;
+  void *user;                          /* User-defined */
 };
 
 enum xml_dtd_elem_node_type {
 };
 
 enum xml_dtd_elem_node_type {
@@ -107,16 +116,18 @@ enum xml_dtd_elem_node_occur {
   XML_DTD_ELEM_OCCUR_PLUS,
 };
 
   XML_DTD_ELEM_OCCUR_PLUS,
 };
 
+struct xml_dtd_elem *xml_dtd_find_elem(struct xml_context *ctx, char *name);
+
 /* Attributes */
 
 /* Attributes */
 
-enum xml_dtd_attribute_default {
+enum xml_dtd_attr_default {
   XML_ATTR_NONE,
   XML_ATTR_REQUIRED,
   XML_ATTR_IMPLIED,
   XML_ATTR_FIXED,
 };
 
   XML_ATTR_NONE,
   XML_ATTR_REQUIRED,
   XML_ATTR_IMPLIED,
   XML_ATTR_FIXED,
 };
 
-enum xml_dtd_attribute_type {
+enum xml_dtd_attr_type {
   XML_ATTR_CDATA,
   XML_ATTR_ID,
   XML_ATTR_IDREF,
   XML_ATTR_CDATA,
   XML_ATTR_ID,
   XML_ATTR_IDREF,
@@ -130,11 +141,12 @@ enum xml_dtd_attribute_type {
 };
 
 struct xml_dtd_attr {
 };
 
 struct xml_dtd_attr {
-  char *name;
-  struct xml_dtd_elem *elem;
-  enum xml_dtd_attribute_type type;
-  enum xml_dtd_attribute_default default_mode;
-  char *default_value;
+  snode n;
+  char *name;                          /* Attribute name */
+  struct xml_dtd_elem *elem;           /* Owner element */
+  uns type;                            /* See enum xml_dtd_attr_type */
+  uns default_mode;                    /* See enum xml_dtd_attr_default */
+  char *default_value;                 /* The default value defined in DTD (or NULL) */
 };
 
 struct xml_dtd_eval {
 };
 
 struct xml_dtd_eval {
@@ -151,4 +163,6 @@ void xml_dtd_init(struct xml_context *ctx);
 void xml_dtd_cleanup(struct xml_context *ctx);
 void xml_dtd_finish(struct xml_context *ctx);
 
 void xml_dtd_cleanup(struct xml_context *ctx);
 void xml_dtd_finish(struct xml_context *ctx);
 
+struct xml_dtd_attr *xml_dtd_find_attr(struct xml_context *ctx, struct xml_dtd_elem *elem, char *name);
+
 #endif
 #endif