/* ***************************************************************************** * * $RCSfile: parstree.h,v $ * $Date: 1999/05/18 18:35:55 $ * $Source: /home/richard/Xml/RCS/parstree.h,v $ * $Revision: 1.15 $ * $Author: richard $ * ***************************************************************************** * * Copyright 1998, Brown University and Richard Goerwitz * ***************************************************************************** */ #ifndef PARSTREE_H_INCLUDED #define PARSTREE_H_INCLUDED /* needed in fileutil.h */ typedef struct xml_node xml_node; /* needed in nfadfa.h */ typedef struct cmnode cmnode; #include "general.h" #include "fileutil.h" #include "nfadfa.h" typedef struct name_val name_val; enum cmnode_type { leaf, qmark, star, plus, slash, comma }; /* used in "children" content models */ struct cmnode { struct cmnode *left; struct cmnode *right; my_wchar_t *text; enum cmnode_type type; }; enum node_type { comment, pi, whitespace, chardata, element, CData }; /* used to hold parse tree for document content */ struct xml_node { enum node_type type; /* may contain element name, PI target, etc. */ my_wchar_t *name; /* namespace-related fields */ my_wchar_t *prefix; my_wchar_t *localpart; my_wchar_t *default_namespace; size_t namecount; name_val **namespaces; /* may contain comment text, PI data, etc. */ my_wchar_t *data; /* array of pointers to name_val structs */ size_t attcount; name_val **atts; /* array of pointers to xml_node structs (child nodes) */ size_t nodecount; xml_node **nodes; /* parent xml_node structure */ xml_node *parent; }; struct name_val { my_wchar_t *name; my_wchar_t *val; my_wchar_t *prefix; my_wchar_t *localpart; yesno was_defaulted; int lineno; xml_node *parent; }; /* routines for creating content model trees */ extern cmnode *create_cmnode (cmnode *, cmnode *, enum cmnode_type); extern cmnode *copy_cmnode (struct cmnode *); extern cmnode *create_cmleaf (my_wchar_t *); extern void free_cmnode (cmnode *); /* make sure that the leaves are all declared elements */ extern int check_leaves_in_cmnode (xml_file *, my_wchar_t *, cmnode *); /* puts links to parent into attribute name_val structs */ extern size_t add_parent_links_to_attributes (xml_file *, xml_node *); /* check all attributes in xml_node against their decls */ extern size_t check_attributes (xml_file *, xml_node *); /* adds child nodes to a parent xml_node structure */ extern size_t add_child_and_parent_backlinks (xml_node *, size_t, xml_node **); extern void free_name_val (name_val *); extern name_val *create_name_val (my_wchar_t *, my_wchar_t *, my_wchar_t *, my_wchar_t *, int, yesno, xml_node *); extern void free_xml_node (xml_node *); extern xml_node *create_xml_node (enum node_type, my_wchar_t *, my_wchar_t *, my_wchar_t *, my_wchar_t *, my_wchar_t *, size_t, name_val **, size_t, name_val **, size_t, xml_node **, xml_node *); /* make sure node can go here (acc. to parent tag's content model */ extern int check_node (xml_file *, xml_node *, xml_node *); /* used by check_node_against_dfa */ #define INITIALIZE_DFA_WALK 1 #define RESTART_DFA_WALK 2 #define FINISH_DFA_WALK 4 #define CLOBBER_STACK 8 /* make sure node can go here (acc. to parent tag's compiled content model */ extern int check_node_against_dfa (xml_file *, dfa_state **, my_wchar_t *, int); #endif /* PARSTREE_H_INCLUDED */