aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/parsing.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-07-03 09:57:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-07-03 09:57:09 +0200
commit1a4099b78717b16f632b0e7e0980a27811221e52 (patch)
tree87a63393fc207082b7418987309581a9a79e49a4 /libxsd/xsd/cxx/tree/parsing.txx
parent06258b8eae3d5af9a1af0206bb5a8e5c80dde455 (diff)
Implement anyType and anySimpleType content representation
anyType as a DOM fragment, similar to wildcards. anySimpleType as a text string.
Diffstat (limited to 'libxsd/xsd/cxx/tree/parsing.txx')
-rw-r--r--libxsd/xsd/cxx/tree/parsing.txx62
1 files changed, 36 insertions, 26 deletions
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 <typename B>
- inline simple_type<B>::
+ template <typename C, typename B>
+ inline simple_type<C, B>::
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<C> (e)));
}
- template <typename B>
- inline simple_type<B>::
+ template <typename C, typename B>
+ inline simple_type<C, B>::
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<C> (a.getValue ())));
}
- template <typename B>
- template <typename C>
- inline simple_type<B>::
+ template <typename C, typename B>
+ inline simple_type<C, B>::
simple_type (const std::basic_string<C>& 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 <typename T, typename C, schema_type::value ST>
@@ -203,7 +216,6 @@ namespace xsd
return;
using std::basic_string;
- typedef typename sequence<T>::ptr ptr;
typedef typename basic_string<C>::size_type size_type;
const C* data (s.c_str ());
@@ -218,13 +230,12 @@ namespace xsd
if (j != basic_string<C>::npos)
{
- ptr r (
- new T (basic_string<C> (data + i, j - i),
- parent,
- f,
- this->container_));
-
- this->v_.push_back (r);
+ this->push_back (
+ traits<T, C, ST>::create (
+ basic_string<C> (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<C> (data + i, size - i),
- parent,
- f,
- this->container_));
-
- this->v_.push_back (r);
+ this->push_back (
+ traits<T, C, ST>::create (
+ basic_string<C> (data + i, size - i),
+ parent,
+ f,
+ this->container_));
break;
}