summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2013-01-23 21:17:00 +0000
committerrandomdan <randomdan@localhost>2013-01-23 21:17:00 +0000
commit70a6c7ec50b203318ac8ce672a1bcd34eed00dd8 (patch)
tree975e3c5c6dfe526dcb5d1e09c739866b50de11b5
parentUse the method attribute from the XSLT document to determine the output method (diff)
downloadproject2-70a6c7ec50b203318ac8ce672a1bcd34eed00dd8.tar.bz2
project2-70a6c7ec50b203318ac8ce672a1bcd34eed00dd8.tar.xz
project2-70a6c7ec50b203318ac8ce672a1bcd34eed00dd8.zip
Don't add null values to the XML output tree
Include part info where available in guide
-rw-r--r--project2/xml/xmlPresenter.cpp20
-rw-r--r--project2/xml/xmlPresenter.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp
index 9982a43..075518c 100644
--- a/project2/xml/xmlPresenter.cpp
+++ b/project2/xml/xmlPresenter.cpp
@@ -153,6 +153,26 @@ XmlPresenter::addAttribute(const Glib::ustring & name, const Glib::ustring & ns,
}
}
+void
+XmlPresenter::addNamedValue(const Glib::ustring & name, const VariableType & value) const
+{
+ if (!value.isNull()) {
+ pushSub(name, Glib::ustring());
+ addText(value);
+ popSub();
+ }
+}
+
+void
+XmlPresenter::addNamedValue(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const
+{
+ if (!value.isNull()) {
+ pushSub(name, ns);
+ addText(value);
+ popSub();
+ }
+}
+
class XmlNodeWriter : public boost::static_visitor<bool> {
public:
XmlNodeWriter(xmlpp::Element * n) : node(n) { }
diff --git a/project2/xml/xmlPresenter.h b/project2/xml/xmlPresenter.h
index 744ef3d..79d9634 100644
--- a/project2/xml/xmlPresenter.h
+++ b/project2/xml/xmlPresenter.h
@@ -30,6 +30,8 @@ class XmlPresenter : public Presenter, public ContentPresenter, public SourceOf<
void pushSub(const Glib::ustring & name, const Glib::ustring & ns) const;
void addAttribute(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const;
void addText(const VariableType & value) const;
+ void addNamedValue(const Glib::ustring & name, const VariableType & value) const;
+ void addNamedValue(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const;
void popSub() const;
void addNewArray(const Glib::ustring&, bool objects) const;
void finishArray(bool objects) const;