summaryrefslogtreecommitdiff
path: root/xsd/examples/cxx/tree/xpath
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/examples/cxx/tree/xpath')
-rw-r--r--xsd/examples/cxx/tree/xpath/README18
-rw-r--r--xsd/examples/cxx/tree/xpath/dom-parse.cxx32
-rw-r--r--xsd/examples/cxx/tree/xpath/dom-parse.hxx1
-rw-r--r--xsd/examples/cxx/tree/xpath/driver-2.cxx139
-rw-r--r--xsd/examples/cxx/tree/xpath/driver.cxx1
-rw-r--r--xsd/examples/cxx/tree/xpath/makefile28
-rw-r--r--xsd/examples/cxx/tree/xpath/people.xml1
-rw-r--r--xsd/examples/cxx/tree/xpath/people.xsd1
8 files changed, 26 insertions, 195 deletions
diff --git a/xsd/examples/cxx/tree/xpath/README b/xsd/examples/cxx/tree/xpath/README
index 48d40d6..1187743 100644
--- a/xsd/examples/cxx/tree/xpath/README
+++ b/xsd/examples/cxx/tree/xpath/README
@@ -30,17 +30,13 @@ dom-parse.cxx
XML document to a DOM document.
driver.cxx
- Driver for Xerces-C++ 3.x.y/XQilla 2.2.x. 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.
-
-driver-2.cxx
- Driver for Xerces-C++ 2.x.y/XQilla 2.1.x. It performs the same set
- of actions as driver.cxx above.
+ 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:
diff --git a/xsd/examples/cxx/tree/xpath/dom-parse.cxx b/xsd/examples/cxx/tree/xpath/dom-parse.cxx
index 82e87b6..0282780 100644
--- a/xsd/examples/cxx/tree/xpath/dom-parse.cxx
+++ b/xsd/examples/cxx/tree/xpath/dom-parse.cxx
@@ -1,5 +1,4 @@
// file : examples/cxx/tree/xpath/dom-parse.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : not copyrighted - public domain
#include "dom-parse.hxx"
@@ -25,10 +24,6 @@ parse (std::istream& is,
bool validate,
DOMImplementation* impl)
{
-#if _XERCES_VERSION >= 30000
-
- // Xerces-C++ 3.0.0 and later.
- //
xml::dom::auto_ptr<DOMLSParser> parser (
impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
@@ -80,39 +75,12 @@ parse (std::istream& is,
xml::dom::bits::error_handler_proxy<char> ehp (eh);
conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
-#else // _XERCES_VERSION >= 30000
-
- // Same as above but for Xerces-C++ 2 series.
- //
- xml::dom::auto_ptr<DOMBuilder> parser (
- impl->createDOMBuilder (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
-
- parser->setFeature (XMLUni::fgDOMComments, false);
- parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true);
- parser->setFeature (XMLUni::fgDOMEntities, false);
- parser->setFeature (XMLUni::fgDOMNamespaces, true);
- parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false);
- parser->setFeature (XMLUni::fgDOMValidation, validate);
- parser->setFeature (XMLUni::fgXercesSchema, validate);
- parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false);
- parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true);
-
- tree::error_handler<char> eh;
- xml::dom::bits::error_handler_proxy<char> ehp (eh);
- parser->setErrorHandler (&ehp);
-
-#endif // _XERCES_VERSION >= 30000
-
// Prepare input stream.
//
xml::sax::std_input_source isrc (is, id);
Wrapper4InputSource wrap (&isrc, false);
-#if _XERCES_VERSION >= 30000
xml::dom::auto_ptr<DOMDocument> doc (parser->parse (&wrap));
-#else
- xml::dom::auto_ptr<DOMDocument> doc (parser->parse (wrap));
-#endif
eh.throw_if_failed<tree::parsing<char> > ();
diff --git a/xsd/examples/cxx/tree/xpath/dom-parse.hxx b/xsd/examples/cxx/tree/xpath/dom-parse.hxx
index cfa1555..9fa0eb9 100644
--- a/xsd/examples/cxx/tree/xpath/dom-parse.hxx
+++ b/xsd/examples/cxx/tree/xpath/dom-parse.hxx
@@ -1,5 +1,4 @@
// file : examples/cxx/tree/xpath/dom-parse.hxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : not copyrighted - public domain
#ifndef DOM_PARSE
diff --git a/xsd/examples/cxx/tree/xpath/driver-2.cxx b/xsd/examples/cxx/tree/xpath/driver-2.cxx
deleted file mode 100644
index ccbdd7c..0000000
--- a/xsd/examples/cxx/tree/xpath/driver-2.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-// file : examples/cxx/tree/xpath/driver.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
-// copyright : not copyrighted - public domain
-
-#include <memory> // std::auto_ptr
-#include <string>
-#include <fstream>
-#include <iostream>
-
-#include <xercesc/dom/DOM.hpp>
-
-#include <xqilla/xqilla-dom3.hpp>
-
-#include <xsd/cxx/xml/string.hxx> // 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<xercesc::DOMDocument> 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<directory> 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<DOMElement*> (d->_node ()));
- DOMDocument* doc (root->getOwnerDocument ());
-
- // Obtain namespace resolver.
- //
- xml_schema::dom::auto_ptr<XQillaNSResolver> resolver (
- (XQillaNSResolver*)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<const XQillaExpression> expr (
- static_cast<const XQillaExpression*> (
- doc->createExpression (
- xml::string ("p:directory/person[age > 30]").c_str (),
- resolver.get ())));
-
- // Execute the query.
- //
- xml_schema::dom::auto_ptr<XPath2Result> r (
- static_cast<XPath2Result*> (
- expr->evaluate (doc, XPath2Result::ITERATOR_RESULT, 0)));
-
- // Iterate over the result.
- //
- cout << "Records matching the query:" << endl;
-
- while (r->iterateNext ())
- {
- const DOMNode* n (r->asNode ());
-
- // Obtain the object model node corresponding to this DOM node.
- //
- person* p (
- static_cast<person*> (
- n->getUserData (xml_schema::dom::tree_node_key)));
-
- // Print the data using the object model.
- //
- cout << 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<char> (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/xsd/examples/cxx/tree/xpath/driver.cxx b/xsd/examples/cxx/tree/xpath/driver.cxx
index f49e186..f9bd040 100644
--- a/xsd/examples/cxx/tree/xpath/driver.cxx
+++ b/xsd/examples/cxx/tree/xpath/driver.cxx
@@ -1,5 +1,4 @@
// file : examples/cxx/tree/xpath/driver.cxx
-// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : not copyrighted - public domain
#include <memory> // std::auto_ptr
diff --git a/xsd/examples/cxx/tree/xpath/makefile b/xsd/examples/cxx/tree/xpath/makefile
index 73457f3..693c6b2 100644
--- a/xsd/examples/cxx/tree/xpath/makefile
+++ b/xsd/examples/cxx/tree/xpath/makefile
@@ -1,6 +1,5 @@
# file : examples/cxx/tree/xpath/makefile
-# author : Boris Kolpackov <boris@codesynthesis.com>
-# copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+# copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
@@ -35,17 +34,16 @@ endif
#
$(driver): $(obj) $(xqilla.l) $(xerces_c.l)
-$(obj) $(dep): cpp_options := -I$(src_root)/libxsd
+$(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): xsd_options :=
$(gen): $(out_root)/xsd/xsd
-$(call include-dep,$(dep))
+$(call include-dep,$(dep),$(obj),$(gen))
# Convenience alias for default target.
#
@@ -60,7 +58,6 @@ $(install) $(dist) $(dist-win) $(dist-common): path := $(subst $(src_root)/,,$(s
$(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)/driver-2.cxx,$(install_doc_dir)/xsd/$(path)/driver-2.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)
@@ -68,7 +65,6 @@ $(install):
$(dist-common):
$(call install-data,$(src_base)/driver.cxx,$(dist_prefix)/$(path)/driver.cxx)
- $(call install-data,$(src_base)/driver-2.cxx,$(dist_prefix)/$(path)/driver-2.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)
@@ -77,9 +73,16 @@ $(dist-common):
$(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,,unix2dos $(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.
#
@@ -105,9 +108,16 @@ endif
$(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)
+$(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/xsd/examples/cxx/tree/xpath/people.xml b/xsd/examples/cxx/tree/xpath/people.xml
index 24af876..9ad9ab6 100644
--- a/xsd/examples/cxx/tree/xpath/people.xml
+++ b/xsd/examples/cxx/tree/xpath/people.xml
@@ -3,7 +3,6 @@
<!--
file : examples/cxx/tree/xpath/people.xml
-author : Boris Kolpackov <boris@codesynthesis.com>
copyright : not copyrighted - public domain
-->
diff --git a/xsd/examples/cxx/tree/xpath/people.xsd b/xsd/examples/cxx/tree/xpath/people.xsd
index 12c8aef..5be94de 100644
--- a/xsd/examples/cxx/tree/xpath/people.xsd
+++ b/xsd/examples/cxx/tree/xpath/people.xsd
@@ -3,7 +3,6 @@
<!--
file : examples/cxx/tree/xpath/people.xsd
-author : Boris Kolpackov <boris@codesynthesis.com>
copyright : not copyrighted - public domain
-->