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 --- examples/cxx/tree/custom/mixed/README | 50 --------- examples/cxx/tree/custom/mixed/driver.cxx | 123 ----------------------- examples/cxx/tree/custom/mixed/makefile | 114 --------------------- examples/cxx/tree/custom/mixed/people-custom.cxx | 89 ---------------- examples/cxx/tree/custom/mixed/people-custom.hxx | 83 --------------- examples/cxx/tree/custom/mixed/people.xml | 38 ------- examples/cxx/tree/custom/mixed/people.xsd | 45 --------- 7 files changed, 542 deletions(-) delete mode 100644 examples/cxx/tree/custom/mixed/README delete mode 100644 examples/cxx/tree/custom/mixed/driver.cxx delete mode 100644 examples/cxx/tree/custom/mixed/makefile delete mode 100644 examples/cxx/tree/custom/mixed/people-custom.cxx delete mode 100644 examples/cxx/tree/custom/mixed/people-custom.hxx delete mode 100644 examples/cxx/tree/custom/mixed/people.xml delete mode 100644 examples/cxx/tree/custom/mixed/people.xsd (limited to 'examples/cxx/tree/custom/mixed') diff --git a/examples/cxx/tree/custom/mixed/README b/examples/cxx/tree/custom/mixed/README deleted file mode 100644 index 7b56812..0000000 --- a/examples/cxx/tree/custom/mixed/README +++ /dev/null @@ -1,50 +0,0 @@ -This example shows how to use type customization to parse and serialize -mixed content. The example achieves this by customizing the type with -the mixed content model to include a DOM document that stores the data -as a raw XML representation. The customized type also provides its own -parsing constructor and serialization operator where the mixed content -is extracted from and inserted back to DOM, respectively. The use of -DOM for mixed content storage is one of the options. You may find other -data structures (e.g., a string) more suitable depending on your situation. - -For more information on the C++/Tree mapping customization see the C++/Tree -Mapping Customization Guide[1]. - -[1] http://wiki.codesynthesis.com/Tree/Customization_guide - -The example consists of the following files: - -people.xsd - XML Schema definition for a simple person record vocabulary. Each - record includes the bio element which represents arbitrary XHTML - fragments as mixed content. - -people.xml - Sample XML instance document. - -people.hxx -people.ixx -people.cxx - C++ types that represent the given vocabulary, a set of parsing - functions that convert XML instance documents to a tree-like in-memory - object model, and a set of serialization functions that convert the - object model back to XML. These are generated by XSD from people.xsd - with the --custom-type option in order to customize the bio type. - -people-custom.hxx - Header file which defines our own bio class by inheriting from the - generated bio_base. It is included at the end of people.hxx using - the --hxx-epilogue option. - -people-custom.cxx - Source file which contains the implementation of our bio class. - -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 data to STDERR, including the bio information converted to text. - Finally, the driver serializes the object model back to XML. - -To run the example on the sample XML instance document simply execute: - -$ ./driver people.xml diff --git a/examples/cxx/tree/custom/mixed/driver.cxx b/examples/cxx/tree/custom/mixed/driver.cxx deleted file mode 100644 index 0378f18..0000000 --- a/examples/cxx/tree/custom/mixed/driver.cxx +++ /dev/null @@ -1,123 +0,0 @@ -// file : examples/cxx/tree/custom/mixed/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include - -#include -#include - -#include "people.hxx" - -// The following transcode() utility function is handy 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 - -using std::cerr; -using std::endl; -using namespace xercesc; - - -void -xhtml2txt (const DOMElement*); - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " people.xml" << endl; - return 1; - } - - int r (0); - - // The Xerces-C++ DOM document that will be used to store the XHTML - // fragments "out-live" the call to the parsing function. Therefore - // we need to initialize the Xerces-C++ runtime ourselves. - // - XMLPlatformUtils::Initialize (); - - try - { - using namespace people; - - // Parse. - // - std::auto_ptr d ( - directory_ (argv[1], xml_schema::flags::dont_initialize)); - - // Print what we've got. - // - const directory::person_sequence& s (d->person ()); - - for (directory::person_const_iterator i (s.begin ()); i != s.end (); ++i) - { - cerr << "First : " << i->first_name () << endl - << "Last : " << i->last_name () << endl - << "Gender : " << i->gender () << endl - << "Age : " << i->age () << endl; - - const bio& b (i->bio ()); - const DOMElement* xhtml (b.xhtml ()); - - if (xhtml != 0) - { - cerr << "Bio : " << endl; - xhtml2txt (xhtml); - } - - cerr << endl; - } - - // Serialize. - // - xml_schema::namespace_infomap map; - - map["ppl"].name = "http://www.codesynthesis.com/people"; - map["ppl"].schema = "people.xsd"; - - directory_ ( - std::cout, *d, map, "UTF-8", xml_schema::flags::dont_initialize); - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - - XMLPlatformUtils::Terminate (); - return r; -} - -// Primitive XHTML to text converter that just prints all the text -// nodes and ignores everything else. -// -void -xhtml2txt (const DOMElement* e) -{ - namespace xml = xsd::cxx::xml; - - for (const DOMNode* n (e->getFirstChild ()); - n != 0; - n = n->getNextSibling ()) - { - switch (n->getNodeType ()) - { - case DOMNode::TEXT_NODE: - { - cerr << xml::transcode (n->getTextContent ()); - break; - } - case DOMNode::ELEMENT_NODE: - { - xhtml2txt (static_cast (n)); - break; - } - default: - break; // Ignore all other nodes (e.g., comments, etc). - } - } -} diff --git a/examples/cxx/tree/custom/mixed/makefile b/examples/cxx/tree/custom/mixed/makefile deleted file mode 100644 index c191271..0000000 --- a/examples/cxx/tree/custom/mixed/makefile +++ /dev/null @@ -1,114 +0,0 @@ -# file : examples/cxx/tree/custom/mixed/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make - -xsd := people.xsd -cxx := driver.cxx people-custom.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) - -$(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 - -# We have to double-escape '#' because the message function -# (which is used in command scripts) expands things twice. -# -$(gen): xsd_options += \ ---generate-inline \ ---generate-serialization \ ---custom-type bio=/bio_base \ ---hxx-epilogue '\#include "people-custom.hxx"' - -$(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)/people.xsd,$(install_doc_dir)/xsd/$(path)/people.xsd) - $(call install-data,$(src_base)/people.xml,$(install_doc_dir)/xsd/$(path)/people.xml) - $(call install-data,$(src_base)/people-custom.hxx,$(install_doc_dir)/xsd/$(path)/people-custom.hxx) - $(call install-data,$(src_base)/people-custom.cxx,$(install_doc_dir)/xsd/$(path)/people-custom.cxx) - -$(dist-common): - $(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx) - $(call install-data,$(src_base)/people.xsd,$(dist_prefix)/$(path)/people.xsd) - $(call install-data,$(src_base)/people.xml,$(dist_prefix)/$(path)/people.xml) - $(call install-data,$(src_base)/people-custom.hxx,$(dist_prefix)/$(path)/people-custom.hxx) - $(call install-data,$(src_base)/people-custom.cxx,$(dist_prefix)/$(path)/people-custom.cxx) - -$(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,,todos $(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/custom/mixed/people-custom.cxx b/examples/cxx/tree/custom/mixed/people-custom.cxx deleted file mode 100644 index 7cd1947..0000000 --- a/examples/cxx/tree/custom/mixed/people-custom.cxx +++ /dev/null @@ -1,89 +0,0 @@ -// file : examples/cxx/tree/custom/mixed/people-custom.cxx -// copyright : not copyrighted - public domain - -#include - -// Include people.hxx instead of people-custom.hxx here. -// -#include "people.hxx" - -namespace people -{ - using namespace xercesc; - - const XMLCh ls[] = {chLatin_L, chLatin_S, chNull}; - - bio:: - bio () - : xhtml_ (0) - { - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - doc_.reset (impl->createDocument ()); - } - - bio:: - bio (const DOMElement& e, - xml_schema::flags f, - xml_schema::container* c) - : bio_base (e, f, c), xhtml_ (0) - { - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - doc_.reset (impl->createDocument ()); - - // Copy the xhtml element. Assume the first child element in - // e is always xhtml. - // - for (DOMNode* n (e.getFirstChild ()); n != 0; n = n->getNextSibling ()) - { - if (n->getNodeType () == DOMNode::ELEMENT_NODE) - { - xhtml_ = static_cast (doc_->importNode (n, true)); - break; - } - } - } - - bio:: - bio (const bio& d, - xml_schema::flags f, - xml_schema::container* c) - : bio_base (d, f, c), xhtml_ (0) - { - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation (ls)); - - doc_.reset (impl->createDocument ()); - - xhtml_ = static_cast ( - doc_->importNode (const_cast (d.xhtml_), true)); - } - - bio* bio:: - _clone (xml_schema::flags f, xml_schema::container* c) const - { - return new bio (*this, f, c); - } - - void - operator<< (DOMElement& e, const bio& x) - { - // Allow our base to serialize first. - // - const bio_base& b (x); - e << b; - - // Copy the XHTML fragment if we have one. - // - const DOMElement* xhtml (x.xhtml ()); - - if (xhtml != 0) - { - DOMDocument* doc (e.getOwnerDocument ()); - e.appendChild (doc->importNode (const_cast (xhtml), true)); - } - } -} diff --git a/examples/cxx/tree/custom/mixed/people-custom.hxx b/examples/cxx/tree/custom/mixed/people-custom.hxx deleted file mode 100644 index 54dfb21..0000000 --- a/examples/cxx/tree/custom/mixed/people-custom.hxx +++ /dev/null @@ -1,83 +0,0 @@ -// file : examples/cxx/tree/custom/mixed/people-custom.hxx -// copyright : not copyrighted - public domain - -// Do not include this file directly, use people.hxx instead. This -// file is included into generated people.hxx so we do not need to -// guard against multiple inclusions. -// - -#include -#include - -namespace people -{ - class bio: public bio_base - { - // Standard constructors. - // - public: - bio (); - - bio (const xercesc::DOMElement&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - bio (const bio&, - xml_schema::flags = 0, - xml_schema::container* = 0); - - virtual bio* - _clone (xml_schema::flags = 0, - xml_schema::container* = 0) const; - - // XHTML bio as a DOM document. - // - public: - const xercesc::DOMElement* - xhtml () const - { - return xhtml_; - } - - xercesc::DOMElement* - xhtml () - { - return xhtml_; - } - - // The element should belong to the DOMDocument returned by - // the dom_document() functions. - // - void - xhtml (xercesc::DOMElement* e) - { - assert (e->getOwnerDocument () == doc_.get ()); - - if (xhtml_ != 0) - xhtml_->release (); - - xhtml_ = e; - } - - const xercesc::DOMDocument& - dom_document () const - { - return *doc_; - } - - xercesc::DOMDocument& - dom_document () - { - return *doc_; - } - - private: - xercesc::DOMElement* xhtml_; - xml_schema::dom::auto_ptr doc_; - }; - - // Serialization operator. - // - void - operator<< (xercesc::DOMElement&, const bio&); -} diff --git a/examples/cxx/tree/custom/mixed/people.xml b/examples/cxx/tree/custom/mixed/people.xml deleted file mode 100644 index 47e68b9..0000000 --- a/examples/cxx/tree/custom/mixed/people.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - John - Doe - male - 32 - - -

Married to Jane Doe.

-
-
-
- - - Jane - Doe - female - 28 - - -

Married to John Doe.

-
-
-
- -
diff --git a/examples/cxx/tree/custom/mixed/people.xsd b/examples/cxx/tree/custom/mixed/people.xsd deleted file mode 100644 index 03e6c97..0000000 --- a/examples/cxx/tree/custom/mixed/people.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.1