LJ Archive

Listing 3. autoXml Code Generation

The polygon.dtdx file here:

<!ELEMENT POLYGON (DESCRIPTION? POINT+)>
<!ATTLIST POLYGON id CDATA #REQUIRED>
<!ELEMENT DESCRIPTION (#PCDATA)>
<!ELEMENT POINT>
<!ATTLIST POINT x INT #REQUIRED>
<!ATTLIST POINT y INT #REQUIRED>
<!ATTLIST POINT z INT "0">

and the command line:

autoXml polygon.dtdx poly

generates poly.h as follows:

/* poly.h autoXml generated file */
#ifndef POLY_H
#define POLY_H

struct polyPolygon
   {
   struct polyPolygon *next;
   char *id;   /* Required */
   struct polyDescription *polyDescription;
      /** Optional (may be NULL). **/
   struct polyPoint *polyPoint;
      /** Non-empty list required. **/
   };

void polyPolygonSave(struct polyPolygon *obj,
     int indent, FILE *f);
/* Save polyPolygon to file. */

struct polyPolygon *polyPolygonLoad(char *fileName);
/* Load polyPolygon from file. */

struct polyDescription
    {
    struct polyDescription *next;
    char *text;
    };

void polyDescriptionSave(struct
     polyDescription *obj, int indent, FILE *f);
/* Save polyDescription to file. */

struct polyDescription
     *polyDescriptionLoad(char *fileName);
/* Load polyDescription from file. */

struct polyPoint
    {
    struct polyPoint *next;
    double x;  /* Required */
    double y;  /* Required */
    double z;  /* Defaults to 0 */
    };

void polyPointSave(struct polyPoint *obj,
    int indent, FILE *f);
/* Save polyPoint to file. */

struct polyPoint *polyPointLoad(char *fileName);
/* Load polyPoint from file. */

#endif /* POLY_H */
LJ Archive