00001 /* dtdParse - parse an XML DTD file. Actually this only 00002 * parses a relatively simple subset of DTD's. It's still 00003 * useful for autoXml and xmlToSql. */ 00004 00005 #ifndef DTDPARSE_H 00006 #define DTDPARSE_H 00007 00008 struct dtdElement 00009 /* An element in an XML file. */ 00010 { 00011 struct dtdElement *next; /* Next in list. */ 00012 char *name; /* Element Name. */ 00013 char *mixedCaseName; /* Name converted from EL_NAME or el-name to elName. */ 00014 struct dtdElChild *children; /* Child elements. */ 00015 struct dtdAttribute *attributes; /* Attributes. */ 00016 int lineIx; /* Line where element occurs in dtd file. */ 00017 char *textType; /* Text between tags if any. */ 00018 }; 00019 00020 struct dtdElChild 00021 /* A reference to a child element. */ 00022 { 00023 struct dtdElChild *next; /* Next in list. */ 00024 char *name; /* Name of element. */ 00025 char copyCode; /* '1', '+', '?', or '*' */ 00026 boolean isOr; /* Is this part of a ( n | m ) "or" list? */ 00027 struct dtdElement *el; /* Element definition. */ 00028 }; 00029 00030 struct dtdAttribute 00031 /* An attribute of some sort. */ 00032 { 00033 struct dtdAttribute *next; /* Next in list. */ 00034 char *name; /* Name of attribute. */ 00035 char *mixedCaseName; /* Name converted from EL_NAME or el-name to elName. */ 00036 char *type; /* Element type - CDATA, INT, FLOAT, etc. */ 00037 boolean required; /* True if required. */ 00038 char *usual; /* Default value (or NULL if none) */ 00039 }; 00040 00041 void dtdParse(char *fileName, char *prefix, char *textField, 00042 struct dtdElement **retList, struct hash **retHash); 00043 /* Parse out a dtd file into elements that are returned in retList, 00044 * and for your convenience also in retHash (which is keyed by the 00045 * name of the element. Note that XML element names can include the '-' 00046 * character. For this and other reasons in addition to the element 00047 * name as it appears in the XML tag, the element has a mixedCaseName 00048 * that strips '-' and '_' chars, and tries to convert the name to 00049 * a mixed-case convention style name. The prefix if any will be 00050 * prepended to mixed-case names. The textField is what to name 00051 * the field that contains the letters between tags. By default 00052 * (if NULL) it is "text." */ 00053 00054 void dtdElementDump(struct dtdElement *el, FILE *f); 00055 /* Dump info on element. */ 00056 00057 #endif /* DTDPARSE_H */
1.5.2