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>
9 #define MODULE_NAME "xmlbuilder_module" /* our module name */
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 /* ------------------------------------------------------------------------------ */
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"
31 module AP_MODULE_DECLARE_DATA xmlbuilder_module;
34 /* our config structure */
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 */
46 xmlBuilderConfig* config;
57 xmlDocPtr xmlBuilderProcessFile( char* XMLFile, xmlBuilderConfig* config );
59 void xmlBuilderAddDtd( const char* sysId, xmlBuilderContext* context );
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 void xmlBuilderProcInstruction( void* blob, const xmlChar* name, const xmlChar* data );
71 static xmlSAXHandler xmlBuilderSaxHandlerStruct = {
72 NULL, /* internalSubset */
73 NULL, /* isStandalone */
74 NULL, /* hasInternalSubset */
75 NULL, /* hasExternalSubset */
76 NULL, /* resolveEntity */
77 xmlBuilderGetEntity, /* getEntity */
78 NULL, /* entityDecl */
79 NULL, /* notationDecl */
80 NULL, /* attributeDecl */
81 NULL, /* elementDecl */
82 NULL, /* unparsedEntityDecl */
83 NULL, /* setDocumentLocator */
84 NULL, /* startDocument */
85 NULL, /* endDocument */
86 xmlBuilderStartElement, /* startElement */
87 xmlBuilderEndElement, /* endElement */
89 xmlBuilderHandleCharacter, /* characters */
90 NULL, /* ignorableWhitespace */
91 xmlBuilderProcInstruction, /* processingInstruction */
93 xmlBuilderParseError, /* xmlParserWarning */
94 xmlBuilderParseError, /* xmlParserError */
95 NULL, /* xmlParserFatalError : unused */
96 NULL, /* getParameterEntity */
97 NULL, /* cdataBlock; */
98 xmlBuilderExtSubset, /* externalSubset; */
101 NULL, /* startElementNs */
102 NULL, /* endElementNs */
103 NULL /* xmlStructuredErrorFunc */
105 static const xmlSAXHandlerPtr xmlBuilderSaxHandler = &xmlBuilderSaxHandlerStruct;