From 1f67e20bd78c9ed3454fafd3ecae5ca1401e5f72 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 5 Aug 2005 21:03:36 +0000 Subject: [PATCH] much work toward the dtd-on-the-fly architecture for locale changing git-svn-id: svn://svn.open-ils.org/ILS/trunk@1621 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/Makefile | 23 +++++-- Open-ILS/src/apachemods/Makefile | 6 +- Open-ILS/src/apachemods/mod_xmltools.c | 6 +- Open-ILS/src/apachemods/xmltools.c | 69 ++++++++++++++++++++ Open-ILS/src/apachemods/xmltools.h | 2 - Open-ILS/src/webxml/advanced.xml | 1 + Open-ILS/src/webxml/index.xml | 3 +- Open-ILS/src/webxml/locale/en-US/lang.dtd | 9 +++ Open-ILS/src/webxml/login.xml | 1 + Open-ILS/src/webxml/mresult.xml | 1 + Open-ILS/src/webxml/myopac/index.xml | 1 + Open-ILS/src/webxml/result_common.xml | 7 +- Open-ILS/src/webxml/rresult.xml | 1 + Open-ILS/src/webxml/sidebar.xml | 9 +-- OpenSRF/bin/opensrf_all | 2 +- OpenSRF/src/router/router_config.xml.example | 2 +- config.sh | 10 --- install.sh | 8 ++- 18 files changed, 128 insertions(+), 33 deletions(-) create mode 100644 Open-ILS/src/webxml/locale/en-US/lang.dtd diff --git a/Open-ILS/src/Makefile b/Open-ILS/src/Makefile index 0ca3a4cfec..9734306559 100644 --- a/Open-ILS/src/Makefile +++ b/Open-ILS/src/Makefile @@ -1,9 +1,15 @@ -all: +export TMPDIR = $(TMP)/opensrf +export LD_OPTS = -L $(TMPDIR) -L . +export CC_OPTS = -g -Wall -O2 -fPIC -I$(LIBXML2_HEADERS) -I$(APACHE2_HEADERS) \ + -I$(LIBXML2_HEADERS)/libxml -I$(TMP) -I$(TMPDIR) + +all: mod_xmltools -web-install: web-templates-install javascript-install autojs-install install: perl-install web-install string-templates-install storage-bootstrap xsl-install +web-install: web-templates-install javascript-install autojs-install mod_xmltools-install webxml-install + JSDIR=$(WEBDIR)/js @@ -13,6 +19,16 @@ marcdumper: marcdumper-install: make -C extras/marcdumper install +mod_xmltools: + make -C apachemods mod_xmltools.so + +mod_xmltools-install: + make -C apachemods mod_xmltools-install + +webxml-install: + mkdir -p $(WEBDIR) + cp -r webxml $(WEBDIR) + perl-install: @echo "Installing Perl modules to $(PERLDIR)" mkdir -p $(PERLDIR) @@ -52,8 +68,6 @@ string-templates-install: cp -r templates/strings $(TEMPLATEDIR) - - xsl-install: @echo "Installing XSL files to $(XSLDIR)" mkdir -p $(XSLDIR) @@ -62,3 +76,4 @@ xsl-install: clean: @echo "Cleaning..." make -C extras clean + diff --git a/Open-ILS/src/apachemods/Makefile b/Open-ILS/src/apachemods/Makefile index 0a717e7fa1..5f39230216 100644 --- a/Open-ILS/src/apachemods/Makefile +++ b/Open-ILS/src/apachemods/Makefile @@ -1,6 +1,6 @@ # --------------------------------------------------------------------------------- -CC_OPTS = -I /usr/include/libxml2 -I /opt/include -g -APXS2 = /home/erickson/sandbox/apache2/bin/apxs +#CC_OPTS = -I /usr/include/libxml2 -I /opt/include -g +#APXS2 = /home/erickson/sandbox/apache2/bin/apxs # --------------------------------------------------------------------------------- LD_OPTS += -lxml2 -lc_utils @@ -27,6 +27,8 @@ mod_xmltools-install: LoadModule mod_xmltools_module modules/mod_xmltools.so \n \ to this: \n \ LoadModule mod_xmltools modules/mod_xmltools.so" + @echo "Also, you can add \nXMLToolsDefaultLocale \nand\n \ + XMLToolsLocaleDir to httpd.conf" @echo "-----------------------------------------------"; @sleep 3; diff --git a/Open-ILS/src/apachemods/mod_xmltools.c b/Open-ILS/src/apachemods/mod_xmltools.c index e96c78144e..6d801e4d25 100644 --- a/Open-ILS/src/apachemods/mod_xmltools.c +++ b/Open-ILS/src/apachemods/mod_xmltools.c @@ -49,9 +49,6 @@ static int mod_xmltools_handler (request_rec* r) { char* locale_dir = cfg->locale_dir; char* default_locale = cfg->default_locale; - fprintf(stderr, "%s : %s\n", locale_dir, default_locale ); - fflush(stderr); - /* we accept get/post requests */ r->allowed |= (AP_METHOD_BIT << M_GET); r->allowed |= (AP_METHOD_BIT << M_POST); @@ -75,6 +72,8 @@ static int mod_xmltools_handler (request_rec* r) { return HTTP_INTERNAL_SERVER_ERROR; } + fflush(stderr); + /* process xincludes */ if( xmlXIncludeProcess(doc) < 0 ) { fprintf(stderr, "\n ^-- Error processing XIncludes for file %s\n", file); @@ -82,6 +81,7 @@ static int mod_xmltools_handler (request_rec* r) { return HTTP_INTERNAL_SERVER_ERROR; } + fflush(stderr); /* replace the DTD */ if(xmlReplaceDtd(doc, dtdfile) < 0) { diff --git a/Open-ILS/src/apachemods/xmltools.c b/Open-ILS/src/apachemods/xmltools.c index c9f6c97f44..e2b9cb3b39 100644 --- a/Open-ILS/src/apachemods/xmltools.c +++ b/Open-ILS/src/apachemods/xmltools.c @@ -1,5 +1,74 @@ #include "xmltools.h" + +#ifdef XMLTOOLS_DEBUG // standalone debugging + +int main(int argc, char* argv[]) { + + char* file = argv[1]; + char* dtdfile = argv[2]; + + xmlDocPtr doc; + + + /* + xmlSubstituteEntitiesDefault(0); + xmlParserCtxtPtr ctxt = xmlNewParserCtxt(); + doc = xmlCtxtReadFile(ctxt, file, NULL, XML_PARSE_NOENT | XML_PARSE_RECOVER | XML_PARSE_XINCLUDE | XML_PARSE_NOERROR | XML_PARSE_NOWARNING ); + if(doc != NULL) + fprintf(stderr, "What we have so far:\n%s\n", xmlDocToString(doc, 1)); + else { + fprintf(stderr, "NO Doc\n"); + return 0; + } + + exit(99); + */ + + /* parse the doc */ + if( (doc = xmlParseFile(file)) == NULL) { + fprintf(stderr, "\n ^-- Error parsing XML file %s\n", file); + fflush(stderr); + return 99; + } + + /* process xincludes */ + if( xmlXIncludeProcessFlags(doc, XML_PARSE_NOENT) < 0 ) { + fprintf(stderr, "\n ^-- Error processing XIncludes for file %s\n", file); + if(doc != NULL) + fprintf(stderr, "What we have so far:\n%s\n", xmlDocToString(doc, 1)); + fflush(stderr); + return 99; + } + + + /* replace the DTD */ + if(xmlReplaceDtd(doc, dtdfile) < 0) { + fprintf(stderr, "Error replacing DTD file with file %s\n", dtdfile); + fflush(stderr); + return 99; + } + + /* force DTD entity replacement */ + doc = xmlProcessDtdEntities(doc); + + /* stringify */ + char* xml = xmlDocToString(doc, 0); + + fprintf(stderr, "%s\n", xml); + + /* deallocate */ + free(dtdfile); + free(xml); + xmlFreeDoc(doc); + xmlCleanupCharEncodingHandlers(); + xmlCleanupParser(); + + +} + +#endif + xmlDocPtr xmlProcessDtdEntities(xmlDocPtr doc) { char* xml = xmlDocToString(doc, 1); xmlFreeDoc(doc); diff --git a/Open-ILS/src/apachemods/xmltools.h b/Open-ILS/src/apachemods/xmltools.h index b5baeed760..c09f3cfb88 100644 --- a/Open-ILS/src/apachemods/xmltools.h +++ b/Open-ILS/src/apachemods/xmltools.h @@ -11,8 +11,6 @@ #include #include -#include "apachetools.h" - #ifndef XMLTOOLS_H #define XMLTOOLS_H diff --git a/Open-ILS/src/webxml/advanced.xml b/Open-ILS/src/webxml/advanced.xml index 4339885718..0b520f1fe5 100644 --- a/Open-ILS/src/webxml/advanced.xml +++ b/Open-ILS/src/webxml/advanced.xml @@ -1,4 +1,5 @@ + %ent; ] > diff --git a/Open-ILS/src/webxml/index.xml b/Open-ILS/src/webxml/index.xml index 2f2c41df53..bf7f55323b 100644 --- a/Open-ILS/src/webxml/index.xml +++ b/Open-ILS/src/webxml/index.xml @@ -1,4 +1,5 @@ + %ent; ] > @@ -6,7 +7,7 @@ Evergreen: Home - + diff --git a/Open-ILS/src/webxml/locale/en-US/lang.dtd b/Open-ILS/src/webxml/locale/en-US/lang.dtd new file mode 100644 index 0000000000..60b34cbbf9 --- /dev/null +++ b/Open-ILS/src/webxml/locale/en-US/lang.dtd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Open-ILS/src/webxml/login.xml b/Open-ILS/src/webxml/login.xml index d74f513e5f..4de66ed229 100644 --- a/Open-ILS/src/webxml/login.xml +++ b/Open-ILS/src/webxml/login.xml @@ -1,4 +1,5 @@ + %ent; ] >
diff --git a/Open-ILS/src/webxml/mresult.xml b/Open-ILS/src/webxml/mresult.xml index aca23c7d42..b1da9618e6 100644 --- a/Open-ILS/src/webxml/mresult.xml +++ b/Open-ILS/src/webxml/mresult.xml @@ -1,4 +1,5 @@ + %ent; ] > diff --git a/Open-ILS/src/webxml/myopac/index.xml b/Open-ILS/src/webxml/myopac/index.xml index d27a62af97..b4d79fe5fc 100644 --- a/Open-ILS/src/webxml/myopac/index.xml +++ b/Open-ILS/src/webxml/myopac/index.xml @@ -1,4 +1,5 @@ + %ent; ] > diff --git a/Open-ILS/src/webxml/result_common.xml b/Open-ILS/src/webxml/result_common.xml index ff2d33ac2c..adca4ae8ad 100644 --- a/Open-ILS/src/webxml/result_common.xml +++ b/Open-ILS/src/webxml/result_common.xml @@ -1,4 +1,5 @@ + %ent; ] >
@@ -24,12 +25,12 @@ Start -   +   << -   + >> -   + End diff --git a/Open-ILS/src/webxml/rresult.xml b/Open-ILS/src/webxml/rresult.xml index 9d0b2560a8..18f82bde85 100644 --- a/Open-ILS/src/webxml/rresult.xml +++ b/Open-ILS/src/webxml/rresult.xml @@ -1,4 +1,5 @@ + %ent; ] > diff --git a/Open-ILS/src/webxml/sidebar.xml b/Open-ILS/src/webxml/sidebar.xml index 0df07d25e2..88a2c10b3a 100644 --- a/Open-ILS/src/webxml/sidebar.xml +++ b/Open-ILS/src/webxml/sidebar.xml @@ -1,4 +1,5 @@ + %ent; ] > @@ -6,14 +7,14 @@