summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/cxx/tree/README8
-rw-r--r--examples/cxx/tree/makefile7
-rw-r--r--examples/cxx/tree/mixed/README6
-rw-r--r--examples/cxx/tree/mixed/text.xml2
-rw-r--r--examples/cxx/tree/order/README11
-rw-r--r--examples/cxx/tree/order/element/README35
-rw-r--r--examples/cxx/tree/order/element/driver.cxx147
-rw-r--r--examples/cxx/tree/order/element/makefile100
-rw-r--r--examples/cxx/tree/order/element/transactions.xml33
-rw-r--r--examples/cxx/tree/order/element/transactions.xsd59
-rw-r--r--examples/cxx/tree/order/makefile44
-rw-r--r--examples/cxx/tree/order/mixed/README45
-rw-r--r--examples/cxx/tree/order/mixed/driver.cxx89
-rw-r--r--examples/cxx/tree/order/mixed/makefile99
-rw-r--r--examples/cxx/tree/order/mixed/text.xml18
-rw-r--r--examples/cxx/tree/order/mixed/text.xsd29
16 files changed, 724 insertions, 8 deletions
diff --git a/examples/cxx/tree/README b/examples/cxx/tree/README
index ee91b43..569bf11 100644
--- a/examples/cxx/tree/README
+++ b/examples/cxx/tree/README
@@ -17,6 +17,10 @@ polymorphism
Shows how to use XML Schema polymorphism features such as the
xsi:type attribute and substitution groups.
+order/
+ A collection of examples that show how to use ordered types to
+ capture and maintain content order.
+
xpath
Shows how to use the C++/Tree mapping together with XPath.
@@ -45,7 +49,7 @@ caching
embedded
Shows how to embed the binary representation of the schema grammar
- into an application and then use it with the C++/Tree mapping to
+ into an application and then use it with the C++/Tree mapping to
parse and validate XML documents.
performance
@@ -68,7 +72,7 @@ streaming
that are too large to fit into memory.
compression
- Shows how to compress an XML document during serialization and decompress
+ Shows how to compress an XML document during serialization and decompress
it during parsing using the zlib library.
binary/
diff --git a/examples/cxx/tree/makefile b/examples/cxx/tree/makefile
index 728860b..688dfd5 100644
--- a/examples/cxx/tree/makefile
+++ b/examples/cxx/tree/makefile
@@ -5,12 +5,11 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
all_examples := binary caching embedded custom hello library messaging \
-mixed multiroot performance polymorphism streaming wildcard compression \
-xpath
-
+mixed multiroot order performance polymorphism streaming wildcard \
+compression xpath
build_examples := binary caching embedded custom hello library messaging \
-mixed multiroot performance polymorphism streaming wildcard
+mixed multiroot order performance polymorphism streaming wildcard
ifeq ($(xsd_with_zlib),y)
build_examples += compression
diff --git a/examples/cxx/tree/mixed/README b/examples/cxx/tree/mixed/README
index 9ab3309..fc23faa 100644
--- a/examples/cxx/tree/mixed/README
+++ b/examples/cxx/tree/mixed/README
@@ -1,8 +1,12 @@
This example shows how to access the underlying DOM nodes in the
C++/Tree mapping in order to handle raw, "type-less content" such
as mixed content models, anyType/anySimpleType, and any/anyAttribute.
+
+For an alternative (and recommended) approach that employs ordered
+types see the order/mixed example.
+
For an alternative approach that employes type customization see
-examples in the custom/ directory, in particular, custom/mixed and
+examples in the custom/ directory, in particular, custom/mixed and
custom/wildcard.
In this example we use mixed content model to describe text with
diff --git a/examples/cxx/tree/mixed/text.xml b/examples/cxx/tree/mixed/text.xml
index 69abe8f..9d70397 100644
--- a/examples/cxx/tree/mixed/text.xml
+++ b/examples/cxx/tree/mixed/text.xml
@@ -2,7 +2,7 @@
<!--
-file : examples/cxx/tree/text/text.xml
+file : examples/cxx/tree/mixed/text.xml
author : Boris Kolpackov <boris@codesynthesis.com>
copyright : not copyrighted - public domain
diff --git a/examples/cxx/tree/order/README b/examples/cxx/tree/order/README
new file mode 100644
index 0000000..7125a2d
--- /dev/null
+++ b/examples/cxx/tree/order/README
@@ -0,0 +1,11 @@
+This directory contains a number of examples that show how to use ordered
+types to capture and maintain content order. The following list gives an
+overview of each example:
+
+element
+ Shows how to use ordered types to capture and maintain element order,
+ including element wildcards.
+
+mixed
+ Shows how to use ordered types to capture mixed content text and to
+ maintain order information between elements and text.
diff --git a/examples/cxx/tree/order/element/README b/examples/cxx/tree/order/element/README
new file mode 100644
index 0000000..19f2381
--- /dev/null
+++ b/examples/cxx/tree/order/element/README
@@ -0,0 +1,35 @@
+This example shows how to use ordered types to capture and maintain
+element order, including element wildcards.
+
+The example consists of the following files:
+
+transactions.xsd
+ XML Schema which describes various bank transactions. A batch of
+ transactions can contain any number of different transactions in
+ any order but the order of transaction in the batch is significant.
+
+library.xml
+ Sample XML instance document.
+
+transactions.hxx
+transactions.cxx
+ C++ types that represent the given vocabulary as well as a set of
+ parsing and serialization functions. These are generated by XSD
+ from transactions.xsd. Note that the --ordered-type option is
+ used to indicate to the XSD compiler that the batch type is
+ ordered. We also use the --generate-wildcard option to enable
+ wildcard support. An element wildcard is used in the batch to
+ allow transaction extensions.
+
+driver.cxx
+ Driver for the example. It first calls one of the parsing functions
+ that constructs the object model from the input XML file. It then
+ iterates over transactions in the batch using the content order
+ sequence. The driver then performs various modifications of the
+ object model while showing how to maintain the content order.
+ Finally, it saves the modified transaction batch back to XML to
+ verify that the content order is preserved in the output document.
+
+To run the example on the sample XML instance document simply execute:
+
+$ ./driver transactions.xml
diff --git a/examples/cxx/tree/order/element/driver.cxx b/examples/cxx/tree/order/element/driver.cxx
new file mode 100644
index 0000000..0ea6d6f
--- /dev/null
+++ b/examples/cxx/tree/order/element/driver.cxx
@@ -0,0 +1,147 @@
+// file : examples/cxx/tree/order/element/driver.cxx
+// copyright : not copyrighted - public domain
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <xercesc/dom/DOM.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+
+#include "transactions.hxx"
+
+// The following string class keeps us sane when working with Xerces.
+// Include it after the generated header in order to get only char or
+// wchar_t version depending on how you compiled your schemas.
+//
+#include <xsd/cxx/xml/string.hxx>
+
+using std::cerr;
+using std::endl;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " transactions.xml" << endl;
+ return 1;
+ }
+
+ using namespace xercesc;
+
+ int r (0);
+
+ // The Xerces-C++ DOM objects that will be used to store the
+ // content matched by the wildcard "out-lives" the call to the
+ // parsing function. Therefore we need to initialize the
+ // Xerces-C++ runtime ourselves.
+ //
+ XMLPlatformUtils::Initialize ();
+
+ try
+ {
+ using namespace transactions;
+
+ // Parse the batch.
+ //
+ std::auto_ptr<batch> b (
+ batch_ (argv[1], xml_schema::flags::dont_initialize));
+
+ // Print what we've got in content order.
+ //
+ for (batch::content_order_const_iterator i (b->content_order ().begin ());
+ i != b->content_order ().end ();
+ ++i)
+ {
+ switch (i->id)
+ {
+ case batch::balance_id:
+ {
+ const balance& t (b->balance ()[i->index]);
+ cerr << t.account () << " balance" << endl;
+ break;
+ }
+ case batch::withdraw_id:
+ {
+ const withdraw& t (b->withdraw ()[i->index]);
+ cerr << t.account () << " withdraw " << t.amount () << endl;
+ break;
+ }
+ case batch::deposit_id:
+ {
+ const deposit& t (b->deposit ()[i->index]);
+ cerr << t.account () << " deposit " << t.amount () << endl;
+ break;
+ }
+ case batch::any_id:
+ {
+ namespace xml = xsd::cxx::xml;
+
+ const DOMElement& e (b->any ()[i->index]);
+ cerr << xml::transcode<char> (e.getLocalName ()) << endl;
+ break;
+ }
+ default:
+ {
+ assert (false); // Unknown content id.
+ }
+ }
+ }
+
+ cerr << endl;
+
+ // Modify the transaction batch. First remove the last transaction.
+ // Note that we have to update both the content itself and content
+ // order sequences.
+ //
+ batch::content_order_sequence& co (b->content_order ());
+
+ co.pop_back ();
+ b->withdraw ().pop_back ();
+
+ // Now add a few more transactions. Again we have to add both the
+ // content and its ordering. The order information consists of the
+ // content id and, in case of a sequence, the index.
+ //
+ b->deposit ().push_back (deposit (123456789, 100000));
+ co.push_back (
+ batch::content_order_type (
+ batch::deposit_id, b->deposit ().size () - 1));
+
+ // The next transaction we add at the beginning of the batch.
+ //
+ b->balance ().push_back (balance (123456789));
+ co.insert (co.begin (),
+ batch::content_order_type (
+ batch::balance_id, b->balance ().size () - 1));
+
+ // Note also that when we merely modify the content of one
+ // of the elements in place, we don't need to update its
+ // order. For example:
+ //
+ b->deposit ()[0].amount (2000000);
+
+ // Serialize the modified transaction batch back to XML.
+ //
+ xml_schema::namespace_infomap map;
+
+ map[""].name = "http://www.codesynthesis.com/transactions";
+ map[""].schema = "transactions.xsd";
+ map["te"].name = "http://www.codesynthesis.com/transactions-extras";
+
+ batch_ (std::cout,
+ *b,
+ map,
+ "UTF-8",
+ xml_schema::flags::dont_initialize);
+ }
+ catch (const xml_schema::exception& e)
+ {
+ cerr << e << endl;
+ r = 1;
+ }
+
+ XMLPlatformUtils::Terminate ();
+ return r;
+}
diff --git a/examples/cxx/tree/order/element/makefile b/examples/cxx/tree/order/element/makefile
new file mode 100644
index 0000000..49478fc
--- /dev/null
+++ b/examples/cxx/tree/order/element/makefile
@@ -0,0 +1,100 @@
+# file : examples/cxx/tree/order/element/makefile
+# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := transactions.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o))
+dep := $(obj:.o=.o.d)
+
+driver := $(out_base)/driver
+install := $(out_base)/.install
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/libxerces-c/stub.make,\
+ l: xerces_c.l,cpp-options: xerces_c.l.cpp-options)
+
+# Build.
+#
+$(driver): $(obj) $(xerces_c.l) -lnsl
+
+$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
+$(obj) $(dep): $(xerces_c.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): xsd := $(out_root)/xsd/xsd
+$(gen): xsd_options += --generate-serialization --generate-wildcard \
+--ordered-type batch
+$(gen): $(out_root)/xsd/xsd
+
+$(call include-dep,$(dep),$(obj),$(gen))
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Install & Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+$(install) $(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(install):
+ $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README)
+ $(call install-data,$(src_base)/driver.cxx,$(install_doc_dir)/xsd/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/transactions.xsd,$(install_doc_dir)/xsd/$(path)/transactions.xsd)
+ $(call install-data,$(src_base)/transactions.xml,$(install_doc_dir)/xsd/$(path)/transactions.xml)
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/transactions.xsd,$(dist_prefix)/$(path)/transactions.xsd)
+ $(call install-data,$(src_base)/transactions.xml,$(dist_prefix)/$(path)/transactions.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+# Clean.
+#
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# 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,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsd/makefile)
diff --git a/examples/cxx/tree/order/element/transactions.xml b/examples/cxx/tree/order/element/transactions.xml
new file mode 100644
index 0000000..5435980
--- /dev/null
+++ b/examples/cxx/tree/order/element/transactions.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/tree/order/element/transactions.xml
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<batch xmlns="http://www.codesynthesis.com/transactions"
+ xmlns:te="http://www.codesynthesis.com/transactions-extras"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.codesynthesis.com/transactions transactions.xsd">
+ <deposit>
+ <account>123456789</account>
+ <amount>1000000</amount>
+ </deposit>
+
+ <balance>
+ <account>123456789</account>
+ </balance>
+
+ <te:block>
+ <account>123456789</account>
+ <amount>500000</amount>
+ </te:block>
+
+ <withdraw>
+ <account>123456789</account>
+ <amount>500000</amount>
+ </withdraw>
+</batch>
diff --git a/examples/cxx/tree/order/element/transactions.xsd b/examples/cxx/tree/order/element/transactions.xsd
new file mode 100644
index 0000000..54e9cc2
--- /dev/null
+++ b/examples/cxx/tree/order/element/transactions.xsd
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/tree/order/element/transactions.xsd
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:t="http://www.codesynthesis.com/transactions"
+ targetNamespace="http://www.codesynthesis.com/transactions"
+ elementFormDefault="qualified">
+
+ <xsd:complexType name="transaction">
+ <xsd:sequence>
+ <xsd:element name="account" type="xsd:unsignedInt"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="balance">
+ <xsd:complexContent>
+ <xsd:extension base="t:transaction"/>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="withdraw">
+ <xsd:complexContent>
+ <xsd:extension base="t:transaction">
+ <xsd:sequence>
+ <xsd:element name="amount" type="xsd:unsignedInt"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="deposit">
+ <xsd:complexContent>
+ <xsd:extension base="t:transaction">
+ <xsd:sequence>
+ <xsd:element name="amount" type="xsd:unsignedInt"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="batch">
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="balance" type="t:balance"/>
+ <xsd:element name="withdraw" type="t:withdraw"/>
+ <xsd:element name="deposit" type="t:deposit"/>
+ <xsd:any namespace="##other" processContents="lax"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <xsd:element name="batch" type="t:batch"/>
+
+</xsd:schema>
diff --git a/examples/cxx/tree/order/makefile b/examples/cxx/tree/order/makefile
new file mode 100644
index 0000000..63f1f3a
--- /dev/null
+++ b/examples/cxx/tree/order/makefile
@@ -0,0 +1,44 @@
+# file : examples/cxx/tree/order/makefile
+# copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+all_examples := element mixed
+build_examples := element mixed
+
+default := $(out_base)/
+install := $(out_base)/.install
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_examples)))
+
+# Install & Dist.
+#
+$(install) $(dist) $(dist-win): path := $(subst $(src_root)/,,$(src_base))
+
+$(install): $(addprefix $(out_base)/,$(addsuffix /.install,$(all_examples)))
+ $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README)
+
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_examples)))
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(addprefix $(out_base)/,$(addsuffix /.dist-win,$(all_examples)))
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+# Clean.
+#
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(build_examples)))
+
+$(call include,$(bld_root)/install.make)
+
+ifneq ($(filter $(MAKECMDGOALS),dist dist-win install),)
+$(foreach e,$(all_examples),$(call import,$(src_base)/$e/makefile))
+else
+$(foreach e,$(build_examples),$(call import,$(src_base)/$e/makefile))
+endif
diff --git a/examples/cxx/tree/order/mixed/README b/examples/cxx/tree/order/mixed/README
new file mode 100644
index 0000000..e66c1ad
--- /dev/null
+++ b/examples/cxx/tree/order/mixed/README
@@ -0,0 +1,45 @@
+This example shows how to use ordered types to capture mixed content
+text and to maintain order information between elements and text.
+
+In this example we use mixed content model to describe text with
+embedded links in the form:
+
+ This paragraph talks about <a href="uri">time</a>.
+
+The example transforms such text into plain text with references in
+the form:
+
+ This paragraph talks about time[uri].
+
+It also saves the modified text back to XML in order to verify the
+element and text order.
+
+The example consists of the following files:
+
+text.xsd
+ XML Schema which describes "text with links" instance documents.
+
+text.xml
+ Sample XML instance document.
+
+text.hxx
+text.cxx
+ C++ types that represent the given vocabulary as well as a set of
+ parsing and serialization functions. These are generated by XSD
+ from text.xsd. Note that the --ordered-type-mixed option is used
+ to indicate to the XSD compiler that all types with mixed content
+ should be automatically treated as ordered.
+
+driver.cxx
+ Driver for the example. It first calls one of the parsing functions
+ that constructs the object model from the input XML file. It then
+ iterates over the text and elements in the content order to convert
+ the document to its plain text representation. The driver then adds
+ another paragraph of text and a link to the object model while showing
+ how to maintain the content order. Finally, it saves the modified
+ text back to XML to verify that the content order is preserved in
+ the output document.
+
+To run the example on the sample XML instance document simply execute:
+
+$ ./driver text.xml
diff --git a/examples/cxx/tree/order/mixed/driver.cxx b/examples/cxx/tree/order/mixed/driver.cxx
new file mode 100644
index 0000000..9606b67
--- /dev/null
+++ b/examples/cxx/tree/order/mixed/driver.cxx
@@ -0,0 +1,89 @@
+// file : examples/cxx/tree/order/mixed/driver.cxx
+// copyright : not copyrighted - public domain
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include "text.hxx"
+
+using std::cerr;
+using std::endl;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " text.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ std::auto_ptr<text> t (text_ (argv[1]));
+
+ // Print what we've got in content order.
+ //
+ for (text::content_order_const_iterator i (t->content_order ().begin ());
+ i != t->content_order ().end ();
+ ++i)
+ {
+ switch (i->id)
+ {
+ case text::a_id:
+ {
+ const anchor& a (t->a ()[i->index]);
+ cerr << a << "[" << a.href () << "]";
+ break;
+ }
+ case text::text_content_id:
+ {
+ const xml_schema::string& s (t->text_content ()[i->index]);
+ cerr << s;
+ break;
+ }
+ default:
+ {
+ assert (false); // Unknown content id.
+ }
+ }
+ }
+
+ cerr << endl;
+
+ // Modify the document. Note that we have to update both the content
+ // itself and content order sequences.
+ //
+ typedef text::content_order_type order_type;
+
+ text::content_order_sequence& co (t->content_order ());
+ text::text_content_sequence& tc (t->text_content ());
+
+ tc.push_back ("The last paragraph doesn't talk about ");
+ co.push_back (order_type (text::text_content_id, tc.size () - 1));
+
+ t->a ().push_back (anchor ("anything", "http://en.wikipedia.org"));
+ co.push_back (order_type (text::a_id, t->a ().size () - 1));
+
+ tc.push_back (" in particular.\n\n");
+ co.push_back (order_type (text::text_content_id, tc.size () - 1));
+
+ // Serialize the modified document back to XML.
+ //
+ xml_schema::namespace_infomap map;
+
+ map[""].schema = "text.xsd";
+
+ text_ (std::cout,
+ *t,
+ map,
+ "UTF-8",
+ xml_schema::flags::dont_pretty_print);
+ }
+ catch (const xml_schema::exception& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+}
diff --git a/examples/cxx/tree/order/mixed/makefile b/examples/cxx/tree/order/mixed/makefile
new file mode 100644
index 0000000..3e3eb30
--- /dev/null
+++ b/examples/cxx/tree/order/mixed/makefile
@@ -0,0 +1,99 @@
+# file : examples/cxx/tree/order/mixed/makefile
+# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make
+
+xsd := text.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o))
+dep := $(obj:.o=.o.d)
+
+driver := $(out_base)/driver
+install := $(out_base)/.install
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/libxerces-c/stub.make,\
+ l: xerces_c.l,cpp-options: xerces_c.l.cpp-options)
+
+# Build.
+#
+$(driver): $(obj) $(xerces_c.l) -lnsl
+
+$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
+$(obj) $(dep): $(xerces_c.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): xsd := $(out_root)/xsd/xsd
+$(gen): xsd_options += --generate-serialization --ordered-type-mixed
+$(gen): $(out_root)/xsd/xsd
+
+$(call include-dep,$(dep),$(obj),$(gen))
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Install & Dist.
+#
+dist-common := $(out_base)/.dist-common
+
+$(install) $(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(src_base))
+
+$(install):
+ $(call install-data,$(src_base)/README,$(install_doc_dir)/xsd/$(path)/README)
+ $(call install-data,$(src_base)/driver.cxx,$(install_doc_dir)/xsd/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/text.xsd,$(install_doc_dir)/xsd/$(path)/text.xsd)
+ $(call install-data,$(src_base)/text.xml,$(install_doc_dir)/xsd/$(path)/text.xml)
+
+$(dist-common):
+ $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
+ $(call install-data,$(src_base)/text.xsd,$(dist_prefix)/$(path)/text.xsd)
+ $(call install-data,$(src_base)/text.xml,$(dist_prefix)/$(path)/text.xml)
+
+$(dist): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README)
+
+$(dist-win): $(dist-common)
+ $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt)
+ $(call message,,unix2dos $(dist_prefix)/$(path)/README.txt)
+
+# Clean.
+#
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# 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,$(bld_root)/install.make)
+$(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsd/makefile)
diff --git a/examples/cxx/tree/order/mixed/text.xml b/examples/cxx/tree/order/mixed/text.xml
new file mode 100644
index 0000000..815b76e
--- /dev/null
+++ b/examples/cxx/tree/order/mixed/text.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/tree/order/mixed/text.xml
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<text xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="text.xsd">
+
+The first paragraph of this text talks about <a href="http://en.wikipedia.org/wiki/time">time</a>.
+
+And this paragraph talks about <a href="http://en.wikipedia.org/wiki/space">space</a>.
+
+</text>
diff --git a/examples/cxx/tree/order/mixed/text.xsd b/examples/cxx/tree/order/mixed/text.xsd
new file mode 100644
index 0000000..bfb868e
--- /dev/null
+++ b/examples/cxx/tree/order/mixed/text.xsd
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+
+<!--
+
+file : examples/cxx/tree/order/mixed/text.xsd
+author : Boris Kolpackov <boris@codesynthesis.com>
+copyright : not copyrighted - public domain
+
+-->
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="anchor">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="href" type="xsd:anyURI" use="required"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="text" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="a" type="anchor" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="text" type="text"/>
+
+</xsd:schema>