]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/apachemods/mod_xmlbuilder.h
adding "voider" and "void_time" fields to billing
[Evergreen.git] / Open-ILS / src / apachemods / mod_xmlbuilder.h
1 #include "apachetools.h"
2 #include "opensrf/xml_utils.h"
3 #include "opensrf/osrf_hash.h"
4 #include "opensrf/osrf_list.h"
5 #include <libxslt/xslt.h>
6 #include <libxslt/transform.h>
7 #include <libxslt/xsltutils.h>
8
9 #define MODULE_NAME     "xmlbuilder_module"     /* our module name */
10
11 /* ------------------------------------------------------------------------------ */
12 /* Apache config items.  These are defaults which are only  used if they are not
13         overriden by the Apache config or URL where appropriate */
14 /* ------------------------------------------------------------------------------ */
15 /* The default directory where the DTD files are stored */
16 #define MODXMLB_DEFAULT_LOCALE_PARAM    "locale"
17 #define MODXMLB_DEFAULT_BASE_DIR                        "/openils/var/web/locale"
18 #define MODXMLB_DEFAULT_LOCALE                  "en-US"                 
19 #define MODXMLB_DEFAULT_DTD                             NULL /* if defined, use this DTD only */
20 /* ------------------------------------------------------------------------------ */
21
22 #define MODXMLB_CONFIG_LOCALE           "XMLBuilderDefaultLocale"
23 #define MODXMLB_CONFIG_BASE_DIR         "XMLBuilderBaseDir"
24 #define MODXMLB_CONFIG_POST_XSL                 "XMLBuilderPostXSL"
25 #define MODXMLB_CONFIG_DEFAULT_DTD      "XMLBuilderDefaultDTD"
26 #define MODXMLB_CONFIG_LOCALE_PARAM "XMLBuilderLocaleParam"
27
28
29
30 /* This module */
31 module AP_MODULE_DECLARE_DATA xmlbuilder_module;
32
33
34 /* our config structure */
35 typedef struct {
36
37         char* baseDir;                                  /* directory on disk where the DTD files live */
38         char* defaultLocale;                    /* locale dir from config or default */
39         char* defaultDtd;                               /* if defined, we load this DTD only */
40         char* localeParam;                      /* the CGI param used to choose the locale dir dynamically */
41         xsltStylesheetPtr postXSL;      /* if defined, run this XSL after parsing */
42
43 } xmlBuilderConfig;
44
45 typedef struct {
46         xmlBuilderConfig* config;
47         xmlDocPtr doc;
48         osrfHash* entHash;
49         osrfHash* dtdHash;
50         osrfList* nodeList;
51         int xmlError;
52         char* xmlFile;
53 } xmlBuilderContext;
54
55
56
57 xmlDocPtr xmlBuilderProcessFile( char* XMLFile, xmlBuilderConfig* config );
58
59 void xmlBuilderAddDtd( const char* sysId, xmlBuilderContext* context );
60
61
62 /* SAX Callbacks */
63 void xmlBuilderStartElement( void* blob, const xmlChar *name, const xmlChar **atts );
64 void xmlBuilderEndElement( void* blob, const xmlChar* name );
65 void xmlBuilderHandleCharacter(void* blob, const xmlChar *ch, int len);
66 void xmlBuilderParseError( void* blob, const char* msg, ... );
67 xmlEntityPtr xmlBuilderGetEntity( void* blob, const xmlChar* name );
68 void xmlBuilderExtSubset( void* blob, const xmlChar* name, const xmlChar* extId, const xmlChar* sysId );
69
70 static xmlSAXHandler xmlBuilderSaxHandlerStruct = {
71    NULL,                                                                /* internalSubset */
72    NULL,                                                                /* isStandalone */
73    NULL,                                                                /* hasInternalSubset */
74    NULL,                                                                /* hasExternalSubset */
75    NULL,                                                                /* resolveEntity */
76    xmlBuilderGetEntity,                 /* getEntity */
77    NULL,                                                        /* entityDecl */
78    NULL,                                                                /* notationDecl */
79    NULL,                                                                /* attributeDecl */
80    NULL,                                                                /* elementDecl */
81    NULL,                                                        /* unparsedEntityDecl */
82    NULL,                                                                /* setDocumentLocator */
83    NULL,                                                                /* startDocument */
84    NULL,                                                                /* endDocument */
85         xmlBuilderStartElement,         /* startElement */
86         xmlBuilderEndElement,           /* endElement */
87    NULL,                                                                /* reference */
88         xmlBuilderHandleCharacter,      /* characters */
89    NULL,                                                                /* ignorableWhitespace */
90    NULL,                                                                /* processingInstruction */
91    NULL,                                                                /* comment */
92    xmlBuilderParseError,                /* xmlParserWarning */
93    xmlBuilderParseError,                /* xmlParserError */
94    NULL,                                                                /* xmlParserFatalError : unused */
95    NULL,                                                                /* getParameterEntity */
96    NULL,                                                                /* cdataBlock; */
97    xmlBuilderExtSubset,                 /* externalSubset; */
98    1,
99    NULL,
100    NULL,                                                                /* startElementNs */
101    NULL,                                                                /* endElementNs */
102         NULL                                                            /* xmlStructuredErrorFunc */
103 };
104 static const xmlSAXHandlerPtr xmlBuilderSaxHandler = &xmlBuilderSaxHandlerStruct;
105
106