summaryrefslogtreecommitdiff
path: root/xsd-tests/cxx/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xsd-tests/cxx/parser')
-rw-r--r--xsd-tests/cxx/parser/.gitignore1
-rw-r--r--xsd-tests/cxx/parser/built-in/buildfile23
-rw-r--r--xsd-tests/cxx/parser/built-in/driver.cxx529
-rw-r--r--xsd-tests/cxx/parser/built-in/output164
-rw-r--r--xsd-tests/cxx/parser/built-in/test.xml199
-rw-r--r--xsd-tests/cxx/parser/built-in/test.xsd63
-rw-r--r--xsd-tests/cxx/parser/enumeration/buildfile24
-rw-r--r--xsd-tests/cxx/parser/enumeration/driver.cxx81
-rw-r--r--xsd-tests/cxx/parser/enumeration/gender.hxx13
-rw-r--r--xsd-tests/cxx/parser/enumeration/output3
-rw-r--r--xsd-tests/cxx/parser/enumeration/test.map7
-rw-r--r--xsd-tests/cxx/parser/enumeration/test.xml10
-rw-r--r--xsd-tests/cxx/parser/enumeration/test.xsd35
-rw-r--r--xsd-tests/cxx/parser/generated-impl/.gitignore2
-rw-r--r--xsd-tests/cxx/parser/generated-impl/buildfile31
-rw-r--r--xsd-tests/cxx/parser/generated-impl/output122
-rw-r--r--xsd-tests/cxx/parser/generated-impl/test.xml168
-rw-r--r--xsd-tests/cxx/parser/generated-impl/test.xsd142
-rw-r--r--xsd-tests/cxx/parser/list/buildfile23
-rw-r--r--xsd-tests/cxx/parser/list/driver.cxx105
-rw-r--r--xsd-tests/cxx/parser/list/output26
-rw-r--r--xsd-tests/cxx/parser/list/test.xml25
-rw-r--r--xsd-tests/cxx/parser/list/test.xsd25
-rw-r--r--xsd-tests/cxx/parser/name-clash/inheritance/buildfile24
-rw-r--r--xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx62
-rw-r--r--xsd-tests/cxx/parser/name-clash/inheritance/output2
-rw-r--r--xsd-tests/cxx/parser/name-clash/inheritance/test.xml8
-rw-r--r--xsd-tests/cxx/parser/name-clash/inheritance/test.xsd22
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/buildfile24
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx68
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/output22
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx147
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx94
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/test.xml15
-rw-r--r--xsd-tests/cxx/parser/polymorphism/recursive/test.xsd53
-rw-r--r--xsd-tests/cxx/parser/polymorphism/same-type/buildfile24
-rw-r--r--xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx62
-rw-r--r--xsd-tests/cxx/parser/polymorphism/same-type/output4
-rw-r--r--xsd-tests/cxx/parser/polymorphism/same-type/test.xml10
-rw-r--r--xsd-tests/cxx/parser/polymorphism/same-type/test.xsd21
-rw-r--r--xsd-tests/cxx/parser/recursive/buildfile24
-rw-r--r--xsd-tests/cxx/parser/recursive/driver.cxx139
-rw-r--r--xsd-tests/cxx/parser/recursive/output22
-rw-r--r--xsd-tests/cxx/parser/recursive/test.xml11
-rw-r--r--xsd-tests/cxx/parser/recursive/test.xsd27
-rw-r--r--xsd-tests/cxx/parser/test-template/buildfile23
-rw-r--r--xsd-tests/cxx/parser/test-template/driver.cxx66
-rw-r--r--xsd-tests/cxx/parser/test-template/output1
-rw-r--r--xsd-tests/cxx/parser/test-template/test.xml7
-rw-r--r--xsd-tests/cxx/parser/test-template/test.xsd12
-rw-r--r--xsd-tests/cxx/parser/union/buildfile23
-rw-r--r--xsd-tests/cxx/parser/union/driver.cxx60
-rw-r--r--xsd-tests/cxx/parser/union/output2
-rw-r--r--xsd-tests/cxx/parser/union/test.xml10
-rw-r--r--xsd-tests/cxx/parser/union/test.xsd16
-rw-r--r--xsd-tests/cxx/parser/validation/all/buildfile22
-rw-r--r--xsd-tests/cxx/parser/validation/all/driver.cxx98
-rw-r--r--xsd-tests/cxx/parser/validation/all/test.xsd20
-rw-r--r--xsd-tests/cxx/parser/validation/all/testscript190
-rw-r--r--xsd-tests/cxx/parser/validation/any/buildfile24
-rw-r--r--xsd-tests/cxx/parser/validation/any/driver.cxx121
-rw-r--r--xsd-tests/cxx/parser/validation/any/output29
-rw-r--r--xsd-tests/cxx/parser/validation/any/test.xml21
-rw-r--r--xsd-tests/cxx/parser/validation/any/test.xsd20
-rw-r--r--xsd-tests/cxx/parser/validation/attribute/buildfile24
-rw-r--r--xsd-tests/cxx/parser/validation/attribute/driver.cxx197
-rw-r--r--xsd-tests/cxx/parser/validation/attribute/output24
-rw-r--r--xsd-tests/cxx/parser/validation/attribute/test.xml10
-rw-r--r--xsd-tests/cxx/parser/validation/attribute/test.xsd71
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/any-type/buildfile24
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx154
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/any-type/output99
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/any-type/test.xml41
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd31
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/binary/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx153
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/boolean/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx145
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/byte/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx256
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/date-time/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx1533
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/float/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/float/driver.cxx285
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/int/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/int/driver.cxx116
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/integer/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx303
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/long/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/long/driver.cxx116
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/qname/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx105
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/short/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/short/driver.cxx116
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/string/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/string/driver.cxx512
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/uri/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx53
-rw-r--r--xsd-tests/cxx/parser/validation/choice/buildfile22
-rw-r--r--xsd-tests/cxx/parser/validation/choice/driver.cxx126
-rw-r--r--xsd-tests/cxx/parser/validation/choice/test.xsd24
-rw-r--r--xsd-tests/cxx/parser/validation/choice/testscript179
-rw-r--r--xsd-tests/cxx/parser/validation/restriction/buildfile22
-rw-r--r--xsd-tests/cxx/parser/validation/restriction/driver.cxx107
-rw-r--r--xsd-tests/cxx/parser/validation/restriction/test.xsd82
-rw-r--r--xsd-tests/cxx/parser/validation/restriction/testscript159
-rw-r--r--xsd-tests/cxx/parser/validation/sequence/buildfile22
-rw-r--r--xsd-tests/cxx/parser/validation/sequence/driver.cxx139
-rw-r--r--xsd-tests/cxx/parser/validation/sequence/test.xsd28
-rw-r--r--xsd-tests/cxx/parser/validation/sequence/testscript328
110 files changed, 9197 insertions, 0 deletions
diff --git a/xsd-tests/cxx/parser/.gitignore b/xsd-tests/cxx/parser/.gitignore
new file mode 100644
index 0000000..5a7b950
--- /dev/null
+++ b/xsd-tests/cxx/parser/.gitignore
@@ -0,0 +1 @@
+*-pskel.?xx
diff --git a/xsd-tests/cxx/parser/built-in/buildfile b/xsd-tests/cxx/parser/built-in/buildfile
new file mode 100644
index 0000000..0522c9a
--- /dev/null
+++ b/xsd-tests/cxx/parser/built-in/buildfile
@@ -0,0 +1,23 @@
+# file : cxx/parser/built-in/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/built-in/driver.cxx b/xsd-tests/cxx/parser/built-in/driver.cxx
new file mode 100644
index 0000000..008bc2d
--- /dev/null
+++ b/xsd-tests/cxx/parser/built-in/driver.cxx
@@ -0,0 +1,529 @@
+// file : cxx/parser/built-in/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test built-in type parsing.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct any_type_pimpl: xml_schema::any_type_pimpl
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ _start_any_element (ro_string const&,
+ ro_string const& n,
+ ro_string const*)
+ {
+ cout << " start any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const& n)
+ {
+ cout << " end any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const&,
+ ro_string const& n,
+ ro_string const& v)
+ {
+ cout << " any attribute " << n << " = '" << v << "'" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_type ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_simple_type ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+ virtual void
+ boolean (bool v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ byte (signed char v)
+ {
+ cout << short (v) << endl;
+ }
+
+ virtual void
+ unsigned_byte (unsigned char v)
+ {
+ cout << (unsigned short) (v) << endl;
+ }
+
+ virtual void
+ short_ (short v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ unsigned_short (unsigned short v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ int_ (int v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ unsigned_int (unsigned int v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ long_ (long long v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ unsigned_long (unsigned long long v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ integer (long long v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ negative_integer (long long v)
+ {
+ cout << v << endl;
+ }
+
+
+ virtual void
+ non_positive_integer (long long v)
+ {
+ cout << v << endl;
+ }
+
+
+ virtual void
+ positive_integer (unsigned long long v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ non_negative_integer (unsigned long long v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ float_ (float v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ double_ (double v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ decimal (double v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ string (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ normalized_string (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ token (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ name (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ nmtoken (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ nmtokens (xml_schema::string_sequence const& s)
+ {
+ cout << "'";
+
+ for (xml_schema::string_sequence::const_iterator i (s.begin ());
+ i != s.end (); ++i)
+ cout << *i << " ";
+
+ cout << "'" << endl;
+ }
+
+ virtual void
+ ncname (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ id (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ idref (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ idrefs (xml_schema::string_sequence const& s)
+ {
+ cout << "'";
+
+ for (xml_schema::string_sequence::const_iterator i (s.begin ());
+ i != s.end (); ++i)
+ cout << *i << " ";
+
+ cout << "'" << endl;
+ }
+
+ virtual void
+ language (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ uri (std::string const& v)
+ {
+ cout << "'" << v << "'" << endl;
+ }
+
+ virtual void
+ qname (xml_schema::qname const& v)
+ {
+ cout << "'" << v.prefix () << ":" << v.name () << "'" << endl;
+ }
+
+ virtual void
+ base64_binary (XSD_AUTO_PTR<xml_schema::buffer> v)
+ {
+ std::string tmp (v->data (), v->size ());
+ cout << "'" << tmp << "'" << endl;
+ }
+
+ virtual void
+ hex_binary (XSD_AUTO_PTR<xml_schema::buffer> v)
+ {
+ std::string tmp (v->data (), v->size ());
+ cout << "'" << tmp << "'" << endl;
+ }
+
+ virtual void
+ gday (xml_schema::gday const& v)
+ {
+ cout << v.day ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ gmonth (xml_schema::gmonth const& v)
+ {
+ cout << v.month ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ gyear (xml_schema::gyear const& v)
+ {
+ cout << v.year ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ gmonth_day (xml_schema::gmonth_day const& v)
+ {
+ cout << v.month () << '-' << v.day ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ gyear_month (xml_schema::gyear_month const& v)
+ {
+ cout << v.year () << '-' << v.month ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ date (xml_schema::date const& v)
+ {
+ cout << v.year () << '-' << v.month () << '-' << v.day ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ time (xml_schema::time const& v)
+ {
+ cout << v.hours () << ':' << v.minutes () << ':' << v.seconds ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ date_time (xml_schema::date_time const& v)
+ {
+ cout << v.year () << '-' << v.month () << '-' << v.day () << 'T'
+ << v.hours () << ':' << v.minutes () << ':' << v.seconds ();
+
+ if (v.zone_present ())
+ cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours ()
+ << ':' << v.zone_minutes ();
+
+ cout << endl;
+ }
+
+ virtual void
+ duration (xml_schema::duration const& v)
+ {
+ cout << (v.negative () ? "-" : "") << 'P'
+ << v.years () << 'Y'
+ << v.months () << 'M'
+ << v.days () << 'D'
+ << 'T'
+ << v.hours () << 'H'
+ << v.minutes () << 'M'
+ << v.seconds () << 'S'
+ << endl;
+ }
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ any_type_pimpl any_type_p;
+ any_simple_type_pimpl any_simple_type_p;
+
+ xml_schema::boolean_pimpl boolean_p;
+
+ xml_schema::byte_pimpl byte_p;
+ xml_schema::unsigned_byte_pimpl unsigned_byte_p;
+ xml_schema::short_pimpl short_p;
+ xml_schema::unsigned_short_pimpl unsigned_short_p;
+ xml_schema::int_pimpl int_p;
+ xml_schema::unsigned_int_pimpl unsigned_int_p;
+ xml_schema::long_pimpl long_p;
+ xml_schema::unsigned_long_pimpl unsigned_long_p;
+
+ xml_schema::integer_pimpl integer_p;
+ xml_schema::negative_integer_pimpl negative_integer_p;
+ xml_schema::non_positive_integer_pimpl non_positive_integer_p;
+ xml_schema::positive_integer_pimpl positive_integer_p;
+ xml_schema::non_negative_integer_pimpl non_negative_integer_p;
+
+ xml_schema::float_pimpl float_p;
+ xml_schema::double_pimpl double_p;
+ xml_schema::decimal_pimpl decimal_p;
+
+ xml_schema::string_pimpl string_p;
+ xml_schema::normalized_string_pimpl normalized_string_p;
+ xml_schema::token_pimpl token_p;
+ xml_schema::name_pimpl name_p;
+ xml_schema::nmtoken_pimpl nmtoken_p;
+ xml_schema::nmtokens_pimpl nmtokens_p;
+ xml_schema::ncname_pimpl ncname_p;
+ xml_schema::id_pimpl id_p;
+ xml_schema::idref_pimpl idref_p;
+ xml_schema::idrefs_pimpl idrefs_p;
+
+ xml_schema::language_pimpl language_p;
+ xml_schema::uri_pimpl uri_p;
+ xml_schema::qname_pimpl qname_p;
+
+ xml_schema::base64_binary_pimpl base64_binary_p;
+ xml_schema::hex_binary_pimpl hex_binary_p;
+
+ xml_schema::gday_pimpl gday_p;
+ xml_schema::gmonth_pimpl gmonth_p;
+ xml_schema::gyear_pimpl gyear_p;
+ xml_schema::gmonth_day_pimpl gmonth_day_p;
+ xml_schema::gyear_month_pimpl gyear_month_p;
+ xml_schema::date_pimpl date_p;
+ xml_schema::time_pimpl time_p;
+ xml_schema::date_time_pimpl date_time_p;
+ xml_schema::duration_pimpl duration_p;
+
+ type_pimpl type_p;
+
+ type_p.parsers (any_type_p,
+ any_simple_type_p,
+ boolean_p,
+ byte_p,
+ unsigned_byte_p,
+ short_p,
+ unsigned_short_p,
+ int_p,
+ unsigned_int_p,
+ long_p,
+ unsigned_long_p,
+ integer_p,
+ negative_integer_p,
+ non_positive_integer_p,
+ positive_integer_p,
+ non_negative_integer_p,
+ float_p,
+ double_p,
+ decimal_p,
+ string_p,
+ normalized_string_p,
+ token_p,
+ name_p,
+ nmtoken_p,
+ nmtokens_p,
+ ncname_p,
+ id_p,
+ idref_p,
+ idrefs_p,
+ language_p,
+ uri_p,
+ qname_p,
+ base64_binary_p,
+ hex_binary_p,
+ gday_p,
+ gmonth_p,
+ gyear_p,
+ gmonth_day_p,
+ gyear_month_p,
+ date_p,
+ time_p,
+ date_time_p,
+ duration_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/built-in/output b/xsd-tests/cxx/parser/built-in/output
new file mode 100644
index 0000000..756abcd
--- /dev/null
+++ b/xsd-tests/cxx/parser/built-in/output
@@ -0,0 +1,164 @@
+{
+ any attribute x = 'x'
+ any text: '
+ '
+ start any element 'a'
+ any text: 'a'
+ end any element 'a'
+ any text: '
+ '
+ start any element 'any-type'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any-type'
+ any text: '
+ '
+}
+
+{
+ any text: '123abc'
+}
+
+1
+0
+1
+0
+0
+127
+-128
+123
+0
+255
+123
+0
+32767
+-32768
+-12345
+0
+65535
+12345
+0
+2147483647
+-2147483648
+-1234567890
+0
+4294967295
+1234567890
+0
+9223372036854775807
+-9223372036854775808
+-1234567890123456789
+0
+18446744073709551615
+12345678901234567890
+0
+2147483647
+-2147483648
+-1234567890
+-2147483648
+-1234567890
+0
+-2147483648
+-1234567890
+4294967295
+1234567890
+0
+4294967295
+1234567890
+0
+0
+-0
+inf
+-inf
+nan
+123.567
+123.567
+-1.23567e+07
+-4.5e-06
+0
+0
+-0
+inf
+-inf
+nan
+123.567
+123.567
+-1.23567e+07
+-4.5e-06
+0
+0
+-0
+123.567
+123.567
+-123.567
+'string space
+newline
+ '
+' string space newline '
+'string space newline'
+'as123:345-.abs'
+'1as123:345-.abs'
+'abc 123 '
+'as123_345-.abs'
+'as123_345-.abs'
+'abc'
+'a123'
+'as123_345-.abs'
+'abc a123 '
+'x'
+'en'
+'en-us'
+'one-two-three-four44-seven77-eight888'
+''
+'relative'
+'#id'
+'http://www.example.com/foo#bar'
+':schemaLocation'
+'xsi:schemaLocation'
+'12345abcjk'
+'a'
+'ab'
+'abc'
+''
+'12345abcjk'
+12+12:0
+1
+31
+15+0:0
+15-14:0
+10+12:0
+1
+12+0:0
+2007+12:0
+1
+-20000+0:0
+10-28+12:0
+12-31
+1-1+0:0
+2007-12+12:0
+-2007-10
+20007-10+0:0
+-20007-1
+2007-12-26+12:0
+-2007-10-15
+20007-12-31+0:0
+-20007-1-1
+12:46:23.456+12:0
+12:13:14
+12:13:14+0:0
+2007-12-26T12:13:14.123+12:0
+-2007-10-15T12:13:14
+20007-12-31T12:13:14+0:0
+-20007-1-1T12:13:14
+-P2007Y13M32DT25H61M61.123S
+P1Y0M0DT0H0M0S
+P0Y1M0DT0H0M0S
+P0Y0M1DT0H0M0S
+P0Y0M0DT1H0M0S
+P0Y0M0DT0H1M0S
+P0Y0M0DT0H0M1.1S
+P1Y0M0DT0H0M1S
diff --git a/xsd-tests/cxx/parser/built-in/test.xml b/xsd-tests/cxx/parser/built-in/test.xml
new file mode 100644
index 0000000..8d9332a
--- /dev/null
+++ b/xsd-tests/cxx/parser/built-in/test.xml
@@ -0,0 +1,199 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <any-type x="x">
+ <a>a</a>
+ <any-type x="xxx">aaa<a>bbb</a>ccc</any-type>
+ </any-type>
+
+ <any-simple-type>123abc</any-simple-type>
+
+ <boolean>1</boolean>
+ <boolean> 0 </boolean>
+ <boolean>true</boolean>
+ <boolean> false </boolean>
+
+ <byte>0</byte>
+ <byte>+127</byte>
+ <byte>-128</byte>
+ <byte> 123 </byte>
+
+ <unsigned-byte>0</unsigned-byte>
+ <unsigned-byte>255</unsigned-byte>
+ <unsigned-byte> 123 </unsigned-byte>
+
+ <short>0</short>
+ <short>+32767</short>
+ <short>-32768</short>
+ <short> -12345 </short>
+
+ <unsigned-short>0</unsigned-short>
+ <unsigned-short>65535</unsigned-short>
+ <unsigned-short> 12345 </unsigned-short>
+
+ <int>0</int>
+ <int>+2147483647</int>
+ <int>-2147483648</int>
+ <int> -1234567890 </int>
+
+ <unsigned-int>0</unsigned-int>
+ <unsigned-int>4294967295</unsigned-int>
+ <unsigned-int> 1234567890 </unsigned-int>
+
+ <long>0</long>
+ <long>+9223372036854775807</long>
+ <long>-9223372036854775808</long>
+ <long> -1234567890123456789 </long>
+
+ <unsigned-long>0</unsigned-long>
+ <unsigned-long>18446744073709551615</unsigned-long>
+ <unsigned-long> 12345678901234567890 </unsigned-long>
+
+ <integer>0</integer>
+ <integer> +2147483647 </integer>
+ <integer>-02147483648</integer>
+ <integer>-1234567890</integer>
+
+ <negative-integer>-02147483648</negative-integer>
+ <negative-integer> -1234567890 </negative-integer>
+
+ <non-positive-integer>0</non-positive-integer>
+ <non-positive-integer>-02147483648</non-positive-integer>
+ <non-positive-integer> -1234567890 </non-positive-integer>
+
+ <positive-integer>4294967295</positive-integer>
+ <positive-integer> +01234567890 </positive-integer>
+
+ <non-negative-integer>0</non-negative-integer>
+ <non-negative-integer>4294967295</non-negative-integer>
+ <non-negative-integer> +01234567890 </non-negative-integer>
+
+ <float>0</float>
+ <float>+0</float>
+ <float>-0</float>
+ <float>INF</float>
+ <float>-INF</float>
+ <float>NaN</float>
+ <float> 123.567 </float>
+ <float>+123.567</float>
+ <float>-123.567e5</float>
+ <float>-.45E-5</float>
+
+ <double>0</double>
+ <double>+0</double>
+ <double>-0</double>
+ <double>INF</double>
+ <double>-INF</double>
+ <double>NaN</double>
+ <double> 123.567 </double>
+ <double>+123.567</double>
+ <double>-123.567e5</double>
+ <double>-.45E-5</double>
+
+ <decimal>0</decimal>
+ <decimal>+0</decimal>
+ <decimal>-0</decimal>
+ <decimal> 123.567 </decimal>
+ <decimal>+123.567</decimal>
+ <decimal>-123.567</decimal>
+
+ <string>string space
+newline
+ </string>
+
+ <normalized-string> string space
+newline
+
+ </normalized-string>
+
+ <token> string space
+newline
+
+ </token>
+
+ <name> as123:345-.abs </name>
+
+ <nmtoken> 1as123:345-.abs </nmtoken>
+
+ <nmtokens> abc 123 </nmtokens>
+
+ <ncname> as123_345-.abs </ncname>
+
+ <id> as123_345-.abs </id>
+ <id> abc </id>
+ <id> a123 </id>
+
+ <idref> as123_345-.abs </idref>
+
+ <idrefs> abc a123 </idrefs>
+
+ <language> x </language>
+ <language> en </language>
+ <language> en-us </language>
+ <language>one-two-three-four44-seven77-eight888</language>
+
+ <uri> </uri>
+ <uri> relative </uri>
+ <uri> #id </uri>
+ <uri> http://www.example.com/foo#bar </uri>
+
+ <qname>schemaLocation</qname>
+ <qname>xsi:schemaLocation</qname>
+
+ <base64_binary> MTIzND
+ VhYmNqaw = =</base64_binary>
+ <base64_binary>YQ==</base64_binary>
+ <base64_binary>YWI=</base64_binary>
+ <base64_binary>YWJj</base64_binary>
+
+ <hex_binary> </hex_binary>
+ <hex_binary> 31323334356162636a6b </hex_binary>
+
+ <gday> ---12+12:00 </gday>
+ <gday>---01</gday>
+ <gday>---31</gday>
+ <gday>---15Z</gday>
+ <gday>---15-14:00</gday>
+
+ <gmonth> --10+12:00 </gmonth>
+ <gmonth>--01</gmonth>
+ <gmonth>--12Z</gmonth>
+
+ <gyear> 2007+12:00 </gyear>
+ <gyear>0001</gyear>
+ <gyear>-20000Z</gyear>
+
+ <gmonth_day> --10-28+12:00 </gmonth_day>
+ <gmonth_day>--12-31</gmonth_day>
+ <gmonth_day>--01-01Z</gmonth_day>
+
+ <gyear_month> 2007-12+12:00 </gyear_month>
+ <gyear_month>-2007-10</gyear_month>
+ <gyear_month>20007-10Z</gyear_month>
+ <gyear_month>-20007-01</gyear_month>
+
+ <date> 2007-12-26+12:00 </date>
+ <date>-2007-10-15</date>
+ <date>20007-12-31Z</date>
+ <date>-20007-01-01</date>
+
+ <time> 12:46:23.456+12:00 </time>
+ <time>12:13:14</time>
+ <time>12:13:14Z</time>
+
+ <date_time> 2007-12-26T12:13:14.123+12:00 </date_time>
+ <date_time>-2007-10-15T12:13:14</date_time>
+ <date_time>20007-12-31T12:13:14Z</date_time>
+ <date_time>-20007-01-01T12:13:14</date_time>
+
+ <duration> -P2007Y13M32DT25H61M61.123S </duration>
+ <duration>P1Y</duration>
+ <duration>P1M</duration>
+ <duration>P1D</duration>
+ <duration>PT1H</duration>
+ <duration>PT1M</duration>
+ <duration>PT1.1S</duration>
+ <duration>P1YT1S</duration>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/built-in/test.xsd b/xsd-tests/cxx/parser/built-in/test.xsd
new file mode 100644
index 0000000..9c00eb4
--- /dev/null
+++ b/xsd-tests/cxx/parser/built-in/test.xsd
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="type">
+ <sequence>
+ <element name="any-type" type="anyType" maxOccurs="unbounded"/>
+ <element name="any-simple-type" type="anySimpleType" maxOccurs="unbounded"/>
+
+ <element name="boolean" type="boolean" maxOccurs="unbounded"/>
+
+ <element name="byte" type="byte" maxOccurs="unbounded"/>
+ <element name="unsigned-byte" type="unsignedByte" maxOccurs="unbounded"/>
+ <element name="short" type="short" maxOccurs="unbounded"/>
+ <element name="unsigned-short" type="unsignedShort" maxOccurs="unbounded"/>
+ <element name="int" type="int" maxOccurs="unbounded"/>
+ <element name="unsigned-int" type="unsignedInt" maxOccurs="unbounded"/>
+ <element name="long" type="long" maxOccurs="unbounded"/>
+ <element name="unsigned-long" type="unsignedLong" maxOccurs="unbounded"/>
+
+ <element name="integer" type="integer" maxOccurs="unbounded"/>
+ <element name="negative-integer" type="negativeInteger" maxOccurs="unbounded"/>
+ <element name="non-positive-integer" type="nonPositiveInteger" maxOccurs="unbounded"/>
+ <element name="positive-integer" type="positiveInteger" maxOccurs="unbounded"/>
+ <element name="non-negative-integer" type="nonNegativeInteger" maxOccurs="unbounded"/>
+
+ <element name="float" type="float" maxOccurs="unbounded"/>
+ <element name="double" type="double" maxOccurs="unbounded"/>
+ <element name="decimal" type="decimal" maxOccurs="unbounded"/>
+
+ <element name="string" type="string" maxOccurs="unbounded"/>
+ <element name="normalized-string" type="normalizedString" maxOccurs="unbounded"/>
+ <element name="token" type="token" maxOccurs="unbounded"/>
+ <element name="name" type="Name" maxOccurs="unbounded"/>
+ <element name="nmtoken" type="NMTOKEN" maxOccurs="unbounded"/>
+ <element name="nmtokens" type="NMTOKENS" maxOccurs="unbounded"/>
+ <element name="ncname" type="NCName" maxOccurs="unbounded"/>
+ <element name="id" type="ID" maxOccurs="unbounded"/>
+ <element name="idref" type="IDREF" maxOccurs="unbounded"/>
+ <element name="idrefs" type="IDREFS" maxOccurs="unbounded"/>
+
+ <element name="language" type="language" maxOccurs="unbounded"/>
+ <element name="uri" type="anyURI" maxOccurs="unbounded"/>
+ <element name="qname" type="QName" maxOccurs="unbounded"/>
+
+ <element name="base64_binary" type="base64Binary" maxOccurs="unbounded"/>
+ <element name="hex_binary" type="hexBinary" maxOccurs="unbounded"/>
+
+ <element name="gday" type="gDay" maxOccurs="unbounded"/>
+ <element name="gmonth" type="gMonth" maxOccurs="unbounded"/>
+ <element name="gyear" type="gYear" maxOccurs="unbounded"/>
+ <element name="gmonth_day" type="gMonthDay" maxOccurs="unbounded"/>
+ <element name="gyear_month" type="gYearMonth" maxOccurs="unbounded"/>
+ <element name="date" type="date" maxOccurs="unbounded"/>
+ <element name="time" type="time" maxOccurs="unbounded"/>
+ <element name="date_time" type="dateTime" maxOccurs="unbounded"/>
+ <element name="duration" type="duration" maxOccurs="unbounded"/>
+
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/enumeration/buildfile b/xsd-tests/cxx/parser/enumeration/buildfile
new file mode 100644
index 0000000..05163df
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/enumeration/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} map{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --type-map $path($<[1]) \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
diff --git a/xsd-tests/cxx/parser/enumeration/driver.cxx b/xsd-tests/cxx/parser/enumeration/driver.cxx
new file mode 100644
index 0000000..4776ee2
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/driver.cxx
@@ -0,0 +1,81 @@
+// file : cxx/parser/enumeration/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test xsd:enumeration parsing.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace xml_schema;
+
+struct digit_pimpl: test::digit_pskel, int_pimpl
+{
+};
+
+struct gender_pimpl: test::gender_pskel, string_pimpl
+{
+ virtual ::gender
+ post_gender ()
+ {
+ std::string str (post_string ());
+
+ if (str == "male")
+ return male;
+ else
+ return female;
+ }
+};
+
+struct type_pimpl: test::type_pskel
+{
+ virtual void
+ digit (int i)
+ {
+ cout << i << endl;
+ }
+
+ virtual void
+ gender (::gender g)
+ {
+ cout << g << endl;
+ }
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ digit_pimpl digit_p;
+ gender_pimpl gender_p;
+ type_pimpl type_p;
+
+ type_p.parsers (digit_p, gender_p);
+
+ document doc_p (type_p, "test", "root");
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/enumeration/gender.hxx b/xsd-tests/cxx/parser/enumeration/gender.hxx
new file mode 100644
index 0000000..a2e5cd8
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/gender.hxx
@@ -0,0 +1,13 @@
+// file : tests/cxx/parser/enumeration/gender.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef GENDER_HXX
+#define GENDER_HXX
+
+enum gender
+{
+ male,
+ female
+};
+
+#endif // GENDER_HXX
diff --git a/xsd-tests/cxx/parser/enumeration/output b/xsd-tests/cxx/parser/enumeration/output
new file mode 100644
index 0000000..16db301
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/output
@@ -0,0 +1,3 @@
+1
+0
+1
diff --git a/xsd-tests/cxx/parser/enumeration/test.map b/xsd-tests/cxx/parser/enumeration/test.map
new file mode 100644
index 0000000..f8868d6
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/test.map
@@ -0,0 +1,7 @@
+namespace test
+{
+ include "gender.hxx";
+
+ digit int int;
+ gender ::gender ::gender;
+}
diff --git a/xsd-tests/cxx/parser/enumeration/test.xml b/xsd-tests/cxx/parser/enumeration/test.xml
new file mode 100644
index 0000000..a6fa893
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/test.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <digit>1</digit>
+
+ <gender>male</gender>
+ <gender>female</gender>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/enumeration/test.xsd b/xsd-tests/cxx/parser/enumeration/test.xsd
new file mode 100644
index 0000000..ded3a18
--- /dev/null
+++ b/xsd-tests/cxx/parser/enumeration/test.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="digit">
+ <restriction base="int">
+ <enumeration value="0"/>
+ <enumeration value="1"/>
+ <enumeration value="2"/>
+ <enumeration value="3"/>
+ <enumeration value="4"/>
+ <enumeration value="5"/>
+ <enumeration value="6"/>
+ <enumeration value="7"/>
+ <enumeration value="8"/>
+ <enumeration value="9"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="gender">
+ <restriction base="string">
+ <enumeration value="male"/>
+ <enumeration value="female"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="digit" type="t:digit"/>
+ <element name="gender" type="t:gender"/>
+ </choice>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/generated-impl/.gitignore b/xsd-tests/cxx/parser/generated-impl/.gitignore
new file mode 100644
index 0000000..21b434c
--- /dev/null
+++ b/xsd-tests/cxx/parser/generated-impl/.gitignore
@@ -0,0 +1,2 @@
+test-pimpl.?xx
+test-driver.?xx
diff --git a/xsd-tests/cxx/parser/generated-impl/buildfile b/xsd-tests/cxx/parser/generated-impl/buildfile
new file mode 100644
index 0000000..8710a77
--- /dev/null
+++ b/xsd-tests/cxx/parser/generated-impl/buildfile
@@ -0,0 +1,31 @@
+# file : cxx/parser/generated-impl/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx ixx cxx}{test-pskel} \
+ {hxx cxx}{test-pimpl} \
+ { cxx}{test-driver} \
+ $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel} \
+ {hxx cxx}{test-pimpl} \
+ { cxx}{test-driver}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --generate-print-impl \
+ --generate-test-driver \
+ --force-overwrite \
+ --output-dir $out_base \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/generated-impl/output b/xsd-tests/cxx/parser/generated-impl/output
new file mode 100644
index 0000000..7c58647
--- /dev/null
+++ b/xsd-tests/cxx/parser/generated-impl/output
@@ -0,0 +1,122 @@
+gender: male
+foo: foo
+gender: male
+int: 0
+int: 1
+int: 2
+int: 3
+foo: foo
+int: 3
+int: 2
+int: 1
+int: 0
+union: 9
+foo: foo
+union: string
+x: x
+a: aaa
+x: x
+y: y
+a: aaa
+b: bbb
+boolean: 1
+boolean: 0
+boolean: 1
+boolean: 0
+byte: 0
+byte: 123
+byte: -123
+unsigned-byte: 0
+unsigned-byte: 123
+short: 0
+short: -1234
+short: 1234
+unsigned-short: 0
+unsigned-short: 1234
+int: 0
+int: -12345
+int: 12345
+unsigned-int: 0
+unsigned-int: 12345
+long: 0
+long: -123456
+long: 123456
+unsigned-long: 0
+unsigned-long: 123456
+integer: 0
+integer: -123456
+integer: 123456
+negative-integer: -123456
+non-positive-integer: 0
+non-positive-integer: -123456
+positive-integer: 123456
+non-negative-integer: 0
+non-negative-integer: 123456
+float: 0
+float: 1.123
+float: -1.123
+double: 0
+double: 1.1234
+double: -1.1234
+decimal: 0
+decimal: 1.1234
+decimal: -1.1234
+string: string space newline
+normalized-string: string space newline
+token: string space newline
+name: as123:345-.abs
+nmtoken: 1as123:345-.abs
+nmtokens: abc 123
+ncname: as123_345-.abs
+id: abc
+id: a123
+idref: abc
+idrefs: abc a123
+language: en
+language: en-us
+uri: http://www.example.com/foo#bar
+qname: schemaLocation
+qname: xsi:schemaLocation
+base64_binary: 10 bytes
+base64_binary: 1 bytes
+base64_binary: 2 bytes
+base64_binary: 3 bytes
+hex_binary: 0 bytes
+hex_binary: 10 bytes
+gday: ---12+12:0
+gday: ---1
+gday: ---31
+gday: ---15+0:0
+gday: ---15-14:0
+gmonth: --10+12:0
+gmonth: --1
+gmonth: --12+0:0
+gyear: 2007+12:0
+gyear: 1
+gyear: -20000+0:0
+gmonth_day: --10-28+12:0
+gmonth_day: --12-31
+gmonth_day: --1-1+0:0
+gyear_month: 2007-12+12:0
+gyear_month: -2007-10
+gyear_month: 20007-10+0:0
+gyear_month: -20007-1
+date: 2007-12-26+12:0
+date: -2007-10-15
+date: 20007-12-31+0:0
+date: -20007-1-1
+time: 12:46:23.456+12:0
+time: 12:13:14
+time: 12:13:14+0:0
+date_time: 2007-12-26T12:13:14.123+12:0
+date_time: -2007-10-15T12:13:14
+date_time: 20007-12-31T12:13:14+0:0
+date_time: -20007-1-1T12:13:14
+duration: -P2007Y13M32DT25H61M61.123S
+duration: P1Y0M0DT0H0M0S
+duration: P0Y1M0DT0H0M0S
+duration: P0Y0M1DT0H0M0S
+duration: P0Y0M0DT1H0M0S
+duration: P0Y0M0DT0H1M0S
+duration: P0Y0M0DT0H0M1.1S
+duration: P1Y0M0DT0H0M1S
diff --git a/xsd-tests/cxx/parser/generated-impl/test.xml b/xsd-tests/cxx/parser/generated-impl/test.xml
new file mode 100644
index 0000000..2f29a39
--- /dev/null
+++ b/xsd-tests/cxx/parser/generated-impl/test.xml
@@ -0,0 +1,168 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <gender>male</gender>
+ <gender-extension foo="foo">male</gender-extension>
+
+ <list>0 1 2 3</list>
+ <list-extension foo="foo">3 2 1 0</list-extension>
+
+ <union>9</union>
+ <union-extension foo="foo">string</union-extension>
+
+ <complex x="x">
+ <a>aaa</a>
+ </complex>
+
+ <complex-extension x="x" y="y">
+ <a>aaa</a>
+ <b>bbb</b>
+ </complex-extension>
+
+ <any-type>aaa<b>bbb</b>ccc</any-type>
+ <any-simple-type>abc123</any-simple-type>
+
+ <boolean>1</boolean>
+ <boolean> 0 </boolean>
+ <boolean>true</boolean>
+ <boolean> false </boolean>
+
+ <byte>0</byte>
+ <byte>123</byte>
+ <byte>-123</byte>
+
+ <unsigned-byte>0</unsigned-byte>
+ <unsigned-byte>123</unsigned-byte>
+
+ <short>0</short>
+ <short>-1234</short>
+ <short>1234</short>
+
+ <unsigned-short>0</unsigned-short>
+ <unsigned-short>1234</unsigned-short>
+
+ <int>0</int>
+ <int>-12345</int>
+ <int>12345</int>
+
+ <unsigned-int>0</unsigned-int>
+ <unsigned-int>12345</unsigned-int>
+
+ <long>0</long>
+ <long>-123456</long>
+ <long>123456</long>
+
+ <unsigned-long>0</unsigned-long>
+ <unsigned-long>123456</unsigned-long>
+
+ <integer>0</integer>
+ <integer>-123456</integer>
+ <integer>123456</integer>
+
+ <negative-integer>-123456</negative-integer>
+
+ <non-positive-integer>0</non-positive-integer>
+ <non-positive-integer>-123456</non-positive-integer>
+
+ <positive-integer>123456</positive-integer>
+
+ <non-negative-integer>0</non-negative-integer>
+ <non-negative-integer>123456</non-negative-integer>
+
+ <float>0</float>
+ <float>1.123</float>
+ <float>-1.123</float>
+
+ <double>0</double>
+ <double>1.1234</double>
+ <double>-1.1234</double>
+
+ <decimal>0</decimal>
+ <decimal>1.1234</decimal>
+ <decimal>-1.1234</decimal>
+
+ <string>string space newline</string>
+
+ <normalized-string>string space newline</normalized-string>
+
+ <token> string space newline</token>
+
+ <name>as123:345-.abs</name>
+
+ <nmtoken>1as123:345-.abs</nmtoken>
+
+ <nmtokens>abc 123</nmtokens>
+
+ <ncname>as123_345-.abs</ncname>
+
+ <id>abc</id>
+ <id>a123</id>
+
+ <idref>abc</idref>
+
+ <idrefs>abc a123</idrefs>
+
+ <language>en</language>
+ <language>en-us</language>
+
+ <uri>http://www.example.com/foo#bar</uri>
+
+ <qname>schemaLocation</qname>
+ <qname>xsi:schemaLocation</qname>
+
+ <base64_binary>MTIzNDVhYmNqaw==</base64_binary>
+ <base64_binary>YQ==</base64_binary>
+ <base64_binary>YWI=</base64_binary>
+ <base64_binary>YWJj</base64_binary>
+
+ <hex_binary></hex_binary>
+ <hex_binary>31323334356162636a6b</hex_binary>
+
+ <gday>---12+12:00</gday>
+ <gday>---01</gday>
+ <gday>---31</gday>
+ <gday>---15Z</gday>
+ <gday>---15-14:00</gday>
+
+ <gmonth>--10+12:00</gmonth>
+ <gmonth>--01</gmonth>
+ <gmonth>--12Z</gmonth>
+
+ <gyear>2007+12:00</gyear>
+ <gyear>0001</gyear>
+ <gyear>-20000Z</gyear>
+
+ <gmonth_day>--10-28+12:00</gmonth_day>
+ <gmonth_day>--12-31</gmonth_day>
+ <gmonth_day>--01-01Z</gmonth_day>
+
+ <gyear_month>2007-12+12:00</gyear_month>
+ <gyear_month>-2007-10</gyear_month>
+ <gyear_month>20007-10Z</gyear_month>
+ <gyear_month>-20007-01</gyear_month>
+
+ <date>2007-12-26+12:00</date>
+ <date>-2007-10-15</date>
+ <date>20007-12-31Z</date>
+ <date>-20007-01-01</date>
+
+ <time>12:46:23.456+12:00</time>
+ <time>12:13:14</time>
+ <time>12:13:14Z</time>
+
+ <date_time>2007-12-26T12:13:14.123+12:00</date_time>
+ <date_time>-2007-10-15T12:13:14</date_time>
+ <date_time>20007-12-31T12:13:14Z</date_time>
+ <date_time>-20007-01-01T12:13:14</date_time>
+
+ <duration>-P2007Y13M32DT25H61M61.123S</duration>
+ <duration>P1Y</duration>
+ <duration>P1M</duration>
+ <duration>P1D</duration>
+ <duration>PT1H</duration>
+ <duration>PT1M</duration>
+ <duration>PT1.1S</duration>
+ <duration>P1YT1S</duration>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/generated-impl/test.xsd b/xsd-tests/cxx/parser/generated-impl/test.xsd
new file mode 100644
index 0000000..7bc8f23
--- /dev/null
+++ b/xsd-tests/cxx/parser/generated-impl/test.xsd
@@ -0,0 +1,142 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- enum -->
+
+ <simpleType name="gender">
+ <restriction base="string">
+ <enumeration value="male"/>
+ <enumeration value="female"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="gender-extension">
+ <simpleContent>
+ <extension base="t:gender">
+ <attribute name="foo" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <!-- list -->
+
+ <simpleType name="list">
+ <list itemType="int"/>
+ </simpleType>
+
+ <complexType name="list-extension">
+ <simpleContent>
+ <extension base="t:list">
+ <attribute name="foo" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <!-- union -->
+
+ <simpleType name="union">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <complexType name="union-extension">
+ <simpleContent>
+ <extension base="t:union">
+ <attribute name="foo" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <!-- complex -->
+
+ <complexType name="complex">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <complexType name="complex-extension">
+ <complexContent>
+ <extension base="t:complex">
+ <sequence>
+ <element name="b" type="string"/>
+ </sequence>
+ <attribute name="y" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="gender" type="t:gender"/>
+ <element name="gender-extension" type="t:gender-extension"/>
+
+ <element name="list" type="t:list"/>
+ <element name="list-extension" type="t:list-extension"/>
+
+ <element name="union" type="t:union"/>
+ <element name="union-extension" type="t:union-extension"/>
+
+ <element name="complex" type="t:complex"/>
+ <element name="complex-extension" type="t:complex-extension"/>
+
+ <!-- Built-in types. -->
+
+ <element name="any-type" type="anyType" maxOccurs="unbounded"/>
+ <element name="any-simple-type" type="anySimpleType" maxOccurs="unbounded"/>
+
+ <element name="boolean" type="boolean" maxOccurs="unbounded"/>
+
+ <element name="byte" type="byte" maxOccurs="unbounded"/>
+ <element name="unsigned-byte" type="unsignedByte" maxOccurs="unbounded"/>
+ <element name="short" type="short" maxOccurs="unbounded"/>
+ <element name="unsigned-short" type="unsignedShort" maxOccurs="unbounded"/>
+ <element name="int" type="int" maxOccurs="unbounded"/>
+ <element name="unsigned-int" type="unsignedInt" maxOccurs="unbounded"/>
+ <element name="long" type="long" maxOccurs="unbounded"/>
+ <element name="unsigned-long" type="unsignedLong" maxOccurs="unbounded"/>
+
+ <element name="integer" type="integer" maxOccurs="unbounded"/>
+ <element name="negative-integer" type="negativeInteger" maxOccurs="unbounded"/>
+ <element name="non-positive-integer" type="nonPositiveInteger" maxOccurs="unbounded"/>
+ <element name="positive-integer" type="positiveInteger" maxOccurs="unbounded"/>
+ <element name="non-negative-integer" type="nonNegativeInteger" maxOccurs="unbounded"/>
+
+ <element name="float" type="float" maxOccurs="unbounded"/>
+ <element name="double" type="double" maxOccurs="unbounded"/>
+ <element name="decimal" type="decimal" maxOccurs="unbounded"/>
+
+ <element name="string" type="string" maxOccurs="unbounded"/>
+ <element name="normalized-string" type="normalizedString" maxOccurs="unbounded"/>
+ <element name="token" type="token" maxOccurs="unbounded"/>
+ <element name="name" type="Name" maxOccurs="unbounded"/>
+ <element name="nmtoken" type="NMTOKEN" maxOccurs="unbounded"/>
+ <element name="nmtokens" type="NMTOKENS" maxOccurs="unbounded"/>
+ <element name="ncname" type="NCName" maxOccurs="unbounded"/>
+ <element name="id" type="ID" maxOccurs="unbounded"/>
+ <element name="idref" type="IDREF" maxOccurs="unbounded"/>
+ <element name="idrefs" type="IDREFS" maxOccurs="unbounded"/>
+
+ <element name="language" type="language" maxOccurs="unbounded"/>
+ <element name="uri" type="anyURI" maxOccurs="unbounded"/>
+ <element name="qname" type="QName" maxOccurs="unbounded"/>
+
+ <element name="base64_binary" type="base64Binary" maxOccurs="unbounded"/>
+ <element name="hex_binary" type="hexBinary" maxOccurs="unbounded"/>
+
+ <element name="gday" type="gDay" maxOccurs="unbounded"/>
+ <element name="gmonth" type="gMonth" maxOccurs="unbounded"/>
+ <element name="gyear" type="gYear" maxOccurs="unbounded"/>
+ <element name="gmonth_day" type="gMonthDay" maxOccurs="unbounded"/>
+ <element name="gyear_month" type="gYearMonth" maxOccurs="unbounded"/>
+ <element name="date" type="date" maxOccurs="unbounded"/>
+ <element name="time" type="time" maxOccurs="unbounded"/>
+ <element name="date_time" type="dateTime" maxOccurs="unbounded"/>
+ <element name="duration" type="duration" maxOccurs="unbounded"/>
+
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/list/buildfile b/xsd-tests/cxx/parser/list/buildfile
new file mode 100644
index 0000000..426101e
--- /dev/null
+++ b/xsd-tests/cxx/parser/list/buildfile
@@ -0,0 +1,23 @@
+# file : cxx/parser/list/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/list/driver.cxx b/xsd-tests/cxx/parser/list/driver.cxx
new file mode 100644
index 0000000..382da5b
--- /dev/null
+++ b/xsd-tests/cxx/parser/list/driver.cxx
@@ -0,0 +1,105 @@
+// file : cxx/parser/list/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test xsd:list parsing.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct string_list_pimpl: string_list_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ item (string const& v)
+ {
+ cout << " '" << v << "'" << endl;
+ }
+
+ virtual void
+ post_string_list ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct string_list_lang_pimpl: string_list_lang_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ item (string const& v)
+ {
+ cout << " '" << v << "'" << endl;
+ }
+
+ virtual void
+ lang (string const& v)
+ {
+ cout << " lang: '" << v << "'" << endl;
+ }
+
+ virtual void
+ post_string_list_lang ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ string_list_pimpl string_list_p;
+ string_list_lang_pimpl string_list_lang_p;
+ type_pimpl type_p;
+
+ string_list_p.parsers (string_p);
+ string_list_lang_p.parsers (string_p, string_p);
+ type_p.parsers (string_list_p, string_list_lang_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/list/output b/xsd-tests/cxx/parser/list/output
new file mode 100644
index 0000000..3642c4d
--- /dev/null
+++ b/xsd-tests/cxx/parser/list/output
@@ -0,0 +1,26 @@
+{
+}
+
+{
+}
+
+{
+}
+
+{
+ 'one'
+}
+
+{
+ 'one'
+ 'two'
+ 'three'
+}
+
+{
+ lang: 'en'
+ 'one'
+ 'two'
+ 'three'
+}
+
diff --git a/xsd-tests/cxx/parser/list/test.xml b/xsd-tests/cxx/parser/list/test.xml
new file mode 100644
index 0000000..52229db
--- /dev/null
+++ b/xsd-tests/cxx/parser/list/test.xml
@@ -0,0 +1,25 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <string-list/>
+
+ <string-list> </string-list>
+
+ <string-list>
+
+ </string-list>
+
+ <string-list>one</string-list>
+
+ <string-list>
+ one two
+ three
+ </string-list>
+
+ <string-list-lang lang="en">
+ one two
+ three
+ </string-list-lang>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/list/test.xsd b/xsd-tests/cxx/parser/list/test.xsd
new file mode 100644
index 0000000..79bd084
--- /dev/null
+++ b/xsd-tests/cxx/parser/list/test.xsd
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="string-list">
+ <list itemType="string"/>
+ </simpleType>
+
+ <complexType name="string-list-lang">
+ <simpleContent>
+ <extension base="t:string-list">
+ <attribute name="lang" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="string-list" type="t:string-list"/>
+ <element name="string-list-lang" type="t:string-list-lang"/>
+ </choice>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/buildfile b/xsd-tests/cxx/parser/name-clash/inheritance/buildfile
new file mode 100644
index 0000000..4bd7b48
--- /dev/null
+++ b/xsd-tests/cxx/parser/name-clash/inheritance/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/name-clash/inheritance/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx b/xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx
new file mode 100644
index 0000000..9e9b905
--- /dev/null
+++ b/xsd-tests/cxx/parser/name-clash/inheritance/driver.cxx
@@ -0,0 +1,62 @@
+// file : cxx/parser/name-clash/inheritance/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test for name clashes across inheritance hierarchy.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct derived_pimpl: derived_pskel
+{
+ virtual void
+ e (string const& v)
+ {
+ cout << "e: " << v << endl;
+ }
+
+ virtual void
+ e1 (string const& v)
+ {
+ cout << "e1: " << v << endl;
+ }
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ derived_pimpl derived_p;
+
+ derived_p.parsers (string_p, string_p);
+
+ xml_schema::document doc_p (derived_p, "test", "root");
+
+ derived_p.pre ();
+ doc_p.parse (argv[1]);
+ derived_p.post_derived ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/output b/xsd-tests/cxx/parser/name-clash/inheritance/output
new file mode 100644
index 0000000..4efd51b
--- /dev/null
+++ b/xsd-tests/cxx/parser/name-clash/inheritance/output
@@ -0,0 +1,2 @@
+e: e
+e1: e1
diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/test.xml b/xsd-tests/cxx/parser/name-clash/inheritance/test.xml
new file mode 100644
index 0000000..8c17101
--- /dev/null
+++ b/xsd-tests/cxx/parser/name-clash/inheritance/test.xml
@@ -0,0 +1,8 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <e>e</e>
+ <e>e1</e>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/name-clash/inheritance/test.xsd b/xsd-tests/cxx/parser/name-clash/inheritance/test.xsd
new file mode 100644
index 0000000..62a782e
--- /dev/null
+++ b/xsd-tests/cxx/parser/name-clash/inheritance/test.xsd
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="base">
+ <sequence>
+ <element name="e" type="string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="derived">
+ <complexContent>
+ <extension base="t:base">
+ <sequence>
+ <element name="e" type="string"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="root" type="t:derived"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/buildfile b/xsd-tests/cxx/parser/polymorphism/recursive/buildfile
new file mode 100644
index 0000000..629645b
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/polymorphism/recursive/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-polymorphic \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx b/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx
new file mode 100644
index 0000000..26793a0
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx
@@ -0,0 +1,68 @@
+// file : cxx/parser/polymorphism/recursive/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test polymorphic recursive parsing.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+#include "test-pimpl.hxx"
+
+using namespace std;
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::int_pimpl int_p;
+
+ root_pimpl root_p;
+ expression_pimpl expression_p;
+ recursive_pimpl recursive_p;
+ value_a_pimpl value_a_p;
+ value_b_pimpl value_b_p;
+
+ xml_schema::parser_map_impl expression_map;
+
+ // Connect the parsers together.
+ //
+ root_p.parsers (expression_p);
+ expression_map.insert(value_a_p);
+ expression_map.insert(value_b_p);
+ expression_map.insert(recursive_p);
+
+ root_p.expression_parser(expression_map);
+
+ recursive_p.parsers(expression_p);
+ recursive_p.expression_parser(expression_map);
+
+ value_a_p.parsers(int_p);
+ value_b_p.parsers(int_p);
+
+ xml_schema::document doc_p (root_p, "test", "root", true);
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ root_p.post_root ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/output b/xsd-tests/cxx/parser/polymorphism/recursive/output
new file mode 100644
index 0000000..28a835f
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/output
@@ -0,0 +1,22 @@
+root start
+recursive start
+value_a begin
+value->constant
+value: post_expression override
+value_a: post_value override
+value_a end
+recursive->expression event
+recursive start
+value_b begin
+value->constant
+value: post_expression override
+value_b: post_value override
+value_b end
+recursive->expression event
+recursive: post_expression override
+recursive end
+recursive->expression event
+recursive: post_expression override
+recursive end
+root->expression
+root end
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx
new file mode 100644
index 0000000..7c7f410
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx
@@ -0,0 +1,147 @@
+// file : cxx/parser/polymorphism/recursive/pimpl.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <iostream>
+
+#include "test-pimpl.hxx"
+
+using namespace std;
+
+namespace test
+{
+ // root_pimpl
+ //
+
+ void root_pimpl::
+ pre ()
+ {
+ cout << "root start" << endl;
+ }
+
+ void root_pimpl::
+ expression ()
+ {
+ cout << "root->expression" << endl;
+ }
+
+ void root_pimpl::
+ post_root ()
+ {
+ cout << "root end" << endl;
+ }
+
+ // expression_pimpl
+ //
+
+ void expression_pimpl::
+ pre ()
+ {
+ cout << "expression begin" << endl;
+ }
+
+ void expression_pimpl::
+ post_expression ()
+ {
+ cout << "expression end" << endl;
+ }
+
+ // recursive_pimpl
+ //
+
+ void recursive_pimpl::
+ pre ()
+ {
+ cout << "recursive start" << endl;
+ }
+
+ void recursive_pimpl::
+ expression ()
+ {
+ cout << "recursive->expression event" << endl;
+ }
+
+ void recursive_pimpl::
+ post_expression ()
+ {
+ cout << "recursive: post_expression override" << endl;
+ post_recursive ();
+ }
+
+ void recursive_pimpl::
+ post_recursive ()
+ {
+ cout << "recursive end" << endl;
+ }
+
+ // value_pimpl
+ //
+
+ void value_pimpl::
+ pre ()
+ {
+ cout << "value begin" << endl;
+ }
+
+ void value_pimpl::
+ constant (int)
+ {
+ cout << "value->constant" << endl;
+ }
+
+ void value_pimpl::
+ post_expression ()
+ {
+ cout << "value: post_expression override" << endl;
+ post_value ();
+ }
+
+ void value_pimpl::
+ post_value ()
+ {
+ cout << "value end" << endl;
+ }
+
+ // value_a_pimpl
+ //
+
+ void value_a_pimpl::
+ pre ()
+ {
+ cout << "value_a begin" << endl;
+ }
+
+ void value_a_pimpl::
+ post_value ()
+ {
+ cout << "value_a: post_value override" << endl;
+ post_value_a ();
+ }
+
+ void value_a_pimpl::
+ post_value_a ()
+ {
+ cout << "value_a end" << endl;
+ }
+
+ // value_b_pimpl
+ //
+
+ void value_b_pimpl::
+ pre ()
+ {
+ cout << "value_b begin" << endl;
+ }
+
+ void value_b_pimpl::
+ post_value ()
+ {
+ cout << "value_b: post_value override" << endl;
+ post_value_b ();
+ }
+
+ void value_b_pimpl::
+ post_value_b ()
+ {
+ cout << "value_b end" << endl;
+ }
+}
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx
new file mode 100644
index 0000000..928b880
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx
@@ -0,0 +1,94 @@
+// file : cxx/parser/polymorphism/recursive/pimpl.hxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef TEST_PIMPL_HXX
+#define TEST_PIMPL_HXX
+
+#include "test-pskel.hxx"
+
+namespace test
+{
+ class root_pimpl: public virtual root_pskel
+ {
+ public:
+ virtual void
+ pre ();
+
+ virtual void
+ expression ();
+
+ virtual void
+ post_root ();
+ };
+
+ class expression_pimpl: public virtual expression_pskel
+ {
+ public:
+ virtual void
+ pre ();
+
+ virtual void
+ post_expression ();
+ };
+
+ class recursive_pimpl: public virtual recursive_pskel,
+ public expression_pimpl
+ {
+ public:
+ virtual void
+ pre ();
+
+ virtual void
+ expression ();
+
+ virtual void
+ post_expression ();
+
+ virtual void
+ post_recursive ();
+ };
+
+ class value_pimpl: public virtual value_pskel, public expression_pimpl
+ {
+ public:
+ virtual void
+ pre ();
+
+ virtual void
+ constant (int);
+
+ virtual void
+ post_expression ();
+
+ virtual void
+ post_value ();
+ };
+
+ class value_a_pimpl: public virtual value_a_pskel, public value_pimpl
+ {
+ public:
+ virtual void
+ pre ();
+
+ virtual void
+ post_value ();
+
+ virtual void
+ post_value_a ();
+ };
+
+ class value_b_pimpl: public virtual value_b_pskel, public value_pimpl
+ {
+ public:
+ virtual void
+ pre ();
+
+ virtual void
+ post_value ();
+
+ virtual void
+ post_value_b ();
+ };
+}
+
+#endif // TEST_PIMPL_HXX
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test.xml b/xsd-tests/cxx/parser/polymorphism/recursive/test.xml
new file mode 100644
index 0000000..42035ba
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/test.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root xmlns="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+ <recursive>
+ <value-a>
+ <constant>1</constant>
+ </value-a>
+ <recursive>
+ <value-b>
+ <constant>2</constant>
+ </value-b>
+ </recursive>
+ </recursive>
+</root>
diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd b/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd
new file mode 100644
index 0000000..affcc8a
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="test"
+ targetNamespace="test"
+ elementFormDefault="qualified">
+
+ <element name="root" type="t:root"/>
+ <complexType name="root">
+ <sequence>
+ <element ref="t:expression" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="expression" type="t:expression" abstract="true"/>
+ <complexType name="expression" abstract="true"/>
+
+ <element name="recursive" type="t:recursive" substitutionGroup="t:expression"/>
+ <complexType name="recursive">
+ <complexContent>
+ <extension base="t:expression">
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="t:expression"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="value" type="t:value" abstract="true" substitutionGroup="t:expression"/>
+ <complexType name="value" abstract="true">
+ <complexContent>
+ <extension base="t:expression">
+ <sequence>
+ <element name="constant" type="int"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="value-a" type="t:value-a" substitutionGroup="t:expression"/>
+ <complexType name="value-a">
+ <complexContent>
+ <extension base="t:value"/>
+ </complexContent>
+ </complexType>
+
+ <element name="value-b" type="t:value-b" substitutionGroup="t:expression"/>
+ <complexType name="value-b">
+ <complexContent>
+ <extension base="t:value"/>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/buildfile b/xsd-tests/cxx/parser/polymorphism/same-type/buildfile
new file mode 100644
index 0000000..d98e917
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/same-type/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/polymorphism/same-type/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-polymorphic \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx b/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx
new file mode 100644
index 0000000..6da4a0a
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx
@@ -0,0 +1,62 @@
+// file : cxx/parser/polymorphism/same-type/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test substitution group and xsi:type that don't change the type.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct base_pimpl: base_pskel
+{
+ virtual void
+ a (string const& v)
+ {
+ cout << v << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ base_pimpl base_p;
+ type_pimpl type_p;
+
+ base_p.parsers (string_p);
+ type_p.parsers (base_p);
+
+ xml_schema::document doc_p (type_p, "test", "root", true);
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/output b/xsd-tests/cxx/parser/polymorphism/same-type/output
new file mode 100644
index 0000000..d418277
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/same-type/output
@@ -0,0 +1,4 @@
+a1
+a2
+a3
+a4
diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/test.xml b/xsd-tests/cxx/parser/polymorphism/same-type/test.xml
new file mode 100644
index 0000000..f8b6d1e
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/same-type/test.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <t:base><a>a1</a></t:base>
+ <t:derived><a>a2</a></t:derived>
+ <t:base xsi:type="t:base"><a>a3</a></t:base>
+ <t:derived xsi:type="t:base"><a>a4</a></t:derived>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd b/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd
new file mode 100644
index 0000000..a4157d3
--- /dev/null
+++ b/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="base">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="base" type="t:base"/>
+ <element name="derived" type="t:base" substitutionGroup="t:base"/>
+
+ <complexType name="type">
+ <sequence>
+ <element ref="t:base" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/recursive/buildfile b/xsd-tests/cxx/parser/recursive/buildfile
new file mode 100644
index 0000000..237855c
--- /dev/null
+++ b/xsd-tests/cxx/parser/recursive/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/recursive/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/recursive/driver.cxx b/xsd-tests/cxx/parser/recursive/driver.cxx
new file mode 100644
index 0000000..c93fd35
--- /dev/null
+++ b/xsd-tests/cxx/parser/recursive/driver.cxx
@@ -0,0 +1,139 @@
+// file : cxx/parser/recursive/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test recursive parser invocation.
+//
+
+#include <iostream>
+#include <string>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+
+struct sub_pimpl: sub_type_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "sub::pre" << endl;
+ }
+
+ virtual void
+ sub ()
+ {
+ cout << "sub::sub" << endl;
+ }
+
+ virtual void
+ sub2 ()
+ {
+ cout << "sub::sub2" << endl;
+ }
+
+ virtual void
+ name (string const& n)
+ {
+ cout << "sub::name: " << n << endl;
+ }
+
+ virtual void
+ post_sub_type ()
+ {
+ cout << "sub::post" << endl;
+ }
+};
+
+struct indir_pimpl: indir_type_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "indir::pre" << endl;
+ }
+
+ virtual void
+ sub ()
+ {
+ cout << "indir::sub" << endl;
+ }
+
+ virtual void
+ name (string const& n)
+ {
+ cout << "indir::name: " << n << endl;
+ }
+
+ virtual void
+ post_indir_type ()
+ {
+ cout << "indir::post" << endl;
+ }
+};
+
+struct test_pimpl: test_type_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "test::pre" << endl;
+ }
+
+ virtual void
+ sub ()
+ {
+ cout << "test::sub" << endl;
+ }
+
+ virtual void
+ name (string const& n)
+ {
+ cout << "test::name: " << n << endl;
+ }
+
+ virtual void
+ post_test_type ()
+ {
+ cout << "test::post" << endl;
+ }
+};
+
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+
+ sub_pimpl sub_p;
+ indir_pimpl indir_p;
+ test_pimpl test_p;
+
+ sub_p.parsers (sub_p, indir_p, sub_p, string_p);
+ indir_p.parsers (sub_p, string_p);
+ test_p.parsers (sub_p, string_p);
+
+ xml_schema::document doc_p (test_p, "test");
+
+ test_p.pre ();
+ doc_p.parse (argv[1]);
+ test_p.post_test_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/recursive/output b/xsd-tests/cxx/parser/recursive/output
new file mode 100644
index 0000000..f26fb72
--- /dev/null
+++ b/xsd-tests/cxx/parser/recursive/output
@@ -0,0 +1,22 @@
+test::pre
+test::name: testName
+sub::pre
+sub::name: subName
+sub::pre
+sub::name: sub-subName
+sub::post
+sub::sub
+indir::pre
+indir::name: sub-indirName
+sub::pre
+sub::name: sub-indir-subName
+sub::post
+indir::sub
+indir::post
+sub::pre
+sub::name: sub-sub2Name
+sub::post
+sub::sub2
+sub::post
+test::sub
+test::post
diff --git a/xsd-tests/cxx/parser/recursive/test.xml b/xsd-tests/cxx/parser/recursive/test.xml
new file mode 100644
index 0000000..f6c219d
--- /dev/null
+++ b/xsd-tests/cxx/parser/recursive/test.xml
@@ -0,0 +1,11 @@
+<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="test.xsd"
+ name="testName">
+ <sub name="subName">
+ <sub name="sub-subName"/>
+ <indir name="sub-indirName">
+ <sub name="sub-indir-subName"/>
+ </indir>
+ <sub2 name="sub-sub2Name"/>
+ </sub>
+</test>
diff --git a/xsd-tests/cxx/parser/recursive/test.xsd b/xsd-tests/cxx/parser/recursive/test.xsd
new file mode 100644
index 0000000..33e1d2d
--- /dev/null
+++ b/xsd-tests/cxx/parser/recursive/test.xsd
@@ -0,0 +1,27 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="sub_type">
+ <xs:sequence>
+ <xs:element name="sub" type="sub_type" minOccurs="0"/>
+ <xs:element name="indir" type="indir_type" minOccurs="0"/>
+ <xs:element name="sub2" type="sub_type" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" />
+ </xs:complexType>
+
+ <xs:complexType name="indir_type">
+ <xs:sequence>
+ <xs:element name="sub" type="sub_type" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" />
+ </xs:complexType>
+
+ <xs:complexType name="test_type">
+ <xs:sequence>
+ <xs:element name="sub" type="sub_type" />
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" />
+ </xs:complexType>
+
+ <xs:element name="test" type="test_type" />
+</xs:schema>
diff --git a/xsd-tests/cxx/parser/test-template/buildfile b/xsd-tests/cxx/parser/test-template/buildfile
new file mode 100644
index 0000000..9f7f5d3
--- /dev/null
+++ b/xsd-tests/cxx/parser/test-template/buildfile
@@ -0,0 +1,23 @@
+# file : cxx/parser/test-template/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/test-template/driver.cxx b/xsd-tests/cxx/parser/test-template/driver.cxx
new file mode 100644
index 0000000..333c6fd
--- /dev/null
+++ b/xsd-tests/cxx/parser/test-template/driver.cxx
@@ -0,0 +1,66 @@
+// file : cxx/parser/test-template/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Insert test description here.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct type_pimpl: type_pskel
+{
+ virtual void
+ pre ()
+ {
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << v << endl;
+ }
+
+ virtual void
+ post_type ()
+ {
+ }
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ type_pimpl type_p;
+
+ type_p.parsers (string_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/test-template/output b/xsd-tests/cxx/parser/test-template/output
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/xsd-tests/cxx/parser/test-template/output
@@ -0,0 +1 @@
+a
diff --git a/xsd-tests/cxx/parser/test-template/test.xml b/xsd-tests/cxx/parser/test-template/test.xml
new file mode 100644
index 0000000..624a80c
--- /dev/null
+++ b/xsd-tests/cxx/parser/test-template/test.xml
@@ -0,0 +1,7 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <a>a</a>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/test-template/test.xsd b/xsd-tests/cxx/parser/test-template/test.xsd
new file mode 100644
index 0000000..07bebc7
--- /dev/null
+++ b/xsd-tests/cxx/parser/test-template/test.xsd
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="type">
+ <sequence>
+ <element name="a" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/union/buildfile b/xsd-tests/cxx/parser/union/buildfile
new file mode 100644
index 0000000..1a8615c
--- /dev/null
+++ b/xsd-tests/cxx/parser/union/buildfile
@@ -0,0 +1,23 @@
+# file : cxx/parser/union/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/union/driver.cxx b/xsd-tests/cxx/parser/union/driver.cxx
new file mode 100644
index 0000000..c5b5c71
--- /dev/null
+++ b/xsd-tests/cxx/parser/union/driver.cxx
@@ -0,0 +1,60 @@
+// file : cxx/parser/union/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test xsd:union parsing.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct int_string_union_pimpl: int_string_union_pskel
+{
+ virtual void
+ _characters (const xml_schema::ro_string& s)
+ {
+ cout << "'" << s << "'" << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ int_string_union_pimpl int_string_union_p;
+ type_pimpl type_p;
+
+ type_p.parsers (int_string_union_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/union/output b/xsd-tests/cxx/parser/union/output
new file mode 100644
index 0000000..a92ffc3
--- /dev/null
+++ b/xsd-tests/cxx/parser/union/output
@@ -0,0 +1,2 @@
+'one'
+'1'
diff --git a/xsd-tests/cxx/parser/union/test.xml b/xsd-tests/cxx/parser/union/test.xml
new file mode 100644
index 0000000..5b3e799
--- /dev/null
+++ b/xsd-tests/cxx/parser/union/test.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <int-string-union/>
+ <int-string-union> </int-string-union>
+ <int-string-union>one</int-string-union>
+ <int-string-union>1</int-string-union>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/union/test.xsd b/xsd-tests/cxx/parser/union/test.xsd
new file mode 100644
index 0000000..5bf3d47
--- /dev/null
+++ b/xsd-tests/cxx/parser/union/test.xsd
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="int-string-union">
+ <union memberTypes="int string"/>
+ </simpleType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="int-string-union" type="t:int-string-union"/>
+ </choice>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/all/buildfile b/xsd-tests/cxx/parser/validation/all/buildfile
new file mode 100644
index 0000000..555843e
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/all/buildfile
@@ -0,0 +1,22 @@
+# file : cxx/parser/validation/all/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \
+ testscript
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/all/driver.cxx b/xsd-tests/cxx/parser/validation/all/driver.cxx
new file mode 100644
index 0000000..a8cbcca
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/all/driver.cxx
@@ -0,0 +1,98 @@
+// file : cxx/parser/validation/all/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the all compositor validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct all_pimpl: all_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+
+ virtual void
+ post_all ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ all_pimpl all_p;
+ type_pimpl type_p;
+
+ all_p.parsers (string_p, string_p, string_p);
+ type_p.parsers (all_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ try
+ {
+ ifstream ifs (argv[1]);
+ type_p.pre ();
+ doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cout << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/all/test.xsd b/xsd-tests/cxx/parser/validation/all/test.xsd
new file mode 100644
index 0000000..1f670e3
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/all/test.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="all">
+ <all minOccurs="1">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string" minOccurs="0"/>
+ </all>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="all" type="t:all" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/all/testscript b/xsd-tests/cxx/parser/validation/all/testscript
new file mode 100644
index 0000000..e93e59c
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/all/testscript
@@ -0,0 +1,190 @@
+# file : cxx/parser/validation/all/testscript
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+test.arguments += test.xml
+
+: all-combinations
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- all combinations -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </all>
+
+ <all>
+ <a>a</a>
+ <c>c</c>
+ <b>b</b>
+ </all>
+
+ <all>
+ <b>b</b>
+ <a>a</a>
+ <c>c</c>
+ </all>
+
+ <all>
+ <b>b</b>
+ <c>c</c>
+ <a>a</a>
+ </all>
+
+ <all>
+ <c>c</c>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+ <all>
+ <c>c</c>
+ <b>b</b>
+ <a>a</a>
+ </all>
+
+ <!-- optional c is not present -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+ <all>
+ <a>a</a>
+ <b>b</b>
+ </all>
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ a = a
+ b = b
+ c = c
+ }
+
+ {
+ a = a
+ c = c
+ b = b
+ }
+
+ {
+ b = b
+ a = a
+ c = c
+ }
+
+ {
+ b = b
+ c = c
+ a = a
+ }
+
+ {
+ c = c
+ a = a
+ b = b
+ }
+
+ {
+ c = c
+ b = b
+ a = a
+ }
+
+ {
+ a = a
+ b = b
+ }
+
+ {
+ a = a
+ b = b
+ }
+
+ EOO
+}
+
+: required-not-present
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- required b is not present (invalid) -->
+ <all>
+ <a>a</a>
+ <c>c</c>
+ </all>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ a = a
+ c = c
+ :9:9 error: expected element 'b'
+ }
+
+ EOO
+}
+
+: absent
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <all>
+ </all>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ :7:9 error: expected element 'a'
+ }
+
+ EOO
+}
+
+: unexpected
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ <a>a</a>
+ </all>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ a = a
+ b = b
+ :9:7 error: unexpected element 'a'
+ }
+
+ EOO
+}
diff --git a/xsd-tests/cxx/parser/validation/any/buildfile b/xsd-tests/cxx/parser/validation/any/buildfile
new file mode 100644
index 0000000..57135f4
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/any/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/validation/any/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/any/driver.cxx b/xsd-tests/cxx/parser/validation/any/driver.cxx
new file mode 100644
index 0000000..1eceda6
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/any/driver.cxx
@@ -0,0 +1,121 @@
+// file : cxx/parser/validation/any/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the any particle validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct any_a_pimpl: any_a_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ x (string const& v)
+ {
+ cout << " x = " << v << endl;
+ }
+
+ virtual void
+ _start_any_element (ro_string const&,
+ ro_string const& n,
+ ro_string const*)
+ {
+ cout << " start any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const& n)
+ {
+ cout << " end any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const&,
+ ro_string const& n,
+ ro_string const& v)
+ {
+ cout << " any attribute " << n << " = '" << v << "'" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_a ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ any_a_pimpl any_a_p;
+ type_pimpl type_p;
+
+ any_a_p.parsers (string_p, string_p);
+ type_p.parsers (any_a_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ try
+ {
+ ifstream ifs (argv[1]);
+ type_p.pre ();
+ doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cout << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/any/output b/xsd-tests/cxx/parser/validation/any/output
new file mode 100644
index 0000000..a1cc6e3
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/any/output
@@ -0,0 +1,29 @@
+{
+ start any element 'any'
+ end any element 'any'
+}
+
+{
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+}
+
+{
+ x = x
+ a = a
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+}
+
diff --git a/xsd-tests/cxx/parser/validation/any/test.xml b/xsd-tests/cxx/parser/validation/any/test.xml
new file mode 100644
index 0000000..f1a0c83
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/any/test.xml
@@ -0,0 +1,21 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- test dispatching of any-nested elements and attributes -->
+
+ <any-a>
+ <o:any/>
+ </any-a>
+
+ <any-a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </any-a>
+
+ <any-a x="x">
+ <a>a</a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </any-a>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/validation/any/test.xsd b/xsd-tests/cxx/parser/validation/any/test.xsd
new file mode 100644
index 0000000..c05aeb5
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/any/test.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="any-a">
+ <sequence>
+ <element name="a" type="string" minOccurs="0"/>
+ <any namespace="other" processContents="skip" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="any-a" type="t:any-a"/>
+ </choice>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/attribute/buildfile b/xsd-tests/cxx/parser/validation/attribute/buildfile
new file mode 100644
index 0000000..d486193
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/attribute/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/validation/attribute/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/attribute/driver.cxx b/xsd-tests/cxx/parser/validation/attribute/driver.cxx
new file mode 100644
index 0000000..4710564
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/attribute/driver.cxx
@@ -0,0 +1,197 @@
+// file : cxx/parser/validation/attribute/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test attribute and attribute wildcard (anyAttribute) validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct pass_a_pimpl: pass_a_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "pass-a" << endl
+ << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const& ns,
+ ro_string const& name,
+ ro_string const& value)
+ {
+ cout << " any: " << ns << "#" << name << " = " << value << endl;
+ }
+
+ virtual void
+ post_pass_a ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct pass_b_pimpl: pass_b_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "pass-b" << endl
+ << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const& ns,
+ ro_string const& name,
+ ro_string const& value)
+ {
+ cout << " any: " << ns << "#" << name << " = " << value << endl;
+ }
+
+ virtual void
+ post_pass_b ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct pass_c_pimpl: pass_c_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "pass-c" << endl
+ << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ post_pass_c ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct fail_pimpl: fail_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "fail" << endl
+ << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ post_fail ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ pass_a_pimpl pass_a_p;
+ pass_b_pimpl pass_b_p;
+ pass_c_pimpl pass_c_p;
+ fail_pimpl fail_p;
+ type_pimpl type_p;
+
+ pass_a_p.parsers (string_p, string_p);
+ pass_b_p.parsers (string_p, string_p);
+ pass_c_p.parsers (string_p, string_p);
+ fail_p.parsers (string_p);
+ type_p.parsers (pass_a_p, pass_b_p, pass_c_p, fail_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ try
+ {
+ ifstream ifs (argv[1]);
+ type_p.pre ();
+ doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cout << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/attribute/output b/xsd-tests/cxx/parser/validation/attribute/output
new file mode 100644
index 0000000..847b054
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/attribute/output
@@ -0,0 +1,24 @@
+pass-a
+{
+ b = b
+ any: test#foo = foo
+ any: test#bar = bar
+}
+
+pass-b
+{
+ a = a
+ b = b
+}
+
+pass-c
+{
+ a = a
+ b = b
+}
+
+fail
+{
+ :8:10 error: expected attribute 'a'
+}
+
diff --git a/xsd-tests/cxx/parser/validation/attribute/test.xml b/xsd-tests/cxx/parser/validation/attribute/test.xml
new file mode 100644
index 0000000..b994d1a
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/attribute/test.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <pass-a b="b" t:foo="foo" t:bar="bar"/>
+ <pass-b a="a" b="b"/>
+ <pass-c a="a" b="b"/>
+ <fail/>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/validation/attribute/test.xsd b/xsd-tests/cxx/parser/validation/attribute/test.xsd
new file mode 100644
index 0000000..833eb8e
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/attribute/test.xsd
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+
+ <!-- Test optional and required attributes as well as a wildcard. -->
+ <complexType name="pass-a">
+ <attribute name="a" type="string" use="optional"/>
+ <attribute name="b" type="string" use="required"/>
+ <anyAttribute namespace="##targetNamespace" processContents="skip"/>
+ </complexType>
+
+
+ <!-- Test that in inheritance attributes are checked before wildcards. -->
+ <complexType name="pass-b-base">
+ <attribute name="a" type="string"/>
+ <anyAttribute namespace="#any" processContents="skip"/>
+ </complexType>
+
+ <complexType name="pass-b">
+ <complexContent>
+ <extension base="t:pass-b-base">
+ <attribute name="b" type="string"/>
+ <anyAttribute namespace="#any" processContents="skip"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <!-- Test that in inheritance by restriction required attribute is
+ checked for even though it is not explicitly mentioned in
+ derived. -->
+ <complexType name="pass-c-base">
+ <attribute name="a" type="string" use="required"/>
+ <attribute name="b" type="string" use="optional"/>
+ </complexType>
+
+ <complexType name="pass-c">
+ <complexContent>
+ <restriction base="t:pass-c-base">
+ <attribute name="b" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+
+ <!-- Test detection of missing required attribute. -->
+ <complexType name="fail-base">
+ <attribute name="a" type="string" use="optional"/>
+ </complexType>
+
+ <complexType name="fail">
+ <complexContent>
+ <restriction base="t:fail-base">
+ <attribute name="a" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="type">
+ <sequence>
+ <element name="pass-a" type="t:pass-a"/>
+ <element name="pass-b" type="t:pass-b"/>
+ <element name="pass-c" type="t:pass-c"/>
+ <element name="fail" type="t:fail"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile
new file mode 100644
index 0000000..a6f366b
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile
@@ -0,0 +1,24 @@
+# file : cxx/parser/validation/built-in/any-type/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs
+
+exe{driver}: xml{test}: test.input = true
+exe{driver}: file{output}: test.stdout = true
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx
new file mode 100644
index 0000000..cbeb864
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx
@@ -0,0 +1,154 @@
+// file : cxx/parser/validation/built-in/any-type/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the anyType and anySimpleType validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct any_type_pimpl: xml_schema::any_type_pimpl
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ _start_any_element (ro_string const&,
+ ro_string const& n,
+ ro_string const*)
+ {
+ cout << " start any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const& n)
+ {
+ cout << " end any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const&,
+ ro_string const& n,
+ ro_string const& v)
+ {
+ cout << " any attribute " << n << " = '" << v << "'" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_type ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_simple_type ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct any_extension_pimpl: virtual any_extension_pskel,
+ any_type_pimpl
+
+{
+ virtual void
+ x (const string& v)
+ {
+ cout << " x = " << v << endl;
+ }
+};
+
+struct any_simple_extension_pimpl: virtual any_simple_extension_pskel,
+ any_simple_type_pimpl
+{
+ virtual void
+ x (const string& v)
+ {
+ cout << " x = " << v << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+
+ any_type_pimpl any_type_p;
+ any_simple_type_pimpl any_simple_type_p;
+
+ any_extension_pimpl any_extension_p;
+ any_simple_extension_pimpl any_simple_extension_p;
+
+ type_pimpl type_p;
+
+ any_extension_p.parsers (string_p);
+ any_simple_extension_p.parsers (string_p);
+
+ type_p.parsers (any_type_p,
+ any_extension_p,
+ any_simple_extension_p,
+ any_simple_type_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ ifstream ifs (argv[1]);
+ type_p.pre ();
+ doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/output b/xsd-tests/cxx/parser/validation/built-in/any-type/output
new file mode 100644
index 0000000..84d7b3a
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/any-type/output
@@ -0,0 +1,99 @@
+{
+ any text: '123abc'
+}
+
+{
+ any text: '
+ '
+ start any element 'any'
+ end any element 'any'
+ any text: '
+ '
+}
+
+{
+ any text: '
+ '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+ '
+}
+
+{
+ any attribute x = 'x'
+ any text: '
+ '
+ start any element 'a'
+ any text: 'a'
+ end any element 'a'
+ any text: '
+ '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+ '
+}
+
+{
+ any text: '
+ '
+ start any element 'any'
+ end any element 'any'
+ any text: '
+ '
+}
+
+{
+ any text: '
+ '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+ '
+}
+
+{
+ x = x
+ any text: '
+ '
+ start any element 'a'
+ any text: 'a'
+ end any element 'a'
+ any text: '
+ '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+ '
+}
+
+{
+ x = x
+ any text: 'abc123'
+}
+
diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml
new file mode 100644
index 0000000..7875b7e
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml
@@ -0,0 +1,41 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd"
+ as="123abc">
+
+ <!-- test dispatching of anyType nested elements and attributes -->
+
+ <a>
+ <o:any/>
+ </a>
+
+ <a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a>
+
+ <a x="x">
+ <a>a</a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a>
+
+ <!-- anyType extension -->
+
+ <a-extension>
+ <o:any/>
+ </a-extension>
+
+ <a-extension>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a-extension>
+
+ <a-extension x="x">
+ <a>a</a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a-extension>
+
+ <!-- anySimpleType extension -->
+
+ <as-extension x="x">abc123</as-extension>
+
+</t:root>
diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd
new file mode 100644
index 0000000..86a4e13
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="any-extension">
+ <complexContent mixed="true">
+ <extension base="anyType">
+ <attribute name="x" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="any-simple-extension">
+ <simpleContent>
+ <extension base="anySimpleType">
+ <attribute name="x" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="a" type="anyType"/>
+ <element name="a-extension" type="t:any-extension"/>
+ <element name="as-extension" type="t:any-simple-extension"/>
+ </choice>
+ <attribute name="as" type="anySimpleType"/>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/built-in/binary/buildfile b/xsd-tests/cxx/parser/validation/built-in/binary/buildfile
new file mode 100644
index 0000000..fd1594f
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/binary/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/binary/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx
new file mode 100644
index 0000000..3fe20ec
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx
@@ -0,0 +1,153 @@
+// file : cxx/parser/validation/built-in/binary/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in base64Binary and hexBinary types validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ typedef xsd::cxx::parser::buffer buffer;
+
+ // Good.
+ //
+
+ // hexBinary
+ //
+ {
+ hex_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters (" ");
+ p._post ();
+ assert (*p.post_hex_binary () == buffer ());
+ }
+
+ {
+ hex_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n313");
+ p._characters ("23334356162636a6b ");
+ p._post ();
+ assert (*p.post_hex_binary () == buffer ("12345abcjk", 10));
+ }
+
+ // base64Binary
+ //
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("MTIzND ");
+ p._characters ("VhYmNqaw = = ");
+ p._post ();
+ assert (*p.post_base64_binary () == buffer ("12345abcjk", 10));
+ }
+
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("YQ==");
+ p._post ();
+ assert (*p.post_base64_binary () == buffer ("a", 1));
+ }
+
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("YWI=");
+ p._post ();
+ assert (*p.post_base64_binary () == buffer ("ab", 2));
+ }
+
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("YWJj");
+ p._post ();
+ assert (*p.post_base64_binary () == buffer ("abc", 3));
+ }
+
+ // Bad
+ //
+
+ // hexBinary
+ //
+ {
+ hex_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("313");
+ assert (test_post_fail (p));
+ }
+
+ {
+ hex_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("313233343X6162636a6b");
+ assert (test_post_fail (p));
+ }
+
+ // base64Binary
+ //
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("YQ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("==");
+ assert (test_post_fail (p));
+ }
+
+ {
+ base64_binary_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("MTIzNDVhYmNqaw=A");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile b/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile
new file mode 100644
index 0000000..259614e
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/boolean/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx
new file mode 100644
index 0000000..f1499cd
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx
@@ -0,0 +1,145 @@
+// file : cxx/parser/validation/built-in/boolean/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in boolean type validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+bool
+test_post_fail (boolean_pimpl<char>& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("true");
+ p._post ();
+ assert (p.post_boolean ());
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1");
+ p._post ();
+ assert (p.post_boolean ());
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("false");
+ p._post ();
+ assert (!p.post_boolean ());
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (!p.post_boolean ());
+ }
+
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" true ");
+ p._post ();
+ assert (p.post_boolean ());
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ p._characters (" \n ");
+ p._characters (" fa");
+ p._characters ("l");
+ p._characters ("se ");
+ p._characters (" \n ");
+ p._characters (" ");
+ p._post ();
+ assert (!p.post_boolean ());
+ }
+
+ // Bad
+ //
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ //p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("fal");
+ p._characters ("s ");
+ p._characters ("e");
+ assert (test_post_fail (p));
+ }
+
+ {
+ boolean_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("01");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/byte/buildfile b/xsd-tests/cxx/parser/validation/built-in/byte/buildfile
new file mode 100644
index 0000000..87de911
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/byte/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/byte/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx
new file mode 100644
index 0000000..b533cfd
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx
@@ -0,0 +1,256 @@
+// file : cxx/parser/validation/built-in/byte/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in byte and unsigned byte types validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("123");
+ p._post ();
+ assert (p.post_byte () == 123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("\t +123 \n ");
+ p._post ();
+ assert (p.post_byte () == 123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-123");
+ p._post ();
+ assert (p.post_byte () == -123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+123");
+ p._post ();
+ assert (p.post_byte () == 123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0000000000000000123");
+ p._post ();
+ assert (p.post_byte () == 123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+0000000000000000123");
+ p._post ();
+ assert (p.post_byte () == 123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0000000000000000123");
+ p._post ();
+ assert (p.post_byte () == -123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("\t \n");
+ p._characters (" -");
+ p._characters ("00000");
+ p._characters ("001");
+ p._characters ("23 \n\t");
+ p._post ();
+ assert (p.post_byte () == -123);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-128");
+ p._post ();
+ assert (p.post_byte () == -128);
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("127");
+ p._post ();
+ assert (p.post_byte () == 127);
+ }
+
+ {
+ unsigned_byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+123");
+ p._post ();
+ assert (p.post_unsigned_byte () == 123);
+ }
+
+ {
+ unsigned_byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_unsigned_byte () == 0);
+ }
+
+ {
+ unsigned_byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("255");
+ p._post ();
+ assert (p.post_unsigned_byte () == 255);
+ }
+
+ // Bad
+ //
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n \t ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("++01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-01");
+ p._characters (" ");
+ p._characters ("23 ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ unsigned_byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-123");
+ assert (test_post_fail (p));
+ }
+
+ // Ranges
+ //
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-129");
+ assert (test_post_fail (p));
+ }
+
+ {
+ byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("128");
+ assert (test_post_fail (p));
+ }
+
+ {
+ unsigned_byte_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("256");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile b/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile
new file mode 100644
index 0000000..47791e5
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/date-time/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx
new file mode 100644
index 0000000..da02a50
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx
@@ -0,0 +1,1533 @@
+// file : cxx/parser/validation/built-in/date-time/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in date and time types validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ typedef xsd::cxx::parser::gday gday;
+ typedef xsd::cxx::parser::gmonth gmonth;
+ typedef xsd::cxx::parser::gyear gyear;
+ typedef xsd::cxx::parser::gmonth_day gmonth_day;
+ typedef xsd::cxx::parser::gyear_month gyear_month;
+ typedef xsd::cxx::parser::date date;
+ typedef xsd::cxx::parser::time time;
+ typedef xsd::cxx::parser::date_time date_time;
+ typedef xsd::cxx::parser::duration duration;
+
+ // Good.
+ //
+
+ // gday & time zone parsing
+ //
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("---1");
+ p._characters ("2+12:00");
+ p._post ();
+ assert (p.post_gday () == gday (12, 12, 00));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---01");
+ p._post ();
+ assert (p.post_gday () == gday (1));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---31");
+ p._post ();
+ assert (p.post_gday () == gday (31));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---15Z");
+ p._post ();
+ assert (p.post_gday () == gday (15, 0, 0));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---15-14:00");
+ p._post ();
+ assert (p.post_gday () == gday (15, -14, 0));
+ }
+
+ // gmonth
+ //
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("--1");
+ p._characters ("0+12:00");
+ p._post ();
+ assert (p.post_gmonth () == gmonth (10, 12, 0));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--01");
+ p._post ();
+ assert (p.post_gmonth () == gmonth (1));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12Z");
+ p._post ();
+ assert (p.post_gmonth () == gmonth (12, 0, 0));
+ }
+
+ // gyear
+ //
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("20");
+ p._characters ("07+12:00");
+ p._post ();
+ assert (p.post_gyear () == gyear (2007, 12, 00));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0001");
+ p._post ();
+ assert (p.post_gyear () == gyear (1));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-20000Z");
+ p._post ();
+ assert (p.post_gyear () == gyear (-20000, 0, 0));
+ }
+
+ // gmonth_day
+ //
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("--1");
+ p._characters ("0-28+12:00 ");
+ p._post ();
+ assert (p.post_gmonth_day () == gmonth_day (10, 28, 12, 00));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12-31");
+ p._post ();
+ assert (p.post_gmonth_day () == gmonth_day (12, 31));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--01-01Z");
+ p._post ();
+ assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0));
+ }
+
+ // gyear_month
+ //
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("200");
+ p._characters ("7-12+12:00 ");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (2007, 12, 12, 00));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-2007-10");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (-2007, 10));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20007-10Z");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-20007-01");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (-20007, 1));
+ }
+
+ // date
+ //
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("200");
+ p._characters ("7-12-26+12:00 ");
+ p._post ();
+ assert (p.post_date () == date (2007, 12, 26, 12, 0));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-2007-10-15");
+ p._post ();
+ assert (p.post_date () == date (-2007, 10, 15));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20007-12-31Z");
+ p._post ();
+ assert (p.post_date () == date (20007, 12, 31, 0, 0));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-20007-01-01");
+ p._post ();
+ assert (p.post_date () == date (-20007, 1, 1));
+ }
+
+ // time
+ //
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("12:");
+ p._characters ("46:23.456+12:00 ");
+ p._post ();
+ assert (p.post_time () == time (12, 46, 23.456, 12, 0));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("12:13:14");
+ p._post ();
+ assert (p.post_time () == time (12, 13, 14.0));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("12:13:14Z");
+ p._post ();
+ assert (p.post_time () == time (12, 13, 14.0, 0, 0));
+ }
+
+ // date_time
+ //
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("200");
+ p._characters ("7-12-26T12:13:14.123+12:00 ");
+ p._post ();
+ assert (p.post_date_time () ==
+ date_time (2007, 12, 26, 12, 13, 14.123, 12, 0));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-2007-10-15T12:13:14");
+ p._post ();
+ assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20007-12-31T12:13:14Z");
+ p._post ();
+ assert (p.post_date_time () ==
+ date_time (20007, 12, 31, 12, 13, 14.0, 0, 0));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-20007-01-01T12:13:14");
+ p._post ();
+ assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0));
+ }
+
+ // duration
+ //
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \t\n ");
+ p._characters ("-P200");
+ p._characters ("7Y13M32DT25H61M61.123S ");
+ p._post ();
+ assert (p.post_duration () ==
+ duration (true, 2007, 13, 32, 25, 61, 61.123));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1Y");
+ p._post ();
+ assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1M");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1D");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT1H");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT1M");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT1.1S");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1YT1S");
+ p._post ();
+ assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0));
+ }
+
+ // Bad
+ //
+
+ // gday & time zone parsing
+ //
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---1");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---32");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---2X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12asd");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---1212:00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12+2:00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12+1200");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12+15:00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12+12:60");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gday_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("---12+14:01");
+ assert (test_post_fail (p));
+ }
+
+ // gmonth
+ //
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--13");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--1X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--11+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // gyear
+ //
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("207");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-207");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0000");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20X7");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // gmonth_day
+ //
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-12-12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--1212");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12?12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--00-12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12-00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--13-23");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12-32");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--1X-12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--12-2X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gmonth_day_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("--11-11+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // gyear_month
+ //
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("207-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-207-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0000-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20X7-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007?12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-0");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-13");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-1X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ gyear_month_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // date
+ //
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("207-01-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-207-01-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0000-01-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20X7-01-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007?01-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-0-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-00-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-13-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-1X-01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10?12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-0");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-32");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-2X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // time
+ //
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1:01:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2X:01:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23?01:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:0:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:60:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:4X:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10?12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10:");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10:0");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10:01.");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10:60");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:10:2X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("24:01:00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("24:00:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:01:01+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // date_time
+ //
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("207-01-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-207-01-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0000-01-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("20X7-01-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007?01-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-0-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-00-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-13-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-1X-01T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10?12T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-0T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-00T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-32T12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-10-2XT12:13:14");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T1:01:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T2X:01:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23?01:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:0:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:60:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:4X:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10?12");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10:");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10:0");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10:01.");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10:60");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T23:10:2X");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T24:01:00");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T24:00:01");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("23:01:01+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ {
+ date_time_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007-01-01T12:13:14+12:3o");
+ assert (test_post_fail (p));
+ }
+
+ // duration
+ //
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ // p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2007Y");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-2007Y");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P-2007Y");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P-1M");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P-1D");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT-1H");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT-1M");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT-1.1S");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1H1M1S");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1M1Y");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT1S1H");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("PT1H1Y");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1Ygarbage");
+ assert (test_post_fail (p));
+ }
+
+ {
+ duration_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("P1YT");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/float/buildfile b/xsd-tests/cxx/parser/validation/built-in/float/buildfile
new file mode 100644
index 0000000..ca0eac1
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/float/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/float/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx
new file mode 100644
index 0000000..bb67eb7
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx
@@ -0,0 +1,285 @@
+// file : cxx/parser/validation/built-in/float/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in float, double, and decimal types validation.
+//
+#include <math.h>
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+
+ // float
+ //
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" 0000123.456 ");
+ p._post ();
+ assert (p.post_float () == 123.456F);
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-12.345E2");
+ p._post ();
+ assert (p.post_float () == -12.345E2F);
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_float () == 0.0F);
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0");
+ p._post ();
+ assert (p.post_float () == -0.0F);
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("INF");
+ p._post ();
+ assert (isinf (p.post_float ()));
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-INF");
+ p._post ();
+ assert (isinf (p.post_float ()));
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("NaN");
+ p._post ();
+ assert (isnan (p.post_float ()));
+ }
+
+ // double
+ //
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" 0000123.456789 ");
+ p._post ();
+ assert (p.post_double () == 123.456789);
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-12.3456789E2");
+ p._post ();
+ assert (p.post_double () == -12.3456789E2);
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_double () == 0.0);
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0");
+ p._post ();
+ assert (p.post_double () == -0.0);
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("INF");
+ p._post ();
+ assert (isinf (p.post_double ()));
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-INF");
+ p._post ();
+ assert (isinf (p.post_double ()));
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("NaN");
+ p._post ();
+ assert (isnan (p.post_double ()));
+ }
+
+ // decimal
+ //
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" 0000123.456789 ");
+ p._post ();
+ assert (p.post_decimal () == 123.456789);
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-123.45678912345");
+ p._post ();
+ assert (p.post_decimal () == -123.45678912345);
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_decimal () == 0.0);
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0");
+ p._post ();
+ assert (p.post_decimal () == -0.0);
+ }
+
+
+ // Bad
+ //
+
+ // float
+ //
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+INF");
+ assert (test_post_fail (p));
+ }
+
+ {
+ float_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1.45 E2");
+ assert (test_post_fail (p));
+ }
+
+ // double
+ //
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+INF");
+ assert (test_post_fail (p));
+ }
+
+ {
+ double_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1.45 E2");
+ assert (test_post_fail (p));
+ }
+
+ // decimal
+ //
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("INF");
+ assert (test_post_fail (p));
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+INF");
+ assert (test_post_fail (p));
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-INF");
+ assert (test_post_fail (p));
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("NaN");
+ assert (test_post_fail (p));
+ }
+
+ {
+ decimal_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1.45 2");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/int/buildfile b/xsd-tests/cxx/parser/validation/built-in/int/buildfile
new file mode 100644
index 0000000..51bdf12
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/int/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/int/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx
new file mode 100644
index 0000000..d31d206
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx
@@ -0,0 +1,116 @@
+// file : cxx/parser/validation/built-in/int/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in int and unsigned int types validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-2147483648");
+ p._post ();
+ assert (p.post_int () == -2147483648);
+ }
+
+ {
+ int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_int () == 0);
+ }
+
+ {
+ int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2147483647");
+ p._post ();
+ assert (p.post_int () == 2147483647);
+ }
+
+ {
+ unsigned_int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_unsigned_int () == 0);
+ }
+
+ {
+ unsigned_int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("4294967295");
+ p._post ();
+ assert (p.post_unsigned_int () == 4294967295);
+ }
+
+ // Bad
+ //
+
+ {
+ unsigned_int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-123");
+ assert (test_post_fail (p));
+ }
+
+
+ // Ranges
+ //
+ {
+ int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-2147483649");
+ assert (test_post_fail (p));
+ }
+
+ {
+ int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("2147483648");
+ assert (test_post_fail (p));
+ }
+
+ {
+ unsigned_int_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("4294967296");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/integer/buildfile b/xsd-tests/cxx/parser/validation/built-in/integer/buildfile
new file mode 100644
index 0000000..4d63a19
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/integer/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/integer/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx
new file mode 100644
index 0000000..3a5fdd5
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx
@@ -0,0 +1,303 @@
+// file : cxx/parser/validation/built-in/integer/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in integer & friends types validation.
+//
+#include <limits.h>
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace std;
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+
+ std::string min;
+ std::string max;
+ std::string umax;
+
+ {
+ ostringstream ostr;
+ ostr << LLONG_MIN;
+ min = ostr.str ();
+ }
+
+ {
+ ostringstream ostr;
+ ostr << LLONG_MAX;
+ max = ostr.str ();
+ }
+
+ {
+ ostringstream ostr;
+ ostr << ULLONG_MAX;
+ umax = ostr.str ();
+ }
+
+ // integer
+ //
+ {
+ integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (min.c_str ());
+ p._post ();
+ assert (p.post_integer () == LLONG_MIN);
+ }
+
+ {
+ integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_integer () == 0);
+ }
+
+ {
+ integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (max.c_str ());
+ p._post ();
+ assert (p.post_integer () == LLONG_MAX);
+ }
+
+ // negative_integer
+ //
+ {
+ negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (min.c_str ());
+ p._post ();
+ assert (p.post_negative_integer () == LLONG_MIN);
+ }
+
+ {
+ negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-1");
+ p._post ();
+ assert (p.post_negative_integer () == -1);
+ }
+
+ // non_positive_integer
+ //
+ {
+ non_positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (min.c_str ());
+ p._post ();
+ assert (p.post_non_positive_integer () == LLONG_MIN);
+ }
+
+ {
+ non_positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+0");
+ p._post ();
+ assert (p.post_non_positive_integer () == 0);
+ }
+
+ // positive_integer
+ //
+ {
+ positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1");
+ p._post ();
+ assert (p.post_positive_integer () == 1);
+ }
+
+ {
+ positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (umax.c_str ());
+ p._post ();
+ assert (p.post_positive_integer () == ULLONG_MAX);
+ }
+
+ // non_negative_integer
+ //
+ /*
+ {
+ non_negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0");
+ p._post ();
+ assert (p.post_non_negative_integer () == 0);
+ }
+ */
+
+ {
+ non_negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_non_negative_integer () == 0);
+ }
+
+ {
+ non_negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (umax.c_str ());
+ p._post ();
+ assert (p.post_non_negative_integer () == ULLONG_MAX);
+ }
+
+
+ // Bad
+ //
+
+ std::string past_min (min);
+ std::string past_max (max);
+ std::string past_umax (umax);
+
+ assert (*past_min.rbegin () != '9');
+ assert (*past_max.rbegin () != '9');
+ assert (*past_umax.rbegin () != '9');
+
+ (*past_min.rbegin ())++;
+ (*past_max.rbegin ())++;
+ (*past_umax.rbegin ())++;
+
+ // integer
+ //
+ {
+ integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (past_min.c_str ());
+ assert (test_post_fail (p));
+ }
+
+ {
+ integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (past_max.c_str ());
+ assert (test_post_fail (p));
+ }
+
+ // negative_integer
+ //
+ {
+ negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (past_min.c_str ());
+ assert (test_post_fail (p));
+ }
+
+ {
+ negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-0");
+ assert (test_post_fail (p));
+ }
+
+ {
+ negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1");
+ assert (test_post_fail (p));
+ }
+
+ // non_positive_integer
+ //
+ {
+ non_positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (past_min.c_str ());
+ assert (test_post_fail (p));
+ }
+
+ {
+ non_positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1");
+ assert (test_post_fail (p));
+ }
+
+ // positive_integer
+ //
+ {
+ positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-1");
+ assert (test_post_fail (p));
+ }
+
+ {
+ positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("+0");
+ assert (test_post_fail (p));
+ }
+
+ {
+ positive_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (past_umax.c_str ());
+ assert (test_post_fail (p));
+ }
+
+ // non_negative_integer
+ //
+ {
+ non_negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-1");
+ assert (test_post_fail (p));
+ }
+
+ {
+ non_negative_integer_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (past_umax.c_str ());
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/long/buildfile b/xsd-tests/cxx/parser/validation/built-in/long/buildfile
new file mode 100644
index 0000000..285ad70
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/long/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/long/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx
new file mode 100644
index 0000000..a4ab565
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx
@@ -0,0 +1,116 @@
+// file : cxx/parser/validation/built-in/long/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in long and unsigned long types validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-9223372036854775808");
+ p._post ();
+ assert (p.post_long () == (-9223372036854775807LL - 1));
+ }
+
+ {
+ long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_long () == 0);
+ }
+
+ {
+ long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("9223372036854775807");
+ p._post ();
+ assert (p.post_long () == 9223372036854775807LL);
+ }
+
+ {
+ unsigned_long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_unsigned_long () == 0);
+ }
+
+ {
+ unsigned_long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("18446744073709551615");
+ p._post ();
+ assert (p.post_unsigned_long () == 18446744073709551615ULL);
+ }
+
+ // Bad
+ //
+
+ {
+ unsigned_long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-123");
+ assert (test_post_fail (p));
+ }
+
+
+ // Ranges
+ //
+ {
+ long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-9223372036854775809");
+ assert (test_post_fail (p));
+ }
+
+ {
+ long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("9223372036854775808");
+ assert (test_post_fail (p));
+ }
+
+ {
+ unsigned_long_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("18446744073709551616");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/buildfile b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile
new file mode 100644
index 0000000..47d644c
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/qname/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx
new file mode 100644
index 0000000..85acd1c
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx
@@ -0,0 +1,105 @@
+// file : cxx/parser/validation/built-in/qname/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in QName type validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+bool
+test_post_fail (qname_pimpl<char>& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ typedef xsd::cxx::parser::qname<char> qname;
+
+ // Good.
+ //
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" xsi");
+ p._characters (":");
+ p._characters ("schemaLocation");
+ p._post ();
+ assert (p.post_qname () == qname ("xsi", "schemaLocation"));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("schemaLocation");
+ p._post ();
+ assert (p.post_qname () == qname ("schemaLocation"));
+ }
+
+
+ // Bad
+ //
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ //p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (":");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("xsi:");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (":schemaLocation");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("x?i:schemaLocation");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("xsi:schema Location");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/short/buildfile b/xsd-tests/cxx/parser/validation/built-in/short/buildfile
new file mode 100644
index 0000000..782b404
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/short/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/short/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx
new file mode 100644
index 0000000..7c79b22
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx
@@ -0,0 +1,116 @@
+// file : cxx/parser/validation/built-in/short/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in short and unsigned short types validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-32768");
+ p._post ();
+ assert (p.post_short () == -32768);
+ }
+
+ {
+ short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_short () == 0);
+ }
+
+ {
+ short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("32767");
+ p._post ();
+ assert (p.post_short () == 32767);
+ }
+
+ {
+ unsigned_short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("0");
+ p._post ();
+ assert (p.post_unsigned_short () == 0);
+ }
+
+ {
+ unsigned_short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("65535");
+ p._post ();
+ assert (p.post_unsigned_short () == 65535);
+ }
+
+ // Bad
+ //
+
+ {
+ unsigned_short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-1234");
+ assert (test_post_fail (p));
+ }
+
+
+ // Ranges
+ //
+ {
+ short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-32769");
+ assert (test_post_fail (p));
+ }
+
+ {
+ short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("32768");
+ assert (test_post_fail (p));
+ }
+
+ {
+ unsigned_short_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("65536");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/string/buildfile b/xsd-tests/cxx/parser/validation/built-in/string/buildfile
new file mode 100644
index 0000000..83e5f7a
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/string/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/string/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx
new file mode 100644
index 0000000..920385a
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx
@@ -0,0 +1,512 @@
+// file : cxx/parser/validation/built-in/string/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in string & friends types validation.
+//
+#include <string>
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+template <typename T>
+bool
+test_post_fail (T& p)
+{
+ try
+ {
+ p._post_impl (); // List implementation needs this to be post_impl.
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ typedef xsd::cxx::parser::string_sequence<char> strings;
+
+ // Good.
+ //
+
+ // string
+ //
+ {
+ string_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" aaa ");
+ p._characters ("bbb");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_string () == " \n\t aaa bbb ");
+ }
+
+ // normalized_string
+ //
+ {
+ normalized_string_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" aaa \n\t ");
+ p._characters (" bbb");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_normalized_string () == " aaa bbb ");
+ }
+
+ // token
+ //
+ {
+ token_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" aaa \n\t ");
+ p._characters (" bbb \n\t");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_token () == "aaa bbb");
+ }
+
+ // name
+ //
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" a:b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_name () == "a:b-c_d123");
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" _12 ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_name () == "_12");
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" :12 ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_name () == ":12");
+ }
+
+ // nmtoken
+ //
+ {
+ nmtoken_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" 123a:b-c_d123 ");
+ p._characters (" \n\t");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_nmtoken () == "123a:b-c_d123");
+ }
+
+ // nmtokens
+ //
+ {
+ strings s;
+ s.push_back ("123");
+ s.push_back ("abc");
+
+ nmtokens_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" 123 ");
+ p._characters (" \n\t abc ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_nmtokens () == s);
+ }
+
+ // ncname
+ //
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" a.b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_ncname () == "a.b-c_d123");
+ }
+
+ // id
+ //
+ {
+ id_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" a.b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_id () == "a.b-c_d123");
+ }
+
+ // idref
+ //
+ {
+ idref_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" a.b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_idref () == "a.b-c_d123");
+ }
+
+ // idrefs
+ //
+ {
+ strings s;
+ s.push_back ("a123");
+ s.push_back ("abc");
+
+ idrefs_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" \n\t");
+ p._characters (" a123 ");
+ p._characters (" \n\t abc ");
+ p._characters (" ");
+ p._post ();
+ assert (p.post_idrefs () == s);
+ }
+
+ // language
+ //
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" x ");
+ p._post ();
+ assert (p.post_language () == "x");
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" en ");
+ p._post ();
+ assert (p.post_language () == "en");
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" en");
+ p._characters ("-us ");
+ p._post ();
+ assert (p.post_language () == "en-us");
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("one-two-three-four44-seven77-eight888");
+ p._post ();
+ assert (p.post_language () == "one-two-three-four44-seven77-eight888");
+ }
+
+
+ // Bad
+ //
+
+ // name
+ //
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (".a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a,b");
+ assert (test_post_fail (p));
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a b");
+ assert (test_post_fail (p));
+ }
+
+ {
+ name_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a<b");
+ assert (test_post_fail (p));
+ }
+
+ // nmtoken
+ //
+ {
+ nmtoken_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ nmtoken_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a,b");
+ assert (test_post_fail (p));
+ }
+
+ {
+ nmtoken_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a b");
+ assert (test_post_fail (p));
+ }
+
+ {
+ nmtoken_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a<b");
+ assert (test_post_fail (p));
+ }
+
+ // nmtokens
+ //
+ {
+ nmtokens_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ p._characters (" \t\n ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ nmtokens_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("ab a,b");
+ assert (test_post_fail (p));
+ }
+
+ // ncname
+ //
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (".a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("-a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (":a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("1:a");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a,b");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a b");
+ assert (test_post_fail (p));
+ }
+
+ {
+ ncname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a<b");
+ assert (test_post_fail (p));
+ }
+
+ // id
+ //
+ {
+ id_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a b");
+ assert (test_post_fail (p));
+ }
+
+ // idref
+ //
+ {
+ idref_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a b");
+ assert (test_post_fail (p));
+ }
+
+ // idrefs
+ //
+ {
+ idrefs_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ p._characters (" \t\n ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ idrefs_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("ab a<b");
+ assert (test_post_fail (p));
+ }
+
+ // language
+ //
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ assert (test_post_fail (p));
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("en-");
+ assert (test_post_fail (p));
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("a1");
+ assert (test_post_fail (p));
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("en+us");
+ assert (test_post_fail (p));
+ }
+
+ {
+ language_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("en-nine99999");
+ assert (test_post_fail (p));
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/built-in/uri/buildfile b/xsd-tests/cxx/parser/validation/built-in/uri/buildfile
new file mode 100644
index 0000000..a8fdf82
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/uri/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/uri/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx
new file mode 100644
index 0000000..dcc9242
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx
@@ -0,0 +1,53 @@
+// file : cxx/parser/validation/built-in/uri/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in anyURI type validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ uri_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" ");
+ p._post ();
+ assert (p.post_uri () == "");
+ }
+
+ {
+ uri_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("relative");
+ p._post ();
+ assert (p.post_uri () == "relative");
+ }
+
+ {
+ uri_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("#id");
+ p._post ();
+ assert (p.post_uri () == "#id");
+ }
+
+ {
+ uri_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("http://www.example.com/foo#bar");
+ p._post ();
+ assert (p.post_uri () == "http://www.example.com/foo#bar");
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/choice/buildfile b/xsd-tests/cxx/parser/validation/choice/buildfile
new file mode 100644
index 0000000..adf0832
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/choice/buildfile
@@ -0,0 +1,22 @@
+# file : cxx/parser/validation/choice/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \
+ testscript
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/choice/driver.cxx b/xsd-tests/cxx/parser/validation/choice/driver.cxx
new file mode 100644
index 0000000..4a52c5d
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/choice/driver.cxx
@@ -0,0 +1,126 @@
+// file : cxx/parser/validation/choice/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the choice compositor validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct choice_pimpl: choice_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+
+ virtual void
+ d (string const& v)
+ {
+ cout << " d = " << v << endl;
+ }
+
+ virtual void
+ _start_any_element (ro_string const& ns,
+ ro_string const& name,
+ ro_string const*)
+ {
+ cout << " any: " << ns << "#" << name << endl
+ << " {" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& v)
+ {
+ cout << " chars = " << v << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const&)
+ {
+ cout << " }" << endl;
+ }
+
+ virtual void
+ post_choice ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ choice_pimpl choice_p;
+ type_pimpl type_p;
+
+ choice_p.parsers (string_p, string_p, string_p, string_p);
+ type_p.parsers (choice_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ try
+ {
+ ifstream ifs (argv[1]);
+ type_p.pre ();
+ doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cout << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/choice/test.xsd b/xsd-tests/cxx/parser/validation/choice/test.xsd
new file mode 100644
index 0000000..8132bbb
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/choice/test.xsd
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="choice">
+ <choice maxOccurs="3">
+ <element name="a" type="string"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <element name="c" type="string" minOccurs="0"/>
+ <element name="d" type="string"/>
+ </sequence>
+ <any namespace="other" maxOccurs="unbounded"/>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="choice" type="t:choice" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/choice/testscript b/xsd-tests/cxx/parser/validation/choice/testscript
new file mode 100644
index 0000000..c5f5afa
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/choice/testscript
@@ -0,0 +1,179 @@
+# file : cxx/parser/validation/choice/testscript
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+test.arguments += test.xml
+
+: valid
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <choice>
+ <a>a</a>
+
+ <b>b</b>
+ </choice>
+
+ <choice>
+ <c>c</c>
+ <d>d</d>
+
+ <o:any>any</o:any>
+
+ <a>a</a>
+ </choice>
+
+ <choice>
+ <c>c</c>
+ <d>d</d>
+
+ <d>d</d>
+
+ <a>a</a>
+ </choice>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ a = a
+ b = b
+ }
+
+ {
+ c = c
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ a = a
+ }
+
+ {
+ c = c
+ d = d
+ d = d
+ a = a
+ }
+
+ EOO
+}
+
+: absent1
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ </choice>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ :8:12 error: expected element 'a'
+ }
+
+ EOO
+}
+
+: absent2
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ <c>c</c>
+ <d>d</d>
+
+ <o:any>any</o:any>
+
+ <a>a</a>
+ <b>b</b>
+ </choice>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ c = c
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ a = a
+ :14:8 error: unexpected element 'b'
+ }
+
+ EOO
+}
+
+: absent3
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ <c>c</c>
+ </choice>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ c = c
+ :9:12 error: expected element 'd'
+ }
+
+ EOO
+}
+
+: absent4
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ <x>x</x>
+ </choice>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ :8:8 error: expected element 'a' instead of 'x'
+ }
+
+ EOO
+}
diff --git a/xsd-tests/cxx/parser/validation/restriction/buildfile b/xsd-tests/cxx/parser/validation/restriction/buildfile
new file mode 100644
index 0000000..4c415bf
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/restriction/buildfile
@@ -0,0 +1,22 @@
+# file : cxx/parser/validation/restriction/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \
+ testscript
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/restriction/driver.cxx b/xsd-tests/cxx/parser/validation/restriction/driver.cxx
new file mode 100644
index 0000000..206b9f8
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/restriction/driver.cxx
@@ -0,0 +1,107 @@
+// file : cxx/parser/validation/restriction/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the restriction compositor validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct base_a_pimpl: base_a_pskel
+{
+};
+
+struct restriction_a_pimpl: restriction_a_pskel
+{
+};
+
+struct extension_b_pimpl: extension_b_pskel
+{
+};
+
+struct restriction_b_pimpl: restriction_b_pskel
+{
+};
+
+struct type_b_pimpl: type_b_pskel
+{
+};
+
+struct type_r_pimpl: type_r_pskel
+{
+};
+
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ base_a_pimpl base_a_p;
+ restriction_a_pimpl restriction_a_p;
+ extension_b_pimpl extension_b_p;
+ restriction_b_pimpl restriction_b_p;
+ type_b_pimpl type_b_p;
+ type_r_pimpl type_r_p;
+
+ base_a_p.parsers (string_p, string_p, string_p,
+ string_p, string_p, string_p);
+
+ restriction_a_p.parsers (string_p, string_p, string_p,
+ string_p, string_p, string_p);
+
+ extension_b_p.parsers (string_p, string_p, string_p,
+ string_p, string_p);
+
+ restriction_b_p.parsers (string_p, string_p, string_p,
+ string_p, string_p);
+
+ type_b_p.parsers (base_a_p, extension_b_p);
+ type_r_p.parsers (restriction_a_p, restriction_b_p);
+
+ xml_schema::document doc_b_p (type_b_p, "test", "root");
+ xml_schema::document doc_r_p (type_r_p, "test", "root");
+
+ {
+ ifstream ifs (argv[1]);
+ type_b_p.pre ();
+ doc_b_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_b_p.post_type_b ();
+ }
+
+ try
+ {
+ ifstream ifs (argv[1]);
+ type_r_p.pre ();
+ doc_r_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_r_p.post_type_r ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cout << e << endl;
+ }
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/restriction/test.xsd b/xsd-tests/cxx/parser/validation/restriction/test.xsd
new file mode 100644
index 0000000..158ded5
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/restriction/test.xsd
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- simple case -->
+ <complexType name="base-a">
+ <sequence minOccurs="1" maxOccurs="2">
+ <element name="a" type="string" minOccurs="0"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ <attribute name="y" type="string"/>
+ <attribute name="z" type="string"/>
+ </complexType>
+
+ <complexType name="restriction-a">
+ <complexContent>
+ <restriction base="t:base-a">
+ <sequence minOccurs="1" maxOccurs="1">
+ <element name="a" type="string" minOccurs="1"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string"/>
+ </sequence>
+ <!-- Can be ommited if not changed, e.g., 'x'. -->
+ <attribute name="y" type="string"/> <!-- But can also be repeated without change. -->
+ <attribute name="z" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <!-- restriction of an extension -->
+ <complexType name="base-b">
+ <sequence>
+ <element name="a" type="string" minOccurs="0"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <complexType name="extension-b">
+ <complexContent>
+ <extension base="t:base-b">
+ <choice>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string"/>
+ </choice>
+ <attribute name="y" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="restriction-b">
+ <complexContent>
+ <restriction base="t:extension-b">
+ <sequence>
+ <sequence>
+ <element name="a" type="string" minOccurs="1"/>
+ </sequence>
+ <choice>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string"/>
+ </choice>
+ </sequence>
+ <attribute name="y" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <complexType name="type-b">
+ <choice maxOccurs="unbounded">
+ <element name="restriction-a" type="t:base-a"/>
+ <element name="restriction-b" type="t:extension-b"/>
+ </choice>
+ </complexType>
+
+ <complexType name="type-r">
+ <choice maxOccurs="unbounded">
+ <element name="restriction-a" type="t:restriction-a"/>
+ <element name="restriction-b" type="t:restriction-b"/>
+ </choice>
+ </complexType>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/restriction/testscript b/xsd-tests/cxx/parser/validation/restriction/testscript
new file mode 100644
index 0000000..ea5a4e8
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/restriction/testscript
@@ -0,0 +1,159 @@
+# file : cxx/parser/validation/all/testscript
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+test.arguments += test.xml
+
+: valid
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <restriction-a z="z">
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ <restriction-a x="x" y="y" z="z">
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ <restriction-b y="y">
+ <a>a</a>
+ <b>b</b>
+ </restriction-b>
+
+ <restriction-b y="y">
+ <a>a</a>
+ <c>c</c>
+ </restriction-b>
+
+ <restriction-b x="x" y="y">
+ <a>a</a>
+ </restriction-b>
+
+ </t:root>
+ EOI
+
+ $*
+}
+
+: invalid1
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid base but not restriction: a element -->
+ <restriction-a z="z">
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ :7:8 error: expected element 'a' instead of 'b'
+ EOO
+}
+
+: invalid2
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid base but not restriction: z attribute -->
+ <restriction-a>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ :10:19 error: expected attribute 'z'
+ EOO
+}
+
+: invalid3
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid base but not restriction: sequence maxOccurs="1" -->
+ <restriction-a z="z">
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ :11:8 error: unexpected element 'a'
+ EOO
+}
+
+: invalid4
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid extension but not restriction: a element -->
+ <restriction-b y="y">
+ <b>b</b>
+ </restriction-b>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ :7:8 error: expected element 'a' instead of 'b'
+ EOO
+}
+
+: invalid5
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid extension but not restriction: y attribute -->
+ <restriction-b>
+ <a>a</a>
+ <b>b</b>
+ </restriction-b>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ :9:19 error: expected attribute 'y'
+ EOO
+}
diff --git a/xsd-tests/cxx/parser/validation/sequence/buildfile b/xsd-tests/cxx/parser/validation/sequence/buildfile
new file mode 100644
index 0000000..b205091
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/sequence/buildfile
@@ -0,0 +1,22 @@
+# file : cxx/parser/validation/sequence/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+import libs += libxerces-c%lib{xerces-c}
+
+exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \
+ testscript
+
+<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd
+{{
+ diag xsd ($<[0]) # @@ TMP
+
+ $xsd cxx-parser --std c++11 \
+ --generate-inline \
+ --skel-file-suffix -pskel \
+ --output-dir $out_base \
+ --generate-validation \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
diff --git a/xsd-tests/cxx/parser/validation/sequence/driver.cxx b/xsd-tests/cxx/parser/validation/sequence/driver.cxx
new file mode 100644
index 0000000..6b5bf70
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/sequence/driver.cxx
@@ -0,0 +1,139 @@
+// file : cxx/parser/validation/sequence/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the sequence compositor validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct sequence_pimpl: sequence_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+
+ virtual void
+ d (string const& v)
+ {
+ cout << " d = " << v << endl;
+ }
+
+ virtual void
+ e (string const& v)
+ {
+ cout << " e = " << v << endl;
+ }
+
+ virtual void
+ f (string const& v)
+ {
+ cout << " f = " << v << endl;
+ }
+
+ virtual void
+ _start_any_element (ro_string const& ns,
+ ro_string const& name,
+ ro_string const*)
+ {
+ cout << " any: " << ns << "#" << name << endl
+ << " {" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& v)
+ {
+ cout << " chars = " << v << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const&)
+ {
+ cout << " }" << endl;
+ }
+
+ virtual void
+ post_sequence ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ sequence_pimpl sequence_p;
+ type_pimpl type_p;
+
+ sequence_p.parsers (string_p, string_p, string_p,
+ string_p, string_p, string_p);
+ type_p.parsers (sequence_p);
+
+ xml_schema::document doc_p (type_p, "test", "root");
+
+ try
+ {
+ ifstream ifs (argv[1]);
+ type_p.pre ();
+ doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate);
+ type_p.post_type ();
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cout << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/xsd-tests/cxx/parser/validation/sequence/test.xsd b/xsd-tests/cxx/parser/validation/sequence/test.xsd
new file mode 100644
index 0000000..8753f54
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/sequence/test.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="sequence">
+ <sequence minOccurs="1" maxOccurs="2">
+ <element name="a" type="string" minOccurs="0"/>
+ <sequence>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string"/>
+ </sequence>
+ <element name="d" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <any namespace="##targetNamespace other"/>
+ <element name="f" type="string"/>
+ </sequence>
+ <element name="e" type="string" maxOccurs="2"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="sequence" type="t:sequence" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/xsd-tests/cxx/parser/validation/sequence/testscript b/xsd-tests/cxx/parser/validation/sequence/testscript
new file mode 100644
index 0000000..deebb9f
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/sequence/testscript
@@ -0,0 +1,328 @@
+# file : cxx/parser/validation/sequence/testscript
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+test.arguments += test.xml
+
+: valid
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <t:any>aaa<a>bbb</a>ccc</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ <sequence>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ <d>d</d>
+ <d>d</d>
+ <d>d</d>
+ <o:any>any</o:any>
+ <f>f</f>
+ <e>e</e>
+ <e>e</e>
+ </sequence>
+
+ <sequence>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ <d>d</d>
+ <d>d</d>
+ <d>d</d>
+ <o:any>any</o:any>
+ <f>f</f>
+ <e>e</e>
+ <e>e</e>
+
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = aaa
+ any: #a
+ {
+ chars = bbb
+ }
+ chars = ccc
+ }
+ f = f
+ e = e
+ }
+
+ {
+ a = a
+ b = b
+ c = c
+ d = d
+ d = d
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ e = e
+ }
+
+ {
+ a = a
+ b = b
+ c = c
+ d = d
+ d = d
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ e = e
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ }
+
+ EOO
+}
+
+: invalid1
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail minOccurs="1" -->
+ <sequence>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ :8:14 error: expected element 'a'
+ }
+
+ EOO
+}
+
+: invalid2
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail maxOccurs="2" -->
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ :20:8 error: unexpected element 'c'
+ }
+
+ EOO
+}
+
+: invalid3
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail a maxOccurs="1" -->
+ <sequence>
+ <a>a</a>
+ <a>a</a>
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ a = a
+ :9:8 error: expected element 'b' instead of 'a'
+ }
+
+ EOO
+}
+
+: invalid4
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail c minOccurs="1" -->
+ <sequence>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ :8:8 error: expected element 'a' instead of 'd'
+ }
+
+ EOO
+}
+
+: invalid5
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o1="other1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail any namespace="##targetNamespace other" -->
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <o1:any>any</o1:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ c = c
+ d = d
+ :10:13 error: expected element '##targetNamespace#*' instead of 'other1#any'
+ }
+
+ EOO
+}
+
+: invalid6
+:
+{
+ cat <<EOI >=test.xml;
+ <t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail e maxOccurs="2" -->
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ <e>e</e>
+ <e>e</e>
+ </sequence>
+
+ </t:root>
+ EOI
+
+ $* >>EOO
+ {
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ e = e
+ :14:8 error: unexpected element 'e'
+ }
+
+ EOO
+}