lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] how to remove "#define private public" hack in xslt_lmi.cpp?


From: Vaclav Slavik
Subject: Re: [lmi] how to remove "#define private public" hack in xslt_lmi.cpp?
Date: Thu, 05 Feb 2009 09:55:44 +0100

Hi,

On Thu, 2009-02-05 at 00:31 +0100, Vadim Zeitlin wrote:
> Besides, this hack is ugly, of course,
> and there is already a TODO about removing it so I suppose there would be
> no objections if I did it, would there? 

You'd be wasting your time. This code is going to be removed soon (see
past discussion on this ML). Below is preliminary(!) patch that switches
XSLT code to xsltwrapp, but it requires SVN version of xmlwrapp (which
is why I didn't submit it yet)


Regards,
Vaclav

Index: Makefile.am
===================================================================
RCS file: /sources/lmi/lmi/Makefile.am,v
retrieving revision 1.70
diff -u -u -r1.70 Makefile.am
--- Makefile.am 27 Dec 2008 02:56:35 -0000      1.70
+++ Makefile.am 5 Feb 2009 07:58:15 -0000
@@ -289,7 +289,6 @@
     system_command.cpp \
     timer.cpp \
     xml_lmi.cpp \
-    xslt_lmi.cpp \
     yare_input.cpp
 
 libmain_auxiliary_common_la_SOURCES = \
@@ -1010,6 +1009,5 @@
     wx_workarounds.hpp \
     xml_lmi_fwd.hpp \
     xml_lmi.hpp \
-    xslt_lmi.hpp \
     yare_input.hpp \
     zero.hpp
Index: configurable_settings.cpp
===================================================================
RCS file: /sources/lmi/lmi/configurable_settings.cpp,v
retrieving revision 1.44
diff -u -u -r1.44 configurable_settings.cpp
--- configurable_settings.cpp   27 Dec 2008 02:56:38 -0000      1.44
+++ configurable_settings.cpp   5 Feb 2009 07:58:15 -0000
@@ -191,17 +191,17 @@
     std::ostringstream oss;
     xml_lmi::dom_parser parser(configuration_filepath().string());
     xml::element const& root = parser.root_node(xml_root_name());
-    xml_lmi::ElementContainer const elements(xml_lmi::child_elements(root));
-    typedef xml_lmi::ElementContainer::const_iterator eci;
-    for(eci i = elements.begin(); i != elements.end(); ++i)
+    xml::const_nodes_view const elements(root.elements());
+    typedef xml::const_nodes_view::const_iterator cnvi;
+    for(cnvi i = elements.begin(); i != elements.end(); ++i)
         {
-        std::string name = (*i)->get_name();
+        std::string name = i->get_name();
         if
             (   member_names().end()
             !=  std::find(member_names().begin(), member_names().end(), name)
             )
             {
-            operator[]((*i)->get_name()) = xml_lmi::get_content(**i);
+            operator[](i->get_name()) = xml_lmi::get_content(*i);
             }
         else if(is_detritus(name))
             {
Index: configure.ac
===================================================================
RCS file: /sources/lmi/lmi/configure.ac,v
retrieving revision 1.44
diff -u -u -r1.44 configure.ac
--- configure.ac        27 Dec 2008 02:56:38 -0000      1.44
+++ configure.ac        5 Feb 2009 07:58:15 -0000
@@ -451,7 +451,7 @@
     PKG_CHECK_MODULES(GTK, gtk+-2.0)
     PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.6.0)
     PKG_CHECK_MODULES(LIBXSLT, libxslt >= 1.1.0)
-    PKG_CHECK_MODULES(XMLWRAPP, xmlwrapp)
+    PKG_CHECK_MODULES(XMLWRAPP, xmlwrapp >= 0.6.0 xsltwrapp)
 else
     dnl --- libxml (required) -------------------
     AC_CHECK_PROG(lmi_xml2_config, xml2-config, yes, no)
@@ -503,27 +503,6 @@
 CXXFLAGS=$save_CXXFLAGS
 LIBS=$save_LIBS
 
-AC_CACHE_CHECK([if we are using recent version of xmlwrapp],
-    lmi_cv_lib_xmlwrapp_recent,
-    [
-        save_CXXFLAGS=$CXXFLAGS
-        CXXFLAGS="$CXXFLAGS $XMLWRAPP_CFLAGS"
-        AC_TRY_COMPILE([#include <xmlwrapp/document.h>
-            #include <xmlwrapp/tree_parser.h>
-            #include <xmlwrapp/node.h>],
-            [
-                xml::tree_parser parser("");
-                parser.get_document().get_root_node();
-            ],
-            lmi_cv_lib_xmlwrapp_recent=yes,
-            lmi_cv_lib_xmlwrapp_recent=no
-        )
-    ]
-)
-if test "x$lmi_cv_lib_xmlwrapp_recent" = "xyes"; then
-    AC_DEFINE([USING_CURRENT_XMLWRAPP], [1], [Define this if you have the 
latest version of libxmlwrapp])
-fi
-
 dnl --- CGICC (optional) ----------------
 if test "x$lmi_cgicc_option" != "xno"; then
     lmi_found_cgicc=yes
Index: ledger_xml_io.cpp
===================================================================
RCS file: /sources/lmi/lmi/ledger_xml_io.cpp,v
retrieving revision 1.85
diff -u -u -r1.85 ledger_xml_io.cpp
--- ledger_xml_io.cpp   27 Dec 2008 02:56:46 -0000      1.85
+++ ledger_xml_io.cpp   5 Feb 2009 07:58:15 -0000
@@ -40,11 +40,11 @@
 #include "value_cast.hpp"
 #include "version.hpp"
 #include "xml_lmi.hpp"
-#include "xslt_lmi.hpp"
 
 #include <boost/filesystem/fstream.hpp>
 #include <boost/filesystem/operations.hpp>
 #include <boost/filesystem/path.hpp>
+#include <xsltwrapp/xsltwrapp.h>
 
 #include <fstream>
 #include <iomanip>
@@ -1019,13 +1019,27 @@
     // in the ledger-class implementation.
     Ledger scaled_ledger(*this);
     scaled_ledger.AutoScale();
-
     xml_lmi::xml_document document(xml_root_name());
     document.root_node() << scaled_ledger;
-    xslt_lmi::Stylesheet(xsl_filepath(scaled_ledger).string()).transform
-        (document.document()
-        ,os
-        ,xslt_lmi::Stylesheet::e_output_xml
-        );
-}
 
+    try
+        {
+        // FIXME: the old code did the equivalent of calling
+        //        xml::init::load_external_subsets(false) here -- do we need
+        //        it or not really?
+        //        probably comes from advice here: 
http://xmlsoft.org/XSLT/API.html
+        //        http://xmlsoft.org/XSLT/tutorial/libxslttutorial.html
+        //        -- but it's the other way around, it should be TRUE,
+        //        we do FALSE
+        xslt::stylesheet 
stylesheet(xsl_filepath(scaled_ledger).string().c_str());
+        os << stylesheet.apply(document.document());
+        }
+    catch(std::exception const& e)
+        {
+        fatal_error()
+            << "Unable to apply stylesheet: "
+            << e.what()
+            << LMI_FLUSH
+            ;
+        }
+}
Index: objects.make
===================================================================
RCS file: /sources/lmi/lmi/objects.make,v
retrieving revision 1.145
diff -u -u -r1.145 objects.make
--- objects.make        27 Dec 2008 02:56:52 -0000      1.145
+++ objects.make        5 Feb 2009 07:58:16 -0000
@@ -225,7 +225,6 @@
   timer.o \
   tn_range_types.o \
   xml_lmi.o \
-  xslt_lmi.o \
   yare_input.o \
 
 
################################################################################






reply via email to

[Prev in Thread] Current Thread [Next in Thread]