diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-02-24 15:16:26 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-02-24 15:16:26 +0200 |
commit | 707cc94fe52463870a9c6c8e2e66eaaa389e601d (patch) | |
tree | 13e10ff28bf4455d915f9d59b401bdbb62a393cb /tests/cxx/hybrid/built-in |
Start tracking XSD/e with git after version 3.0.03.0.0
Diffstat (limited to 'tests/cxx/hybrid/built-in')
-rw-r--r-- | tests/cxx/hybrid/built-in/driver.cxx | 56 | ||||
-rw-r--r-- | tests/cxx/hybrid/built-in/makefile | 88 | ||||
-rw-r--r-- | tests/cxx/hybrid/built-in/output | 5 | ||||
-rw-r--r-- | tests/cxx/hybrid/built-in/test.xml | 24 | ||||
-rw-r--r-- | tests/cxx/hybrid/built-in/test.xsd | 125 |
5 files changed, 298 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> |