From 1a4099b78717b16f632b0e7e0980a27811221e52 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Jul 2014 09:57:09 +0200 Subject: Implement anyType and anySimpleType content representation anyType as a DOM fragment, similar to wildcards. anySimpleType as a text string. --- libxsd/xsd/cxx/tree/parsing.txx | 62 ++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'libxsd/xsd/cxx/tree/parsing.txx') diff --git a/libxsd/xsd/cxx/tree/parsing.txx b/libxsd/xsd/cxx/tree/parsing.txx index 628b7fd..02aeda1 100644 --- a/libxsd/xsd/cxx/tree/parsing.txx +++ b/libxsd/xsd/cxx/tree/parsing.txx @@ -36,6 +36,9 @@ namespace xsd _type (const xercesc::DOMElement& e, flags f, container* c) : container_ (c) { + if (f & flags::extract_content) + content_.reset (new dom_content_type (e)); + if (f & flags::keep_dom) dom_info_ = dom_info_factory::create (e, *this, c == 0); } @@ -44,6 +47,8 @@ namespace xsd _type (const xercesc::DOMAttr& a, flags f, container* c) : container_ (c) { + // anyType cannot be an attribute type so no content extraction. + if (f & flags::keep_dom) dom_info_ = dom_info_factory::create (a, *this); } @@ -56,33 +61,41 @@ namespace xsd container* c) : container_ (c) // List elements don't have associated DOM nodes. { + // anyType cannot be a list element type so no content extraction. } // simple_type // - template - inline simple_type:: + template + inline simple_type:: simple_type (const xercesc::DOMElement& e, flags f, container* c) - : B (e, f, c) + : B (e, (f & ~flags::extract_content), c) { + if (f & flags::extract_content) + this->content_.reset ( + new text_content_type (tree::text_content (e))); } - template - inline simple_type:: + template + inline simple_type:: simple_type (const xercesc::DOMAttr& a, flags f, container* c) - : B (a, f, c) + : B (a, (f & ~flags::extract_content), c) { + if (f & flags::extract_content) + this->content_.reset (new text_content_type ( + xml::transcode (a.getValue ()))); } - template - template - inline simple_type:: + template + inline simple_type:: simple_type (const std::basic_string& s, const xercesc::DOMElement* e, flags f, container* c) - : B (s, e, f, c) + : B (s, e, (f & ~flags::extract_content), c) { + if (f & flags::extract_content) + this->content_.reset (new text_content_type (s)); } // fundamental_base @@ -161,7 +174,7 @@ namespace xsd } // Individual items of the list have no DOM association. Therefore - // I clear keep_dom from flags. + // we clear keep_dom from flags. // template @@ -203,7 +216,6 @@ namespace xsd return; using std::basic_string; - typedef typename sequence::ptr ptr; typedef typename basic_string::size_type size_type; const C* data (s.c_str ()); @@ -218,13 +230,12 @@ namespace xsd if (j != basic_string::npos) { - ptr r ( - new T (basic_string (data + i, j - i), - parent, - f, - this->container_)); - - this->v_.push_back (r); + this->push_back ( + traits::create ( + basic_string (data + i, j - i), + parent, + f, + this->container_)); i = bits::find_ns (data, size, j); } @@ -232,13 +243,12 @@ namespace xsd { // Last element. // - ptr r ( - new T (basic_string (data + i, size - i), - parent, - f, - this->container_)); - - this->v_.push_back (r); + this->push_back ( + traits::create ( + basic_string (data + i, size - i), + parent, + f, + this->container_)); break; } -- cgit v1.1