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/xpath/README | 43 ----------- examples/cxx/tree/xpath/dom-parse.cxx | 88 ---------------------- examples/cxx/tree/xpath/dom-parse.hxx | 25 ------- examples/cxx/tree/xpath/driver.cxx | 136 ---------------------------------- examples/cxx/tree/xpath/makefile | 122 ------------------------------ examples/cxx/tree/xpath/people.xml | 28 ------- examples/cxx/tree/xpath/people.xsd | 38 ---------- 7 files changed, 480 deletions(-) delete mode 100644 examples/cxx/tree/xpath/README delete mode 100644 examples/cxx/tree/xpath/dom-parse.cxx delete mode 100644 examples/cxx/tree/xpath/dom-parse.hxx delete mode 100644 examples/cxx/tree/xpath/driver.cxx delete mode 100644 examples/cxx/tree/xpath/makefile delete mode 100644 examples/cxx/tree/xpath/people.xml delete mode 100644 examples/cxx/tree/xpath/people.xsd (limited to 'examples/cxx/tree/xpath') diff --git a/examples/cxx/tree/xpath/README b/examples/cxx/tree/xpath/README deleted file mode 100644 index 1187743..0000000 --- a/examples/cxx/tree/xpath/README +++ /dev/null @@ -1,43 +0,0 @@ -This example shows how to use the C++/Tree mapping together with XPath. -In particular, it shows how to execute an XPath query on the underlying -DOM document and then handle the result using the more convenient object -model representation. For more information on maintaining association -with the underlying DOM document, refer to Section 5.1, "DOM Association" -in the C++/Tree Mapping User Manual. - -You will need the XQilla library[1] which provides XQuery and XPath 2 -support on top of Xerces-C++ in order to build and run this example. - -[1] http://xqilla.sourceforge.net - -The example consists of the following files: - -people.xsd - XML Schema definition for a simple person record vocabulary. - -people.xml - Sample XML instance document. - -people.hxx -people.cxx - C++ types that represent the person record 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 people.xsd. - -dom-parse.hxx -dom-parse.cxx - Definition and implementation of the parse() function that parses an - XML document to a DOM document. - -driver.cxx - Driver for the example. It first calls the above parse() function to - parse the input file to a DOM document using XQilla-provided DOM - Implementation with support for XPath 2. It then parses the DOM - document to the object model. Finally, it prepares and executes - an XPath query on the underlying DOM document and then handles - the result by getting back from the returned DOM nodes to object - model nodes. - -To run the example on the sample XML document simply execute: - -$ ./driver people.xml diff --git a/examples/cxx/tree/xpath/dom-parse.cxx b/examples/cxx/tree/xpath/dom-parse.cxx deleted file mode 100644 index 0282780..0000000 --- a/examples/cxx/tree/xpath/dom-parse.cxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : examples/cxx/tree/xpath/dom-parse.cxx -// copyright : not copyrighted - public domain - -#include "dom-parse.hxx" - -#include - -#include -#include - -#include -#include - -#include -#include - -using namespace xercesc; -namespace xml = xsd::cxx::xml; -namespace tree = xsd::cxx::tree; - -xml::dom::auto_ptr -parse (std::istream& is, - const std::string& id, - bool validate, - DOMImplementation* impl) -{ - xml::dom::auto_ptr parser ( - impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - DOMConfiguration* conf (parser->getDomConfig ()); - - // Discard comment nodes in the document. - // - conf->setParameter (XMLUni::fgDOMComments, false); - - // Enable datatype normalization. - // - conf->setParameter (XMLUni::fgDOMDatatypeNormalization, true); - - // Do not create EntityReference nodes in the DOM tree. No - // EntityReference nodes will be created, only the nodes - // corresponding to their fully expanded substitution text - // will be created. - // - conf->setParameter (XMLUni::fgDOMEntities, false); - - // Perform namespace processing. - // - conf->setParameter (XMLUni::fgDOMNamespaces, true); - - // Do not include ignorable whitespace in the DOM tree. - // - conf->setParameter (XMLUni::fgDOMElementContentWhitespace, false); - - // Enable/Disable validation. - // - conf->setParameter (XMLUni::fgDOMValidate, validate); - conf->setParameter (XMLUni::fgXercesSchema, validate); - conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); - - // Xerces-C++ 3.1.0 is the first version with working multi import - // support. - // -#if _XERCES_VERSION >= 30100 - conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); -#endif - - // We will release the DOM document ourselves. - // - conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - // Set error handler. - // - tree::error_handler eh; - xml::dom::bits::error_handler_proxy ehp (eh); - conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); - - // Prepare input stream. - // - xml::sax::std_input_source isrc (is, id); - Wrapper4InputSource wrap (&isrc, false); - - xml::dom::auto_ptr doc (parser->parse (&wrap)); - - eh.throw_if_failed > (); - - return doc; -} diff --git a/examples/cxx/tree/xpath/dom-parse.hxx b/examples/cxx/tree/xpath/dom-parse.hxx deleted file mode 100644 index 9fa0eb9..0000000 --- a/examples/cxx/tree/xpath/dom-parse.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : examples/cxx/tree/xpath/dom-parse.hxx -// copyright : not copyrighted - public domain - -#ifndef DOM_PARSE -#define DOM_PARSE - -#include -#include - -#include -#include - -#include - -// Parse an XML document from the standard input stream with an -// optional resource id. Resource id is used in diagnostics as -// well as to locate schemas referenced from inside the document. -// -xsd::cxx::xml::dom::auto_ptr -parse (std::istream& is, - const std::string& id, - bool validate, - xercesc::DOMImplementation*); - -#endif // DOM_PARSE diff --git a/examples/cxx/tree/xpath/driver.cxx b/examples/cxx/tree/xpath/driver.cxx deleted file mode 100644 index f9bd040..0000000 --- a/examples/cxx/tree/xpath/driver.cxx +++ /dev/null @@ -1,136 +0,0 @@ -// file : examples/cxx/tree/xpath/driver.cxx -// copyright : not copyrighted - public domain - -#include // std::auto_ptr -#include -#include -#include - -#include - -#include - -#include // xml::string, xml::transcode - -#include "dom-parse.hxx" - -#include "people.hxx" - -using namespace std; -using namespace xercesc; -namespace xml = xsd::cxx::xml; - -int -main (int argc, char* argv[]) -{ - if (argc != 2) - { - cerr << "usage: " << argv[0] << " people.xml" << endl; - return 1; - } - - int r (0); - - // Initialise Xerces-C++ and XQilla. - // - XQillaPlatformUtils::initialize(); - - // Get the XQilla DOMImplementation object with support for XPath. - // - DOMImplementation* impl ( - DOMImplementationRegistry::getDOMImplementation( - xml::string ("XPath2 3.0").c_str ())); - - try - { - using namespace people; - - ifstream ifs; - ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1]); - - // Parse the XML file to DOM using the XQilla DOMImplementation. - // - xml_schema::dom::auto_ptr dom ( - parse (ifs, argv[1], true, impl)); - - // Parse the DOM document to the object model. We also request that - // the DOM document to be associated with the object model. - // - std::auto_ptr d ( - directory_ (dom, - xml_schema::flags::keep_dom | xml_schema::flags::own_dom)); - - // Obtain the root element and document corresponding to the - // directory object. - // - DOMElement* root (static_cast (d->_node ())); - DOMDocument* doc (root->getOwnerDocument ()); - - // Obtain namespace resolver. - // - xml_schema::dom::auto_ptr resolver ( - doc->createNSResolver (root)); - - // Set the namespace prefix for the people namespace that we can - // use reliably in XPath expressions regardless of what is used - // in XML documents. - // - resolver->addNamespaceBinding ( - xml::string ("p").c_str (), - xml::string ("http://www.codesynthesis.com/people").c_str ()); - - // Create XPath expression. - // - xml_schema::dom::auto_ptr expr ( - doc->createExpression ( - xml::string ("p:directory/person[age > 30]").c_str (), - resolver.get ())); - - // Execute the query. - // - xml_schema::dom::auto_ptr r ( - expr->evaluate (doc, DOMXPathResult::ITERATOR_RESULT_TYPE, 0)); - - // Iterate over the result. - // - cerr << "Records matching the query:" << endl; - - while (r->iterateNext ()) - { - DOMNode* n (r->getNodeValue ()); - - // Obtain the object model node corresponding to this DOM node. - // - person* p ( - static_cast ( - n->getUserData (xml_schema::dom::tree_node_key))); - - // Print the data using the object model. - // - cerr << endl - << "First : " << p->first_name () << endl - << "Last : " << p->last_name () << endl - << "Gender : " << p->gender () << endl - << "Age : " << p->age () << endl; - } - } - catch(const DOMException& e) - { - cerr << xml::transcode (e.getMessage ()) << std::endl; - r = 1; - } - catch (const xml_schema::exception& e) - { - cerr << e << endl; - r = 1; - } - catch (const std::ios_base::failure&) - { - cerr << argv[1] << ": unable to open or read failure" << endl; - r = 1; - } - - XQillaPlatformUtils::terminate(); - return r; -} diff --git a/examples/cxx/tree/xpath/makefile b/examples/cxx/tree/xpath/makefile deleted file mode 100644 index 3f5a3b0..0000000 --- a/examples/cxx/tree/xpath/makefile +++ /dev/null @@ -1,122 +0,0 @@ -# file : examples/cxx/tree/xpath/makefile -# license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make - -xsd := people.xsd -cxx := driver.cxx dom-parse.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) - -ifeq ($(filter $(MAKECMDGOALS),dist dist-win install),) -$(call import,\ - $(scf_root)/import/libxqilla/stub.make,\ - l: xqilla.l,cpp-options: xqilla.l.cpp-options) -endif - - -# Build. -# -$(driver): $(obj) $(xqilla.l) $(xerces_c.l) - -$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd -$(obj) $(dep): $(xqilla.l.cpp-options) $(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): $(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)/dom-parse.hxx,$(install_doc_dir)/xsd/$(path)/dom-parse.hxx) - $(call install-data,$(src_base)/dom-parse.cxx,$(install_doc_dir)/xsd/$(path)/dom-parse.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)/dom-parse.hxx,$(dist_prefix)/$(path)/dom-parse.hxx) - $(call install-data,$(src_base)/dom-parse.cxx,$(dist_prefix)/$(path)/dom-parse.cxx) - -$(dist): $(dist-common) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README) - -$(dist-win): |$(out_root)/.dist-pre -$(dist-win): $(dist-common) - $(call install-data,$(src_base)/README,$(dist_prefix)/$(path)/README.txt) - $(call message,,todos $(dist_prefix)/$(path)/README.txt) - $(call meta-vc8sln,$(src_root)/dist/template-vc8.sln,xpath-vc8.sln) - $(call meta-vc9sln,$(src_root)/dist/template-vc9.sln,xpath-vc9.sln) - $(call meta-vc10sln,$(src_root)/dist/template-vc10.sln,xpath-vc10.sln) - $(call meta-vc11sln,$(src_root)/dist/template-vc11.sln,xpath-vc11.sln) - $(call meta-vc12sln,$(src_root)/dist/template-vc12.sln,xpath-vc12.sln) - - -# 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,$(scf_root)/xsd/tree/xsd-cxx.make) - -$(call include,$(bld_root)/install.make) -$(call include,$(bld_root)/meta/vc8sln.make) -$(call include,$(bld_root)/meta/vc9sln.make) -$(call include,$(bld_root)/meta/vc10sln.make) -$(call include,$(bld_root)/meta/vc11sln.make) -$(call include,$(bld_root)/meta/vc12sln.make) - - -# Dependencies. -# -$(call import,$(src_root)/xsd/makefile) diff --git a/examples/cxx/tree/xpath/people.xml b/examples/cxx/tree/xpath/people.xml deleted file mode 100644 index 9ad9ab6..0000000 --- a/examples/cxx/tree/xpath/people.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - John - Doe - male - 32 - - - - Jane - Doe - female - 28 - - - diff --git a/examples/cxx/tree/xpath/people.xsd b/examples/cxx/tree/xpath/people.xsd deleted file mode 100644 index 5be94de..0000000 --- a/examples/cxx/tree/xpath/people.xsd +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.1