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"
27 #define MODXMLB_CONFIG_CONTENT_TYPE "XMLBuilderContentType"
32 module AP_MODULE_DECLARE_DATA xmlbuilder_module;
35 /* our config structure */
38 char* baseDir; /* directory on disk where the DTD files live */
39 char* defaultLocale; /* locale dir from config or default */
40 char* defaultDtd; /* if defined, we load this DTD only */
41 char* localeParam; /* the CGI param used to choose the locale dir dynamically */
42 char* contentType; /* what content type to serve our files as (derfault is text/html) */
43 xsltStylesheetPtr postXSL; /* if defined, run this XSL after parsing */
48 xmlBuilderConfig* config;
59 xmlDocPtr xmlBuilderProcessFile( char* XMLFile, xmlBuilderConfig* config );
61 void xmlBuilderAddDtd( const char* sysId, xmlBuilderContext* context );
62 void xmlBuilderAddAtts( xmlBuilderContext* ctx, xmlNodePtr ptr, const xmlChar** atts );
65 void xmlBuilderStartElement( void* blob, const xmlChar *name, const xmlChar **atts );
66 void xmlBuilderEndElement( void* blob, const xmlChar* name );
67 void xmlBuilderHandleCharacter(void* blob, const xmlChar *ch, int len);
68 void xmlBuilderParseError( void* blob, const char* msg, ... );
69 xmlEntityPtr xmlBuilderGetEntity( void* blob, const xmlChar* name );
70 void xmlBuilderExtSubset( void* blob, const xmlChar* name, const xmlChar* extId, const xmlChar* sysId );
71 void xmlBuilderProcInstruction( void* blob, const xmlChar* name, const xmlChar* data );
72 void xmlBuilderComment( void* blob, const xmlChar* data );
75 static xmlSAXHandler xmlBuilderSaxHandlerStruct = {
76 NULL, /* internalSubset */
77 NULL, /* isStandalone */
78 NULL, /* hasInternalSubset */
79 NULL, /* hasExternalSubset */
80 NULL, /* resolveEntity */
81 xmlBuilderGetEntity, /* getEntity */
82 NULL, /* entityDecl */
83 NULL, /* notationDecl */
84 NULL, /* attributeDecl */
85 NULL, /* elementDecl */
86 NULL, /* unparsedEntityDecl */
87 NULL, /* setDocumentLocator */
88 NULL, /* startDocument */
89 NULL, /* endDocument */
90 xmlBuilderStartElement, /* startElement */
91 xmlBuilderEndElement, /* endElement */
93 xmlBuilderHandleCharacter, /* characters */
94 NULL, /* ignorableWhitespace */
95 xmlBuilderProcInstruction, /* processingInstruction */
96 xmlBuilderComment, /* comment */
97 xmlBuilderParseError, /* xmlParserWarning */
98 xmlBuilderParseError, /* xmlParserError */
99 NULL, /* xmlParserFatalError : unused */
100 NULL, /* getParameterEntity */
101 NULL, /* cdataBlock; */
102 xmlBuilderExtSubset, /* externalSubset; */
105 NULL, /* startElementNs */
106 NULL, /* endElementNs */
107 NULL /* xmlStructuredErrorFunc */
109 static const xmlSAXHandlerPtr xmlBuilderSaxHandler = &xmlBuilderSaxHandlerStruct;