diff options
Diffstat (limited to 'xsd-tests/cxx/parser/validation/built-in/any-type')
5 files changed, 348 insertions, 0 deletions
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..9008472 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile @@ -0,0 +1,23 @@ +# file : cxx/parser/validation/built-in/any-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +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 + +cxx.poptions =+ "-I$out_base" + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser $xsd_cxx_std \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} 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> |