aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/hybrid
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/hybrid')
-rw-r--r--tests/cxx/hybrid/built-in/driver.cxx56
-rw-r--r--tests/cxx/hybrid/built-in/makefile88
-rw-r--r--tests/cxx/hybrid/built-in/output5
-rw-r--r--tests/cxx/hybrid/built-in/test.xml24
-rw-r--r--tests/cxx/hybrid/built-in/test.xsd125
-rw-r--r--tests/cxx/hybrid/choice/driver.cxx70
-rw-r--r--tests/cxx/hybrid/choice/makefile88
-rw-r--r--tests/cxx/hybrid/choice/output1
-rw-r--r--tests/cxx/hybrid/choice/test.xml57
-rw-r--r--tests/cxx/hybrid/choice/test.xsd174
-rw-r--r--tests/cxx/hybrid/compositor/includee.xsd14
-rw-r--r--tests/cxx/hybrid/compositor/includer.xsd14
-rw-r--r--tests/cxx/hybrid/compositor/test.xsd186
-rw-r--r--tests/cxx/hybrid/compositor/tmp.xsd87
-rw-r--r--tests/cxx/hybrid/file-per-type/a.xsd14
-rw-r--r--tests/cxx/hybrid/file-per-type/b.xsd16
-rw-r--r--tests/cxx/hybrid/file-per-type/test.xsd9
-rw-r--r--tests/cxx/hybrid/list/driver.cxx56
-rw-r--r--tests/cxx/hybrid/list/makefile88
-rw-r--r--tests/cxx/hybrid/list/output1
-rw-r--r--tests/cxx/hybrid/list/test.xml8
-rw-r--r--tests/cxx/hybrid/list/test.xsd35
-rw-r--r--tests/cxx/hybrid/makefile29
-rw-r--r--tests/cxx/hybrid/reorder/test.xsd26
-rw-r--r--tests/cxx/hybrid/sequences/driver.cxx442
-rw-r--r--tests/cxx/hybrid/sequences/makefile61
-rw-r--r--tests/cxx/hybrid/size/test.xsd136
-rw-r--r--tests/cxx/hybrid/test-template/driver.cxx56
-rw-r--r--tests/cxx/hybrid/test-template/makefile88
-rw-r--r--tests/cxx/hybrid/test-template/output1
-rw-r--r--tests/cxx/hybrid/test-template/test.xml5
-rw-r--r--tests/cxx/hybrid/test-template/test.xsd12
-rw-r--r--tests/cxx/hybrid/union/driver.cxx56
-rw-r--r--tests/cxx/hybrid/union/makefile88
-rw-r--r--tests/cxx/hybrid/union/output1
-rw-r--r--tests/cxx/hybrid/union/test.xml6
-rw-r--r--tests/cxx/hybrid/union/test.xsd26
37 files changed, 2249 insertions, 0 deletions
diff --git a/tests/cxx/hybrid/built-in/driver.cxx b/tests/cxx/hybrid/built-in/driver.cxx
new file mode 100644
index 0000000..6204882
--- /dev/null
+++ b/tests/cxx/hybrid/built-in/driver.cxx
@@ -0,0 +1,56 @@
+// file : tests/cxx/hybrid/built-in/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test built-in types.
+//
+
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.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;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/built-in/makefile b/tests/cxx/hybrid/built-in/makefile
new file mode 100644
index 0000000..c62315c
--- /dev/null
+++ b/tests/cxx/hybrid/built-in/makefile
@@ -0,0 +1,88 @@
+# file : tests/cxx/hybrid/built-in/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+gen := $(out_base)/$(xsd:.xsd=.hxx) \
+ $(out_base)/$(xsd:.xsd=.cxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.cxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.cxx)
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/built-in/output b/tests/cxx/hybrid/built-in/output
new file mode 100644
index 0000000..6798590
--- /dev/null
+++ b/tests/cxx/hybrid/built-in/output
@@ -0,0 +1,5 @@
+<t:root xmlns:t="test"><any></any><any-res x="x"><a>123</a><b>abc</b></any-res><any-simple></any-simple><any-simple-ext x="x"></any-simple-ext><int>123</int><simple-int>456</simple-int><int-base x="x">789</int-base><int-derived x="x" y="y">123</int-derived><bin>YmFzZTY0IGJpbmFyeQ==
+</bin><simple-bin>YmFzZTY0IGJpbmFyeQ==
+</simple-bin><bin-base x="x">YmFzZTY0IGJpbmFyeQ==
+</bin-base><bin-derived x="x" y="y">YmFzZTY0IGJpbmFyeQ==
+</bin-derived><string>abc</string><simple-string>def</simple-string><string-base x="x">ghi</string-base><string-derived x="x" y="y">jkl</string-derived></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/built-in/test.xml b/tests/cxx/hybrid/built-in/test.xml
new file mode 100644
index 0000000..ae72e80
--- /dev/null
+++ b/tests/cxx/hybrid/built-in/test.xml
@@ -0,0 +1,24 @@
+<t:root xmlns:t="test" any-simple-attr="">
+
+ <any></any>
+ <any-res x="x"><a>123</a><b>abc</b></any-res>
+
+ <any-simple></any-simple>
+ <any-simple-ext x="x"></any-simple-ext>
+
+ <int>123</int>
+ <simple-int>456</simple-int>
+ <int-base x="x">789</int-base>
+ <int-derived x="x" y="y">123</int-derived>
+
+ <bin>YmFzZTY0IGJpbmFyeQ==</bin>
+ <simple-bin>YmFzZTY0IGJpbmFyeQ==</simple-bin>
+ <bin-base x="x">YmFzZTY0IGJpbmFyeQ==</bin-base>
+ <bin-derived x="x" y="y">YmFzZTY0IGJpbmFyeQ==</bin-derived>
+
+ <string>abc</string>
+ <simple-string>def</simple-string>
+ <string-base x="x">ghi</string-base>
+ <string-derived x="x" y="y">jkl</string-derived>
+
+</t:root>
diff --git a/tests/cxx/hybrid/built-in/test.xsd b/tests/cxx/hybrid/built-in/test.xsd
new file mode 100644
index 0000000..1481d4f
--- /dev/null
+++ b/tests/cxx/hybrid/built-in/test.xsd
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- anyType -->
+
+ <complexType name="any-res">
+ <complexContent>
+ <restriction base="anyType">
+ <sequence>
+ <element name="a" type="int"/>
+ <element name="b" type="string"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <!-- anySimpleType -->
+
+ <complexType name="any-simple-ext">
+ <simpleContent>
+ <extension base="anySimpleType">
+ <attribute name="x" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+
+ <!-- int -->
+
+ <simpleType name="simple-int">
+ <restriction base="int"/>
+ </simpleType>
+
+ <complexType name="int-base">
+ <simpleContent>
+ <extension base="int">
+ <attribute name="x" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="int-derived">
+ <simpleContent>
+ <extension base="t:int-base">
+ <attribute name="y" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <!-- base64Binary -->
+
+ <simpleType name="simple-bin">
+ <restriction base="base64Binary"/>
+ </simpleType>
+
+ <complexType name="bin-base">
+ <simpleContent>
+ <extension base="base64Binary">
+ <attribute name="x" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="bin-derived">
+ <simpleContent>
+ <extension base="t:bin-base">
+ <attribute name="y" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <!-- string -->
+
+ <simpleType name="simple-string">
+ <restriction base="string"/>
+ </simpleType>
+
+ <complexType name="string-base">
+ <simpleContent>
+ <extension base="string">
+ <attribute name="x" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="string-derived">
+ <simpleContent>
+ <extension base="t:string-base">
+ <attribute name="y" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+
+ <element name="any" type="anyType"/>
+ <element name="any-res" type="t:any-res"/>
+
+ <element name="any-simple" type="anySimpleType"/>
+ <element name="any-simple-ext" type="t:any-simple-ext"/>
+
+ <element name="int" type="int"/>
+ <element name="simple-int" type="t:simple-int"/>
+ <element name="int-base" type="t:int-base"/>
+ <element name="int-derived" type="t:int-derived"/>
+
+ <element name="bin" type="base64Binary"/>
+ <element name="simple-bin" type="t:simple-bin"/>
+ <element name="bin-base" type="t:bin-base"/>
+ <element name="bin-derived" type="t:bin-derived"/>
+
+ <element name="string" type="string"/>
+ <element name="simple-string" type="t:simple-string"/>
+ <element name="string-base" type="t:string-base"/>
+ <element name="string-derived" type="t:string-derived"/>
+
+ </sequence>
+ <attribute name="any-simple-attr" type="anySimpleType"/>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/choice/driver.cxx b/tests/cxx/hybrid/choice/driver.cxx
new file mode 100644
index 0000000..0ba13de
--- /dev/null
+++ b/tests/cxx/hybrid/choice/driver.cxx
@@ -0,0 +1,70 @@
+// file : tests/cxx/hybrid/choice/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test choice mapping.
+//
+
+#include <cassert>
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.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;
+ }
+
+#ifdef XSDE_STL
+ {
+ test1 x;
+ x.b ("foo");
+ test1 y (x);
+ assert (y.b () == "foo");
+ test1 z;
+ y.a (123);
+ z = y;
+ assert (z.a () == 123);
+ }
+#endif
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/choice/makefile b/tests/cxx/hybrid/choice/makefile
new file mode 100644
index 0000000..cd256ff
--- /dev/null
+++ b/tests/cxx/hybrid/choice/makefile
@@ -0,0 +1,88 @@
+# file : tests/cxx/hybrid/choice/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+gen := $(out_base)/$(xsd:.xsd=.hxx) \
+ $(out_base)/$(xsd:.xsd=.cxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.cxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.cxx)
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/choice/output b/tests/cxx/hybrid/choice/output
new file mode 100644
index 0000000..b299e90
--- /dev/null
+++ b/tests/cxx/hybrid/choice/output
@@ -0,0 +1 @@
+<t:root xmlns:t="test"><test2><a>123</a></test2><test2><b>abc</b><b>def</b></test2><test2><c><a>1.23</a><b>123</b></c></test2><test2><d><a>true</a><a>false</a><b>abc</b></d></test2><test2><e></e></test2><test2><s1>1.23</s1><s2>123</s2></test2><test2><s3>1.23</s3><s4>123</s4></test2><test2><s5>1.23</s5><s6>123</s6><s5>4.56</s5><s6>456</s6></test2><test3><f1>1.23</f1><v1>true</v1><f5>1.23</f5><v5>true</v5></test3><test3><f2>123</f2><v2><a>true</a><a>false</a><b>abc</b></v2><f3>1.23</f3><v3>true</v3><f6>123</f6><f5>1.23</f5><v6><a>true</a><a>false</a><b>abc</b></v6><v5>true</v5></test3><test4><f1>1.23</f1></test4><test4><v1>true</v1></test4><test4><f5>1.23</f5></test4><test4><v5>true</v5></test4><test4><f2>123</f2></test4><test4><v2><a>true</a><a>false</a><b>abc</b></v2></test4><test4><f3>1.23</f3></test4><test4><v3>true</v3></test4><test4><f6>123</f6><f5>1.23</f5></test4><test4><v6><a>true</a><a>false</a><b>abc</b></v6><v5>true</v5></test4><test5a></test5a><test5b><d>true</d></test5b><test5c><d>true</d></test5c><test5d></test5d></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/choice/test.xml b/tests/cxx/hybrid/choice/test.xml
new file mode 100644
index 0000000..48f06fd
--- /dev/null
+++ b/tests/cxx/hybrid/choice/test.xml
@@ -0,0 +1,57 @@
+<t:root xmlns:t="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- test 2 -->
+
+ <test2><a>123</a></test2>
+
+ <test2><b>abc</b><b>def</b></test2>
+
+ <test2><c><a>1.23</a><b>123</b></c></test2>
+
+ <test2><d><a>true</a><a>false</a><b>abc</b></d></test2>
+
+ <test2><e/></test2>
+
+ <test2><s1>1.23</s1><s2>123</s2></test2>
+ <test2><s3>1.23</s3><s4>123</s4></test2>
+ <test2><s5>1.23</s5><s6>123</s6><s5>4.56</s5><s6>456</s6></test2>
+
+ <!-- test 3 -->
+
+ <test3>
+ <f1>1.23</f1>
+ <v1>true</v1>
+ <f5>1.23</f5>
+ <v5>true</v5></test3>
+
+ <test3>
+ <f2>123</f2>
+ <v2><a>true</a><a>false</a><b>abc</b></v2>
+ <f3>1.23</f3>
+ <v3>true</v3>
+ <f6>123</f6><f5>1.23</f5>
+ <v6><a>true</a><a>false</a><b>abc</b></v6><v5>true</v5>
+ </test3>
+
+ <!-- test 4 -->
+
+ <test4><f1>1.23</f1></test4>
+ <test4><v1>true</v1></test4>
+ <test4><f5>1.23</f5></test4>
+ <test4><v5>true</v5></test4>
+ <test4><f2>123</f2></test4>
+ <test4><v2><a>true</a><a>false</a><b>abc</b></v2></test4>
+ <test4><f3>1.23</f3></test4>
+ <test4><v3>true</v3></test4>
+ <test4><f6>123</f6><f5>1.23</f5></test4>
+ <test4><v6><a>true</a><a>false</a><b>abc</b></v6><v5>true</v5></test4>
+
+ <!-- test 5 -->
+
+ <test5a></test5a>
+ <test5b><d>true</d></test5b>
+ <test5c><d>true</d></test5c>
+ <test5d></test5d>
+
+</t:root>
diff --git a/tests/cxx/hybrid/choice/test.xsd b/tests/cxx/hybrid/choice/test.xsd
new file mode 100644
index 0000000..9fe5f5c
--- /dev/null
+++ b/tests/cxx/hybrid/choice/test.xsd
@@ -0,0 +1,174 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="fix">
+ <sequence>
+ <element name="a" type="double" minOccurs="0"/>
+ <element name="b" type="int"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var">
+ <sequence>
+ <element name="a" type="boolean" maxOccurs="unbounded"/>
+ <element name="b" type="string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="empty">
+ <sequence/>
+ </complexType>
+
+
+ <!-- test 1: fixed choice copying/assignment -->
+
+ <complexType name="test1">
+ <choice>
+ <element name="a" type="int"/>
+ <element name="b" type="string"/>
+ </choice>
+ </complexType>
+
+ <!-- test 2: general -->
+
+ <complexType name="test2">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <element name="c" type="t:fix"/>
+ <element name="d" type="t:var"/>
+ <element name="e" type="t:empty"/>
+ <sequence>
+ <element name="s1" type="double"/>
+ <element name="s2" type="int"/>
+ </sequence>
+ <sequence minOccurs="0">
+ <element name="s3" type="double"/>
+ <element name="s4" type="int"/>
+ </sequence>
+ <sequence maxOccurs="unbounded">
+ <element name="s5" type="double"/>
+ <element name="s6" type="int"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <!-- test 3: choice cardinalities -->
+
+ <complexType name="test3">
+ <sequence>
+ <choice>
+ <element name="f1" type="double"/>
+ <element name="f2" type="int"/>
+ </choice>
+ <choice>
+ <element name="v1" type="boolean"/>
+ <element name="v2" type="t:var"/>
+ </choice>
+ <choice minOccurs="0">
+ <element name="f3" type="double"/>
+ <element name="f4" type="int"/>
+ </choice>
+ <choice minOccurs="0">
+ <element name="v3" type="boolean"/>
+ <element name="v4" type="t:var"/>
+ </choice>
+ <choice maxOccurs="unbounded">
+ <element name="f5" type="double"/>
+ <element name="f6" type="int"/>
+ </choice>
+ <choice maxOccurs="unbounded">
+ <element name="v5" type="boolean"/>
+ <element name="v6" type="t:var"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <!-- test 4: nested choice -->
+
+ <complexType name="test4">
+ <choice minOccurs="0">
+ <choice>
+ <element name="f1" type="double"/>
+ <element name="f2" type="int"/>
+ </choice>
+ <choice>
+ <element name="v1" type="boolean"/>
+ <element name="v2" type="t:var"/>
+ </choice>
+ <choice minOccurs="0">
+ <element name="f3" type="double"/>
+ <element name="f4" type="int"/>
+ </choice>
+ <choice minOccurs="0">
+ <element name="v3" type="boolean"/>
+ <element name="v4" type="t:var"/>
+ </choice>
+ <choice maxOccurs="unbounded">
+ <element name="f5" type="double"/>
+ <element name="f6" type="int"/>
+ </choice>
+ <choice maxOccurs="unbounded">
+ <element name="v5" type="boolean"/>
+ <element name="v6" type="t:var"/>
+ </choice>
+ </choice>
+ </complexType>
+
+ <!-- test 5: required choice with optional element-->
+
+ <complexType name="test5a">
+ <choice>
+ <element name="a" type="int"/>
+ <element name="b" type="double" minOccurs="0"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </complexType>
+
+ <complexType name="test5b">
+ <sequence>
+ <choice>
+ <element name="a" type="int"/>
+ <element name="b" type="double" minOccurs="0"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ <element name="d" type="boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="test5c">
+ <sequence>
+ <element name="d" type="boolean"/>
+ <choice>
+ <element name="a" type="int"/>
+ <element name="b" type="double" minOccurs="0"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="test5d">
+ <choice>
+ <choice>
+ <element name="a" type="int"/>
+ <element name="b" type="double" minOccurs="0"/>
+ </choice>
+ <element name="c" type="boolean"/>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="test2" type="t:test2" maxOccurs="unbounded"/>
+ <element name="test3" type="t:test3" maxOccurs="unbounded"/>
+ <element name="test4" type="t:test4" maxOccurs="unbounded"/>
+ <element name="test5a" type="t:test5a" maxOccurs="unbounded"/>
+ <element name="test5b" type="t:test5b" maxOccurs="unbounded"/>
+ <element name="test5c" type="t:test5c" maxOccurs="unbounded"/>
+ <element name="test5d" type="t:test5d" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/compositor/includee.xsd b/tests/cxx/hybrid/compositor/includee.xsd
new file mode 100644
index 0000000..1def761
--- /dev/null
+++ b/tests/cxx/hybrid/compositor/includee.xsd
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="test"
+ targetNamespace="test">
+
+ <complexType name="member">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/compositor/includer.xsd b/tests/cxx/hybrid/compositor/includer.xsd
new file mode 100644
index 0000000..fc730e4
--- /dev/null
+++ b/tests/cxx/hybrid/compositor/includer.xsd
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:T="test"
+ targetNamespace="test">
+
+ <include schemaLocation="includee.xsd"/>
+
+ <complexType name="container">
+ <choice>
+ <element name="a" type="T:member" maxOccurs="unbounded"/>
+ </choice>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/compositor/test.xsd b/tests/cxx/hybrid/compositor/test.xsd
new file mode 100644
index 0000000..3d1b1ce
--- /dev/null
+++ b/tests/cxx/hybrid/compositor/test.xsd
@@ -0,0 +1,186 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- all -->
+
+ <complexType name="all-1">
+ <all>
+ <element name="a" type="int"/>
+ <element name="b" type="string"/>
+ </all>
+ </complexType>
+
+ <complexType name="all-2">
+ <all minOccurs="0">
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" minOccurs="0"/>
+ </all>
+ </complexType>
+
+ <!-- sequence -->
+
+ <complexType name="sequence-1">
+ <sequence>
+ <element name="a" type="int"/>
+ <sequence>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-2">
+ <sequence minOccurs="0">
+ <element name="a" type="int"/>
+ <sequence minOccurs="0">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-3">
+ <sequence maxOccurs="unbounded">
+ <element name="a" type="int"/>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-4">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-5">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice minOccurs="0">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-6">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-7">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice>
+ <element name="b" type="string"/>
+ <sequence>
+ <element name="c" type="boolean"/>
+ <element name="d" type="float"/>
+ </sequence>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-8">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice>
+ <element name="b" type="string"/>
+ <sequence minOccurs="0">
+ <element name="c" type="boolean"/>
+ <element name="d" type="float"/>
+ </sequence>
+ </choice>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-9">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice>
+ <element name="b" type="string"/>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element name="c" type="boolean"/>
+ <element name="d" type="float"/>
+ </sequence>
+ </choice>
+ </sequence>
+ </complexType>
+
+
+ <complexType name="sequence-10">
+ <sequence>
+ <element name="a" type="int"/>
+ <sequence minOccurs="0">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </sequence>
+ <sequence maxOccurs="unbounded">
+ <element name="d" type="string"/>
+ <element name="e" type="boolean"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+ <!-- choice -->
+
+ <complexType name="choice-1">
+ <choice>
+ <element name="a" type="int"/>
+ <choice>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ <element name="d" type="string" minOccurs="0"/>
+ <element name="e" type="boolean" minOccurs="0"/>
+ <element name="f" type="string" maxOccurs="unbounded"/>
+ <element name="g" type="boolean" maxOccurs="unbounded"/>
+ </choice>
+ </choice>
+ </complexType>
+
+ <complexType name="choice-2">
+ <choice minOccurs="0">
+ <element name="a" type="int"/>
+ <choice minOccurs="0">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </choice>
+ </complexType>
+
+ <complexType name="choice-3">
+ <choice maxOccurs="unbounded">
+ <element name="a" type="int"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ </choice>
+ </complexType>
+
+ <complexType name="choice-4">
+ <sequence>
+ <element name="a" type="int"/>
+ <choice>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ </choice>
+ <choice>
+ <element name="d" type="string"/>
+ <element name="e" type="boolean"/>
+ </choice>
+ </sequence>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/compositor/tmp.xsd b/tests/cxx/hybrid/compositor/tmp.xsd
new file mode 100644
index 0000000..fc3a4bd
--- /dev/null
+++ b/tests/cxx/hybrid/compositor/tmp.xsd
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="fixed">
+ <sequence>
+ <element name="a" type="boolean" minOccurs="0"/>
+ <element name="b" type="int"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="fix-ext">
+ <complexContent>
+ <extension base="t:fixed">
+ <sequence>
+ <element name="c" type="int"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="var-ext">
+ <complexContent>
+ <extension base="t:fixed">
+ <sequence>
+ <element name="c" type="string"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="var-ext2">
+ <complexContent>
+ <extension base="t:var-ext">
+ <sequence>
+ <element name="d" type="string"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="sequence-1">
+ <choice maxOccurs="unbounded">
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <element name="c" type="boolean"/>
+ <sequence maxOccurs="unbounded">
+ <element name="d" type="string"/>
+ <element name="e" type="boolean"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <complexType name="sequence-1a">
+ <choice>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ <sequence minOccurs="1">
+ <element name="d" type="string"/>
+ <element name="e" type="boolean"/>
+ </sequence>
+ </choice>
+ </complexType>
+
+ <complexType name="sequence-2">
+ <sequence maxOccurs="10">
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="string"/>
+ <element name="c" type="boolean"/>
+ <sequence maxOccurs="20">
+ <element name="d" type="string"/>
+ <element name="e" type="boolean"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+ <complexType name="sequence-3">
+ <sequence maxOccurs="unbounded">
+ <element name="a" type="int" minOccurs="0"/>
+ <sequence maxOccurs="unbounded">
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <element name="c" type="boolean"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/file-per-type/a.xsd b/tests/cxx/hybrid/file-per-type/a.xsd
new file mode 100644
index 0000000..9abe165
--- /dev/null
+++ b/tests/cxx/hybrid/file-per-type/a.xsd
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <include schemaLocation="b.xsd"/>
+
+ <complexType name="base">
+ <sequence>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="boolean"/>
+ <element name="c" type="t:derived" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/file-per-type/b.xsd b/tests/cxx/hybrid/file-per-type/b.xsd
new file mode 100644
index 0000000..f10ad4c
--- /dev/null
+++ b/tests/cxx/hybrid/file-per-type/b.xsd
@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <include schemaLocation="a.xsd"/>
+
+ <complexType name="derived">
+ <complexContent>
+ <extension base="t:base">
+ <sequence>
+ <element name="d" type="double"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/file-per-type/test.xsd b/tests/cxx/hybrid/file-per-type/test.xsd
new file mode 100644
index 0000000..ebb2f23
--- /dev/null
+++ b/tests/cxx/hybrid/file-per-type/test.xsd
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <include schemaLocation="a.xsd"/>
+ <include schemaLocation="b.xsd"/>
+
+ <element name="root" type="t:derived"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/list/driver.cxx b/tests/cxx/hybrid/list/driver.cxx
new file mode 100644
index 0000000..5d6b20e
--- /dev/null
+++ b/tests/cxx/hybrid/list/driver.cxx
@@ -0,0 +1,56 @@
+// file : tests/cxx/hybrid/list/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test list mapping.
+//
+
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.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;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/list/makefile b/tests/cxx/hybrid/list/makefile
new file mode 100644
index 0000000..5d70a97
--- /dev/null
+++ b/tests/cxx/hybrid/list/makefile
@@ -0,0 +1,88 @@
+# file : tests/cxx/hybrid/list/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+gen := $(out_base)/$(xsd:.xsd=.hxx) \
+ $(out_base)/$(xsd:.xsd=.cxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.cxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.cxx)
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/list/output b/tests/cxx/hybrid/list/output
new file mode 100644
index 0000000..6c1ac43
--- /dev/null
+++ b/tests/cxx/hybrid/list/output
@@ -0,0 +1 @@
+<t:root xmlns:t="test"><int-list>123 456 789</int-list><qname-list>one t:two three</qname-list><string-list>abc def ghi</string-list><string-list-lang lang="fr">abc def ghi</string-list-lang></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/list/test.xml b/tests/cxx/hybrid/list/test.xml
new file mode 100644
index 0000000..2451a4b
--- /dev/null
+++ b/tests/cxx/hybrid/list/test.xml
@@ -0,0 +1,8 @@
+<t:root xmlns:t="test">
+
+ <int-list>123 456 789</int-list>
+ <qname-list>one t:two three</qname-list>
+ <string-list>abc def ghi</string-list>
+ <string-list-lang lang="fr">abc def ghi</string-list-lang>
+
+</t:root>
diff --git a/tests/cxx/hybrid/list/test.xsd b/tests/cxx/hybrid/list/test.xsd
new file mode 100644
index 0000000..d864b12
--- /dev/null
+++ b/tests/cxx/hybrid/list/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="int-list">
+ <list itemType="int"/>
+ </simpleType>
+
+ <simpleType name="qname-list">
+ <list itemType="QName"/>
+ </simpleType>
+
+ <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">
+ <sequence>
+ <element name="int-list" type="t:int-list"/>
+ <element name="qname-list" type="t:qname-list"/>
+ <element name="string-list" type="t:string-list"/>
+ <element name="string-list-lang" type="t:string-list-lang"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile
new file mode 100644
index 0000000..3351241
--- /dev/null
+++ b/tests/cxx/hybrid/makefile
@@ -0,0 +1,29 @@
+# file : tests/cxx/hybrid/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
+
+tests := sequences
+
+ifeq ($(xsde_iostream),y)
+tests += built-in list test-template union
+
+ifeq ($(xsde_parser_validation),y)
+tests += choice
+endif
+
+endif
+
+default := $(out_base)/
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+.PHONY: $(default) $(test) $(clean)
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/tests/cxx/hybrid/reorder/test.xsd b/tests/cxx/hybrid/reorder/test.xsd
new file mode 100644
index 0000000..1b610cc
--- /dev/null
+++ b/tests/cxx/hybrid/reorder/test.xsd
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="container">
+ <sequence>
+ <element name="c" type="t:member"/>
+ <element name="d" type="t:member" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="member">
+ <sequence>
+ <element name="a" type="int" minOccurs="0"/>
+ <element name="b" type="boolean"/>
+ </sequence>
+ </complexType>
+
+ <simpleType name="list">
+ <list itemType="t:item"/>
+ </simpleType>
+
+ <simpleType name="item">
+ <restriction base="int"/>
+ </simpleType>
+
+</schema>
diff --git a/tests/cxx/hybrid/sequences/driver.cxx b/tests/cxx/hybrid/sequences/driver.cxx
new file mode 100644
index 0000000..3d6c702
--- /dev/null
+++ b/tests/cxx/hybrid/sequences/driver.cxx
@@ -0,0 +1,442 @@
+// file : tests/cxx/hybrid/sequences/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test sequence templates.
+//
+#include <string>
+#include <cassert>
+
+#include <xsde/cxx/config.hxx>
+
+#ifndef XSDE_STL
+#include <xsde/cxx/strdupx.hxx>
+#endif
+
+#include <xsde/cxx/hybrid/sequence.hxx>
+
+using std::string;
+using namespace xsde::cxx::hybrid;
+
+void data_destructor (void* p, size_t)
+{
+ delete static_cast<string*> (p);
+}
+
+void data_destructor_pos (void* p, size_t i)
+{
+ switch (i)
+ {
+ case 0:
+ {
+ delete static_cast<string*> (p);
+ break;
+ }
+ case 1:
+ {
+ delete static_cast<int*> (p);
+ break;
+ }
+ }
+}
+
+int
+main ()
+{
+ //
+ // pod_seq
+ //
+ typedef pod_seq<int> pod;
+
+ {
+ pod s;
+ s.push_back (111);
+ assert (s.size () == 1 && s[0] == 111);
+ s.pop_back ();
+ assert (s.size () == 0);
+ }
+
+ {
+ pod s;
+ s.push_back (111);
+ s.erase (s.begin ());
+ assert (s.size () == 0);
+
+ s.push_back (111);
+ s.push_back (222);
+ s.push_back (333);
+ s.erase (s.begin ());
+ assert (s.size () == 2 && s[0] == 222 && s[1] == 333);
+
+ s.push_back (444);
+ s.erase (s.begin () + 1);
+ assert (s.size () == 2 && s[0] == 222 && s[1] == 444);
+
+ s.push_back (555);
+ s.erase (s.begin () + 2);
+ assert (s.size () == 2 && s[0] == 222 && s[1] == 444);
+ }
+
+ {
+ pod s;
+ s.reserve (2);
+ s.push_back (111);
+ s.push_back (222);
+ s.push_back (333);
+ assert (s.size () == 3 && s[0] == 111 && s[1] == 222 && s[2] == 333);
+ }
+
+ {
+ pod s;
+ s.insert (s.begin (), 111);
+ assert (s.size () == 1 && s[0] == 111);
+ s.push_back (222);
+ s.push_back (333);
+
+ s.insert (s.begin (), 444);
+ assert (s[0] == 444);
+
+ s.insert (s.begin () + 1, 555);
+ assert (s[1] == 555);
+
+ s.insert (s.end (), 666);
+ assert (s[5] == 666);
+
+ assert (s[0] == 444 && s[1] == 555 && s[2] == 111 &&
+ s[3] == 222 && s[4] == 333 && s[5] == 666);
+ }
+
+ {
+ pod s;
+ s.reserve (2);
+ s.push_back (111);
+ s.push_back (222);
+ s.insert (s.begin () + 1, 333);
+ assert (s[0] == 111 && s[1] == 333 && s[2] == 222);
+ }
+
+ //
+ // fix_seq
+ //
+ typedef fix_seq<string> fix;
+
+ {
+ fix s;
+ s.push_back ("aaa");
+ assert (s.size () == 1 && s[0] == "aaa");
+ s.pop_back ();
+ assert (s.size () == 0);
+ }
+
+ {
+ fix s;
+ s.push_back ("aaa");
+ s.erase (s.begin ());
+ assert (s.size () == 0);
+
+ s.push_back ("aaa");
+ s.push_back ("bbb");
+ s.push_back ("ccc");
+ s.erase (s.begin ());
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ccc");
+
+ s.push_back ("ddd");
+ s.erase (s.begin () + 1);
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd");
+
+ s.push_back ("eee");
+ s.erase (s.begin () + 2);
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd");
+ }
+
+ {
+ fix s;
+ s.reserve (2);
+ s.push_back ("aaa");
+ s.push_back ("bbb");
+ s.push_back ("ccc");
+ assert (s.size () == 3 && s[0] == "aaa" &&
+ s[1] == "bbb" && s[2] == "ccc");
+ }
+
+ {
+ fix s;
+ s.insert (s.begin (), "aaa");
+ assert (s.size () == 1 && s[0] == "aaa");
+ s.push_back ("bbb");
+ s.push_back ("ccc");
+
+ s.insert (s.begin (), "ddd");
+ assert (s[0] == "ddd");
+
+ s.insert (s.begin () + 1, "eee");
+ assert (s[1] == "eee");
+
+ s.insert (s.end (), "fff");
+ assert (s[5] == "fff");
+
+ assert (s[0] == "ddd" && s[1] == "eee" && s[2] == "aaa" &&
+ s[3] == "bbb" && s[4] == "ccc" && s[5] == "fff");
+ }
+
+ {
+ fix s;
+ s.reserve (2);
+ s.push_back ("aaa");
+ s.push_back ("bbb");
+ s.insert (s.begin () + 1, "ccc");
+ assert (s[0] == "aaa" && s[1] == "ccc" && s[2] == "bbb");
+ }
+
+ //
+ // var_seq
+ //
+ typedef var_seq<string> var;
+
+ {
+ var s;
+ s.push_back (new string ("aaa"));
+ assert (s.size () == 1 && s[0] == "aaa");
+ s.pop_back ();
+ assert (s.size () == 0);
+ }
+
+ {
+ var s;
+ s.push_back (new string ("aaa"));
+ s.erase (s.begin ());
+ assert (s.size () == 0);
+
+ s.push_back (new string ("aaa"));
+ s.push_back (new string ("bbb"));
+ s.push_back (new string ("ccc"));
+ s.erase (s.begin ());
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ccc");
+
+ s.push_back (new string ("ddd"));
+ s.erase (s.begin () + 1);
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd");
+
+ s.push_back (new string ("eee"));
+ s.erase (s.begin () + 2);
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd");
+ }
+
+ {
+ var s;
+ s.reserve (2);
+ s.push_back (new string ("aaa"));
+ s.push_back (new string ("bbb"));
+ s.push_back (new string ("ccc"));
+ assert (s.size () == 3 && s[0] == "aaa" &&
+ s[1] == "bbb" && s[2] == "ccc");
+ }
+
+ {
+ var s;
+ s.insert (s.begin (), new string ("aaa"));
+ assert (s.size () == 1 && s[0] == "aaa");
+ s.push_back (new string ("bbb"));
+ s.push_back (new string ("ccc"));
+
+ s.insert (s.begin (), new string ("ddd"));
+ assert (s[0] == "ddd");
+
+ s.insert (s.begin () + 1, new string ("eee"));
+ assert (s[1] == "eee");
+
+ s.insert (s.end (), new string ("fff"));
+ assert (s[5] == "fff");
+
+ assert (s[0] == "ddd" && s[1] == "eee" && s[2] == "aaa" &&
+ s[3] == "bbb" && s[4] == "ccc" && s[5] == "fff");
+ }
+
+ {
+ var s;
+ s.reserve (2);
+ s.push_back (new string ("aaa"));
+ s.push_back (new string ("bbb"));
+ s.insert (s.begin () + 1, new string ("ccc"));
+ assert (s[0] == "aaa" && s[1] == "ccc" && s[2] == "bbb");
+ }
+
+ //
+ // str_seq
+ //
+ typedef str_seq str;
+
+#ifndef XSDE_STL
+ using xsde::cxx::strdupx;
+
+ {
+ str s;
+ s.push_back (strdupx ("aaa"));
+ assert (s.size () == 1 && s[0] == string ("aaa"));
+ s.pop_back ();
+ assert (s.size () == 0);
+ }
+
+ {
+ str s;
+ s.push_back_copy ("aaa");
+ s.erase (s.begin ());
+ assert (s.size () == 0);
+
+ s.push_back_copy ("aaa");
+ s.push_back_copy ("bbb");
+ s.push_back_copy ("ccc");
+ s.erase (s.begin ());
+ assert (s.size () == 2 &&
+ s[0] == string ("bbb") && s[1] == string ("ccc"));
+
+ s.push_back_copy ("ddd");
+ s.erase (s.begin () + 1);
+ assert (s.size () == 2 &&
+ s[0] == string ("bbb") && s[1] == string ("ddd"));
+
+ s.push_back_copy ("eee");
+ s.erase (s.begin () + 2);
+ assert (s.size () == 2 &&
+ s[0] == string ("bbb") && s[1] == string ("ddd"));
+ }
+
+ {
+ str s;
+ s.reserve (2);
+ s.push_back_copy ("aaa");
+ s.push_back_copy ("bbb");
+ s.push_back_copy ("ccc");
+ assert (s.size () == 3 &&
+ s[0] == string ("aaa") &&
+ s[1] == string ("bbb") &&
+ s[2] == string ("ccc"));
+ }
+
+ {
+ str s;
+ s.insert (s.begin (), strdupx ("aaa"));
+ assert (s.size () == 1 && s[0] == string ("aaa"));
+ s.push_back_copy ("bbb");
+ s.push_back_copy ("ccc");
+
+ s.insert (s.begin (), strdupx ("ddd"));
+ assert (s[0] == string ("ddd"));
+
+ s.insert (s.begin () + 1, strdupx ("eee"));
+ assert (s[1] == string ("eee"));
+
+ s.insert (s.end (), strdupx ("fff"));
+ assert (s[5] == string ("fff"));
+
+ assert (s[0] == string ("ddd") && s[1] == string ("eee") &&
+ s[2] == string ("aaa") && s[3] == string ("bbb") &&
+ s[4] == string ("ccc") && s[5] == string ("fff"));
+ }
+
+ {
+ str s;
+ s.reserve (2);
+ s.push_back_copy ("aaa");
+ s.push_back_copy ("bbb");
+ s.insert (s.begin () + 1, strdupx ("ccc"));
+ assert (s[0] == string ("aaa") &&
+ s[1] == string ("ccc") &&
+ s[2] == string ("bbb"));
+ }
+
+#else
+
+ {
+ str s;
+ s.push_back ("aaa");
+ assert (s.size () == 1 && s[0] == "aaa");
+ s.pop_back ();
+ assert (s.size () == 0);
+ }
+
+ {
+ str s;
+ s.push_back ("aaa");
+ s.erase (s.begin ());
+ assert (s.size () == 0);
+
+ s.push_back ("aaa");
+ s.push_back ("bbb");
+ s.push_back ("ccc");
+ s.erase (s.begin ());
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ccc");
+
+ s.push_back ("ddd");
+ s.erase (s.begin () + 1);
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd");
+
+ s.push_back ("eee");
+ s.erase (s.begin () + 2);
+ assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd");
+ }
+
+ {
+ str s;
+ s.reserve (2);
+ s.push_back ("aaa");
+ s.push_back ("bbb");
+ s.push_back ("ccc");
+ assert (s.size () == 3 &&
+ s[0] == "aaa" && s[1] == "bbb" && s[2] == "ccc");
+ }
+
+ {
+ str s;
+ s.insert (s.begin (), "aaa");
+ assert (s.size () == 1 && s[0] == "aaa");
+ s.push_back ("bbb");
+ s.push_back ("ccc");
+
+ s.insert (s.begin (), "ddd");
+ assert (s[0] == "ddd");
+
+ s.insert (s.begin () + 1, "eee");
+ assert (s[1] == "eee");
+
+ s.insert (s.end (), "fff");
+ assert (s[5] == "fff");
+
+ assert (s[0] == "ddd" && s[1] == "eee" && s[2] == "aaa" &&
+ s[3] == "bbb" && s[4] == "ccc" && s[5] == "fff");
+ }
+
+ {
+ str s;
+ s.reserve (2);
+ s.push_back ("aaa");
+ s.push_back ("bbb");
+ s.insert (s.begin () + 1, "ccc");
+ assert (s[0] == "aaa" && s[1] == "ccc" && s[2] == "bbb");
+ }
+#endif
+
+ //
+ // data_seq
+ //
+ typedef data_seq data;
+
+ {
+ data s;
+ s.destructor (&data_destructor);
+ s.push_back (new string ("aaa"));
+ s.push_back (new string ("bbb"));
+ assert (*static_cast<string*> (s[0]) == "aaa" &&
+ *static_cast<string*> (s[1]) == "bbb");
+ }
+
+ {
+ data s;
+ s.destructor (&data_destructor_pos);
+ s.push_back (new string ("aaa"));
+ s.push_back (new int (5));
+ assert (*static_cast<string*> (s[0]) == "aaa" &&
+ *static_cast<int*> (s[1]) == 5);
+ }
+}
diff --git a/tests/cxx/hybrid/sequences/makefile b/tests/cxx/hybrid/sequences/makefile
new file mode 100644
index 0000000..41f5941
--- /dev/null
+++ b/tests/cxx/hybrid/sequences/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/hybrid/sequences/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o))
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep))
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/size/test.xsd b/tests/cxx/hybrid/size/test.xsd
new file mode 100644
index 0000000..e8e265d
--- /dev/null
+++ b/tests/cxx/hybrid/size/test.xsd
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- fixed -->
+
+ <complexType name="fixed-base">
+ <sequence>
+ <element name="a" type="int"/>
+ <element name="b" type="t:fixed-all" minOccurs="0"/>
+ </sequence>
+ <attribute name="x" type="double" use="required"/>
+ </complexType>
+
+ <complexType name="fixed-derived">
+ <complexContent>
+ <extension base="t:fixed-base">
+ <sequence>
+ <element name="c" type="float"/>
+ </sequence>
+ <attribute name="y" type="boolean"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="fixed-all">
+ <all>
+ <element name="a" type="int"/>
+ <element name="b" type="time" minOccurs="0"/>
+ </all>
+ <attribute name="x" type="double"/>
+ </complexType>
+
+ <!-- variable -->
+
+ <complexType name="var-el-string">
+ <all>
+ <element name="b" type="string"/>
+ </all>
+ <attribute name="x" type="double"/>
+ </complexType>
+
+ <complexType name="var-at-string">
+ <all>
+ <element name="b" type="int"/>
+ </all>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <complexType name="var-seq1">
+ <sequence>
+ <element name="b" type="int" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var-seq2">
+ <sequence maxOccurs="2">
+ <element name="a" type="int"/>
+ <element name="b" type="int"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var-choice">
+ <choice>
+ <element name="a" type="int"/>
+ <element name="b" type="boolean"/>
+ </choice>
+ </complexType>
+
+ <complexType name="var-var-mem">
+ <sequence>
+ <element name="a" type="int"/>
+ <element name="b" type="t:var-seq1"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var-var-base">
+ <complexContent>
+ <extension base="t:var-var-mem">
+ <sequence>
+ <element name="c" type="float"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="var-fwd1">
+ <sequence>
+ <element name="a" type="int"/>
+ <element name="b" type="t:var-fwd2"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var-fwd2">
+ <sequence>
+ <element name="a" type="int"/>
+ <element name="b" type="string"/>
+ </sequence>
+ </complexType>
+
+
+ <complexType name="var-mem-rec1">
+ <sequence>
+ <element name="a" type="t:var-mem-rec2"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var-mem-rec2">
+ <sequence>
+ <element name="a" type="t:var-mem-rec1" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+
+ <complexType name="var-base-rec1">
+ <sequence>
+ <element name="a" type="t:var-base-rec3"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="var-base-rec2">
+ <complexContent>
+ <extension base="t:var-base-rec1">
+ <sequence>
+ <element name="c" type="float"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="var-base-rec3">
+ <sequence>
+ <element name="a" type="t:var-base-rec2" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/hybrid/test-template/driver.cxx b/tests/cxx/hybrid/test-template/driver.cxx
new file mode 100644
index 0000000..c482a0c
--- /dev/null
+++ b/tests/cxx/hybrid/test-template/driver.cxx
@@ -0,0 +1,56 @@
+// file : tests/cxx/hybrid/test-template/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Insert test description here.
+//
+
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.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;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/test-template/makefile b/tests/cxx/hybrid/test-template/makefile
new file mode 100644
index 0000000..2a73ad9
--- /dev/null
+++ b/tests/cxx/hybrid/test-template/makefile
@@ -0,0 +1,88 @@
+# file : tests/cxx/hybrid/test-template/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+gen := $(out_base)/$(xsd:.xsd=.hxx) \
+ $(out_base)/$(xsd:.xsd=.cxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.cxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.cxx)
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/test-template/output b/tests/cxx/hybrid/test-template/output
new file mode 100644
index 0000000..66261f6
--- /dev/null
+++ b/tests/cxx/hybrid/test-template/output
@@ -0,0 +1 @@
+<t:root xmlns:t="test"><a>123</a></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/test-template/test.xml b/tests/cxx/hybrid/test-template/test.xml
new file mode 100644
index 0000000..1b7571e
--- /dev/null
+++ b/tests/cxx/hybrid/test-template/test.xml
@@ -0,0 +1,5 @@
+<t:root xmlns:t="test">
+
+ <a>123</a>
+
+</t:root>
diff --git a/tests/cxx/hybrid/test-template/test.xsd b/tests/cxx/hybrid/test-template/test.xsd
new file mode 100644
index 0000000..e0a9be1
--- /dev/null
+++ b/tests/cxx/hybrid/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="int" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/union/driver.cxx b/tests/cxx/hybrid/union/driver.cxx
new file mode 100644
index 0000000..286bf14
--- /dev/null
+++ b/tests/cxx/hybrid/union/driver.cxx
@@ -0,0 +1,56 @@
+// file : tests/cxx/hybrid/union/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test union mapping.
+//
+
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.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;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/union/makefile b/tests/cxx/hybrid/union/makefile
new file mode 100644
index 0000000..5c1289c
--- /dev/null
+++ b/tests/cxx/hybrid/union/makefile
@@ -0,0 +1,88 @@
+# file : tests/cxx/hybrid/union/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+gen := $(out_base)/$(xsd:.xsd=.hxx) \
+ $(out_base)/$(xsd:.xsd=.cxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-pimpl.cxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.hxx) \
+ $(out_base)/$(xsd:.xsd=-simpl.cxx)
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen): xsde_options += --generate-parser --generate-serializer \
+--generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/union/output b/tests/cxx/hybrid/union/output
new file mode 100644
index 0000000..9748083
--- /dev/null
+++ b/tests/cxx/hybrid/union/output
@@ -0,0 +1 @@
+<t:root xmlns:t="test"><int-string-union>123</int-string-union><int-string-union-lang lang="en">one</int-string-union-lang></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/union/test.xml b/tests/cxx/hybrid/union/test.xml
new file mode 100644
index 0000000..a2218b2
--- /dev/null
+++ b/tests/cxx/hybrid/union/test.xml
@@ -0,0 +1,6 @@
+<t:root xmlns:t="test">
+
+ <int-string-union>123</int-string-union>
+ <int-string-union-lang lang="en">one</int-string-union-lang>
+
+</t:root>
diff --git a/tests/cxx/hybrid/union/test.xsd b/tests/cxx/hybrid/union/test.xsd
new file mode 100644
index 0000000..60a8d21
--- /dev/null
+++ b/tests/cxx/hybrid/union/test.xsd
@@ -0,0 +1,26 @@
+<?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="int-string-union-lang">
+ <simpleContent>
+ <extension base="t:int-string-union">
+ <attribute name="lang" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="int-string-union" type="t:int-string-union"/>
+ <element name="int-string-union-lang" type="t:int-string-union-lang"/>
+ <element name="dummy" type="boolean" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>