[passepartout] added a testcase for the xslt parameter parsing; port the parser to libxml++ 2.6
- From: Sven Herzberg <herzi src gnome org>
- To: svn-commits-list gnome org
- Subject: [passepartout] added a testcase for the xslt parameter parsing; port the parser to libxml++ 2.6
- Date: Tue, 28 Apr 2009 10:16:04 -0400 (EDT)
commit 55c645582d24a33a9cf93c03c04618262449809a
Author: Sven Herzberg <herzi lanedo com>
Date: Tue Apr 28 13:16:26 2009 +0200
added a testcase for the xslt parameter parsing; port the parser to libxml++ 2.6
* src/pptout/document/Makefile.am: execute a test (so we realize when this
breaks again)
* src/pptout/document/getxsltparams.cc: behave like a test (silent unless
asked for verbosity)
---
src/pptout/document/Makefile.am | 8 +++++-
src/pptout/document/getxsltparams.cc | 46 ++++++++++++++++++++++++++-------
2 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/src/pptout/document/Makefile.am b/src/pptout/document/Makefile.am
index 0622ced..be4a1ed 100644
--- a/src/pptout/document/Makefile.am
+++ b/src/pptout/document/Makefile.am
@@ -13,6 +13,12 @@ getxsltparams_LDADD=\
$(XMLPP_LIBS) \
$(NULL)
+check-local: getxsltparams
+ @for xslt in $(top_srcdir)/data/xhtml.xslt; do \
+ echo "[TEST] $< $$xslt" >&2; \
+ ./getxsltparams $$xslt || exit $$?; \
+ done
+
dist_noinst_HEADERS = basicframe.h cachedframe.h document.h group.h \
imageframe.h page.h pagent.h rasterframe.h textframe.h \
textstream.h fileerrors.h paper_sizes.h getxsltparams.h \
@@ -24,4 +30,4 @@ libdocument_a_SOURCES = basicframe.cc cachedframe.cc document.cc \
loader.cc typesetterthread.cc
libdocument_a_CPPFLAGS = -I$(top_srcdir)/src
-libdocument_a_CPPFLAGS += $(GTKMM_CFLAGS) $(getxsltparams_CPPFLAGS)
+libdocument_a_CPPFLAGS += $(GTKMM_CFLAGS) $(XMLPP_CFLAGS) $(WARN_CFLAGS)
diff --git a/src/pptout/document/getxsltparams.cc b/src/pptout/document/getxsltparams.cc
index ae08bf8..f56fde4 100644
--- a/src/pptout/document/getxsltparams.cc
+++ b/src/pptout/document/getxsltparams.cc
@@ -11,7 +11,7 @@ public:
const std::vector<std::string>& result() const { return found; }
protected:
- void on_start_element(const std::string& n,
+ void on_start_element(const Glib::ustring& n,
const xmlpp::SaxParser::AttributeList &p);
private:
@@ -20,8 +20,9 @@ private:
bool done;
};
-void XsltParamsFinder::on_start_element
-(const std::string& n, const xmlpp::SaxParser::AttributeList &p)
+void
+XsltParamsFinder::on_start_element (const Glib::ustring& n,
+ const xmlpp::SaxParser::AttributeList &p)
{
if(done) return;
@@ -64,25 +65,50 @@ int
main (int argc,
char**argv)
{
+ int file_argument = 1;
+ bool verbose = false;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp ("-v", argv[i]) ||
+ !strcmp ("--verbose", argv[i]))
+ {
+ verbose = true;
+
+ if (i == file_argument)
+ {
+ file_argument++;
+ }
+ }
+ }
+
if (argc <= 1)
{
std::cerr << "Usage:" << std::endl
- << "\t" << argv[0] << " <xslt-file>" << std::endl;
+ << "\t" << argv[0] << " [-v|--verbose] <xslt-file>" << std::endl;
return 1;
}
- std::vector<std::string> params = getXsltParams (argv[1]);
+ std::vector<std::string> params = getXsltParams (argv[file_argument]);
if (params.size () <= 0)
{
- std::cerr << "File \"" << argv[1] << "\" didn't contain parameters" << std::endl;
+ std::cerr << "File \"" << argv[file_argument] << "\" didn't contain parameters" << std::endl;
return 2;
}
- for(std::vector<std::string>::const_iterator i = params.begin();
- i != params.end(); ++i) {
- std::cout << "Found parameter: " << *i << std::endl;
- }
+ if (verbose)
+ {
+ std::cout << "File \"" << argv[file_argument] << "\" contains "
+ << params.size () << " parameter(s)." << std::endl;
+
+ for (std::vector<std::string>::const_iterator i = params.begin();
+ i != params.end();
+ ++i)
+ {
+ std::cout << "Found parameter: " << *i << std::endl;
+ }
+ }
return 0;
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]