diff options
Diffstat (limited to 'project2/xml/rawView.cpp')
-rw-r--r-- | project2/xml/rawView.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/project2/xml/rawView.cpp b/project2/xml/rawView.cpp index c583e00..4f013f9 100644 --- a/project2/xml/rawView.cpp +++ b/project2/xml/rawView.cpp @@ -15,10 +15,12 @@ class RawViewBase : public View { void execute(const MultiRowSetPresenter * mp, ExecContext * ec) const { if (const Presenter * p = dynamic_cast<const Presenter *>(mp)) { - for (const auto * node : getCopyRoot(ec)->get_children()) { - const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(node); - if (e) { - copyNode(p, e); + if (auto copyRoot = getCopyRoot(ec)) { + for (const auto * node : copyRoot->get_children()) { + const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(node); + if (e) { + copyNode(p, e); + } } } } @@ -30,11 +32,16 @@ class RawViewBase : public View { private: void copyNode(const Presenter * p, const xmlpp::Element * n) const { - p->pushSub(n->get_name()); - p->setNamespace(n->get_namespace_prefix(), n->get_namespace_uri()); + if (!n->get_namespace_uri().empty()) { + p->setNamespace(n->get_namespace_prefix(), n->get_namespace_uri()); + } + p->pushSub(n->get_name(), n->get_namespace_prefix()); xmlpp::Element::AttributeList al = n->get_attributes(); for (const xmlpp::Attribute * a : al) { - p->addAttribute(a->get_name(), a->get_value()); + if (!a->get_namespace_uri().empty()) { + p->setNamespace(a->get_namespace_prefix(), a->get_namespace_uri()); + } + p->addAttribute(a->get_name(), a->get_namespace_prefix(), a->get_value()); } const xmlpp::Node::NodeList ch = n->get_children(); for (const xmlpp::Node * c : ch) { |