From 5e527213a2430bb3018e5eebd909aef294edf9b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- xsd-examples/cxx/tree/hello/.gitignore | 1 + xsd-examples/cxx/tree/hello/README | 26 +++++++++++++++++ xsd-examples/cxx/tree/hello/buildfile | 23 +++++++++++++++ xsd-examples/cxx/tree/hello/driver.cxx | 36 +++++++++++++++++++++++ xsd-examples/cxx/tree/hello/hello.xml | 19 +++++++++++++ xsd-examples/cxx/tree/hello/hello.xsd | 52 ++++++++++++++++++++++++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 xsd-examples/cxx/tree/hello/.gitignore create mode 100644 xsd-examples/cxx/tree/hello/README create mode 100644 xsd-examples/cxx/tree/hello/buildfile create mode 100644 xsd-examples/cxx/tree/hello/driver.cxx create mode 100644 xsd-examples/cxx/tree/hello/hello.xml create mode 100644 xsd-examples/cxx/tree/hello/hello.xsd (limited to 'xsd-examples/cxx/tree/hello') diff --git a/xsd-examples/cxx/tree/hello/.gitignore b/xsd-examples/cxx/tree/hello/.gitignore new file mode 100644 index 0000000..d73130a --- /dev/null +++ b/xsd-examples/cxx/tree/hello/.gitignore @@ -0,0 +1 @@ +hello.?xx diff --git a/xsd-examples/cxx/tree/hello/README b/xsd-examples/cxx/tree/hello/README new file mode 100644 index 0000000..bb98584 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/README @@ -0,0 +1,26 @@ +This is a "Hello, world!" example that shows how to use the C++/Tree +mapping to access XML instance documents described by XML Schema +definitions. + +The example consists of the following files: + +hello.xsd + XML Schema which describes "hello" instance documents. + +hello.xml + Sample XML instance document. + +hello.hxx +hello.cxx + C++ types that represent the given vocabulary and a set of parsing + functions that convert XML instance documents to a tree-like in-memory + object model. These are generated by XSD from hello.xsd. + +driver.cxx + Driver for the example. It first calls one of the parsing functions + that constructs the object model from the input file. It then prints + the content of the object model to STDERR. + +To run the example on the sample XML instance document simply execute: + +$ ./driver hello.xml diff --git a/xsd-examples/cxx/tree/hello/buildfile b/xsd-examples/cxx/tree/hello/buildfile new file mode 100644 index 0000000..241d6f1 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/buildfile @@ -0,0 +1,23 @@ +# file : cxx/tree/hello/buildfile +# license : not copyrighted - public domain + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +./: exe{driver} doc{README} + +exe{driver}: {hxx cxx}{* -hello} {hxx ixx cxx}{hello} $libs + +exe{driver}: xml{hello}: test.input = true + +<{hxx ixx cxx}{hello}>: xsd{hello} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-tree --std c++11 \ + --generate-inline \ + --output-dir $out_base \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-examples/cxx/tree/hello/driver.cxx b/xsd-examples/cxx/tree/hello/driver.cxx new file mode 100644 index 0000000..7c8cec0 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/driver.cxx @@ -0,0 +1,36 @@ +// file : cxx/tree/hello/driver.cxx +// copyright : not copyrighted - public domain + +#include // std::unique_ptr +#include + +#include "hello.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " hello.xml" << endl; + return 1; + } + + try + { + unique_ptr h (hello (argv[1])); + + for (hello_t::name_const_iterator i (h->name ().begin ()); + i != h->name ().end (); + ++i) + { + cout << h->greeting () << ", " << *i << "!" << endl; + } + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/xsd-examples/cxx/tree/hello/hello.xml b/xsd-examples/cxx/tree/hello/hello.xml new file mode 100644 index 0000000..b534d21 --- /dev/null +++ b/xsd-examples/cxx/tree/hello/hello.xml @@ -0,0 +1,19 @@ + + + + + + + Hello + + sun + moon + world + + diff --git a/xsd-examples/cxx/tree/hello/hello.xsd b/xsd-examples/cxx/tree/hello/hello.xsd new file mode 100644 index 0000000..a945ecf --- /dev/null +++ b/xsd-examples/cxx/tree/hello/hello.xsd @@ -0,0 +1,52 @@ + + + + + + + + + + + The hello_t type consists of a greeting phrase and a + collection of names to which this greeting applies. + + + + + + + + + The greeting element contains the greeting phrase + for this hello object. + + + + + + + + The name elements contains names to be greeted. + + + + + + + + + + + The hello element is a root of the Hello XML vocabulary. + Every conforming document should start with this element. + + + + + -- cgit v1.1