From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- tests/cxx/tree/built-in/attributes.xml | 73 ++++++ tests/cxx/tree/built-in/driver.cxx | 94 +++++++ tests/cxx/tree/built-in/elements.xml | 84 ++++++ tests/cxx/tree/built-in/inherited.xml | 84 ++++++ tests/cxx/tree/built-in/makefile | 93 +++++++ tests/cxx/tree/built-in/types.xsd | 460 +++++++++++++++++++++++++++++++++ 6 files changed, 888 insertions(+) create mode 100644 tests/cxx/tree/built-in/attributes.xml create mode 100644 tests/cxx/tree/built-in/driver.cxx create mode 100644 tests/cxx/tree/built-in/elements.xml create mode 100644 tests/cxx/tree/built-in/inherited.xml create mode 100644 tests/cxx/tree/built-in/makefile create mode 100644 tests/cxx/tree/built-in/types.xsd (limited to 'tests/cxx/tree/built-in') diff --git a/tests/cxx/tree/built-in/attributes.xml b/tests/cxx/tree/built-in/attributes.xml new file mode 100644 index 0000000..609a757 --- /dev/null +++ b/tests/cxx/tree/built-in/attributes.xml @@ -0,0 +1,73 @@ + + diff --git a/tests/cxx/tree/built-in/driver.cxx b/tests/cxx/tree/built-in/driver.cxx new file mode 100644 index 0000000..f3138aa --- /dev/null +++ b/tests/cxx/tree/built-in/driver.cxx @@ -0,0 +1,94 @@ +// file : tests/cxx/tree/built-in/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test built-in type mapping. +// + +#include // std::auto_ptr +#include +#include + + +#include "types.hxx" + +using std::cerr; +using std::endl; +using std::auto_ptr; + +int +main (int argc, char* argv[]) +{ + if (argc != 4) + { + cerr << "usage: " << argv[0] << " elements.xml attributes.xml inherited.xml" << endl; + return 1; + } + + auto_ptr elements (xmlns::test::elements (argv[1])); + + auto_ptr attributes ( + xmlns::test::attributes (argv[2])); + + auto_ptr inherited ( + xmlns::test::inherited (argv[3])); + + cerr << "elements: " << *elements << endl + << endl + << "attributes: " << *attributes << endl + << endl + << "inherited: " << *inherited << endl; + + // Test parsing/serialization. + // + + xml_schema::namespace_infomap map; + + map["test"].name = "http://www.codesynthesis.com/xmlns/test"; + map["test"].schema = "types.xsd"; + + { + std::ostringstream ostr; + xmlns::test::elements (ostr, *elements, map); + + std::istringstream istr (ostr.str ()); + auto_ptr elements1 (xmlns::test::elements (istr)); + + std::ostringstream ostr1; + xmlns::test::elements (ostr1, *elements1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } + + { + std::ostringstream ostr; + xmlns::test::attributes (ostr, *attributes, map); + + std::istringstream istr (ostr.str ()); + auto_ptr attributes1 ( + xmlns::test::attributes (istr)); + + std::ostringstream ostr1; + xmlns::test::attributes (ostr1, *attributes1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } + + { + std::ostringstream ostr; + xmlns::test::inherited (ostr, *inherited, map); + + std::istringstream istr (ostr.str ()); + auto_ptr inherited1 ( + xmlns::test::inherited (istr)); + + std::ostringstream ostr1; + xmlns::test::inherited (ostr1, *inherited1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } +} diff --git a/tests/cxx/tree/built-in/elements.xml b/tests/cxx/tree/built-in/elements.xml new file mode 100644 index 0000000..f76f019 --- /dev/null +++ b/tests/cxx/tree/built-in/elements.xml @@ -0,0 +1,84 @@ + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 12345678.12345678 + + + + string + normalized +string + + one + two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + + + + diff --git a/tests/cxx/tree/built-in/inherited.xml b/tests/cxx/tree/built-in/inherited.xml new file mode 100644 index 0000000..1781a69 --- /dev/null +++ b/tests/cxx/tree/built-in/inherited.xml @@ -0,0 +1,84 @@ + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 12345678.12345678 + + + + string + normalized +string + + one + two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + + + + diff --git a/tests/cxx/tree/built-in/makefile b/tests/cxx/tree/built-in/makefile new file mode 100644 index 0000000..028d18d --- /dev/null +++ b/tests/cxx/tree/built-in/makefile @@ -0,0 +1,93 @@ +# file : tests/cxx/tree/built-in/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := types.xsd +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +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) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --char-type char \ + --generate-inline \ + --generate-ostream \ + --generate-serialization \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --root-element-all + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(src_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +# We need to cd to src_base in order to have the schema in the working +# directory. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/elements.xml $(src_base)/attributes.xml \ +$(src_base)/inherited.xml + cd $(src_base) && $(driver) $(src_base)/elements.xml \ +$(src_base)/attributes.xml $(src_base)/inherited.xml + + +# 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)/xsd/tree/xsd-cxx.make) + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/built-in/types.xsd b/tests/cxx/tree/built-in/types.xsd new file mode 100644 index 0000000..22582cb --- /dev/null +++ b/tests/cxx/tree/built-in/types.xsd @@ -0,0 +1,460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1