Skip to content

Instantly share code, notes, and snippets.

@melvincabatuan
Created June 17, 2015 09:48
Show Gist options
  • Select an option

  • Save melvincabatuan/81f8adc13b5bd0b14afe to your computer and use it in GitHub Desktop.

Select an option

Save melvincabatuan/81f8adc13b5bd0b14afe to your computer and use it in GitHub Desktop.
xsd parsing
xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ xsd cxx-tree hello.xsd
xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ ls
driver.cxx hello.cxx hello.hxx hello.xml hello.xsd makefile README
xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ cat hello.hxx
// Copyright (c) 2005-2014 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema to
// C++ data binding compiler.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// In addition, as a special exception, Code Synthesis Tools CC gives
// permission to link this program with the Xerces-C++ library (or with
// modified versions of Xerces-C++ that use the same license as Xerces-C++),
// and distribute linked combinations including the two. You must obey
// the GNU General Public License version 2 in all respects for all of
// the code used other than Xerces-C++. If you modify this copy of the
// program, you may extend this exception to your version of the program,
// but you are not obligated to do so. If you do not wish to do so, delete
// this exception statement from your version.
//
// Furthermore, Code Synthesis Tools CC makes a special exception for
// the Free/Libre and Open Source Software (FLOSS) which is described
// in the accompanying FLOSSE file.
//
#ifndef HELLO_HXX
#define HELLO_HXX
#ifndef XSD_USE_CHAR
#define XSD_USE_CHAR
#endif
#ifndef XSD_CXX_TREE_USE_CHAR
#define XSD_CXX_TREE_USE_CHAR
#endif
// Begin prologue.
//
//
// End prologue.
#include <xsd/cxx/config.hxx>
#if (XSD_INT_VERSION != 4000000L)
#error XSD runtime version mismatch
#endif
#include <xsd/cxx/pre.hxx>
#include <xsd/cxx/xml/char-utf8.hxx>
#include <xsd/cxx/tree/exceptions.hxx>
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/tree/types.hxx>
#include <xsd/cxx/xml/error-handler.hxx>
#include <xsd/cxx/xml/dom/auto-ptr.hxx>
#include <xsd/cxx/tree/parsing.hxx>
#include <xsd/cxx/tree/parsing/byte.hxx>
#include <xsd/cxx/tree/parsing/unsigned-byte.hxx>
#include <xsd/cxx/tree/parsing/short.hxx>
#include <xsd/cxx/tree/parsing/unsigned-short.hxx>
#include <xsd/cxx/tree/parsing/int.hxx>
#include <xsd/cxx/tree/parsing/unsigned-int.hxx>
#include <xsd/cxx/tree/parsing/long.hxx>
#include <xsd/cxx/tree/parsing/unsigned-long.hxx>
#include <xsd/cxx/tree/parsing/boolean.hxx>
#include <xsd/cxx/tree/parsing/float.hxx>
#include <xsd/cxx/tree/parsing/double.hxx>
#include <xsd/cxx/tree/parsing/decimal.hxx>
namespace xml_schema
{
// anyType and anySimpleType.
//
typedef ::xsd::cxx::tree::type type;
typedef ::xsd::cxx::tree::simple_type< char, type > simple_type;
typedef ::xsd::cxx::tree::type container;
// 8-bit
//
typedef signed char byte;
typedef unsigned char unsigned_byte;
// 16-bit
//
typedef short short_;
typedef unsigned short unsigned_short;
// 32-bit
//
typedef int int_;
typedef unsigned int unsigned_int;
// 64-bit
//
typedef long long long_;
typedef unsigned long long unsigned_long;
// Supposed to be arbitrary-length integral types.
//
typedef long long integer;
typedef long long non_positive_integer;
typedef unsigned long long non_negative_integer;
typedef unsigned long long positive_integer;
typedef long long negative_integer;
// Boolean.
//
typedef bool boolean;
// Floating-point types.
//
typedef float float_;
typedef double double_;
typedef double decimal;
// String types.
//
typedef ::xsd::cxx::tree::string< char, simple_type > string;
typedef ::xsd::cxx::tree::normalized_string< char, string > normalized_string;
typedef ::xsd::cxx::tree::token< char, normalized_string > token;
typedef ::xsd::cxx::tree::name< char, token > name;
typedef ::xsd::cxx::tree::nmtoken< char, token > nmtoken;
typedef ::xsd::cxx::tree::nmtokens< char, simple_type, nmtoken > nmtokens;
typedef ::xsd::cxx::tree::ncname< char, name > ncname;
typedef ::xsd::cxx::tree::language< char, token > language;
// ID/IDREF.
//
typedef ::xsd::cxx::tree::id< char, ncname > id;
typedef ::xsd::cxx::tree::idref< char, ncname, type > idref;
typedef ::xsd::cxx::tree::idrefs< char, simple_type, idref > idrefs;
// URI.
//
typedef ::xsd::cxx::tree::uri< char, simple_type > uri;
// Qualified name.
//
typedef ::xsd::cxx::tree::qname< char, simple_type, uri, ncname > qname;
// Binary.
//
typedef ::xsd::cxx::tree::buffer< char > buffer;
typedef ::xsd::cxx::tree::base64_binary< char, simple_type > base64_binary;
typedef ::xsd::cxx::tree::hex_binary< char, simple_type > hex_binary;
// Date/time.
//
typedef ::xsd::cxx::tree::time_zone time_zone;
typedef ::xsd::cxx::tree::date< char, simple_type > date;
typedef ::xsd::cxx::tree::date_time< char, simple_type > date_time;
typedef ::xsd::cxx::tree::duration< char, simple_type > duration;
typedef ::xsd::cxx::tree::gday< char, simple_type > gday;
typedef ::xsd::cxx::tree::gmonth< char, simple_type > gmonth;
typedef ::xsd::cxx::tree::gmonth_day< char, simple_type > gmonth_day;
typedef ::xsd::cxx::tree::gyear< char, simple_type > gyear;
typedef ::xsd::cxx::tree::gyear_month< char, simple_type > gyear_month;
typedef ::xsd::cxx::tree::time< char, simple_type > time;
// Entity.
//
typedef ::xsd::cxx::tree::entity< char, ncname > entity;
typedef ::xsd::cxx::tree::entities< char, simple_type, entity > entities;
typedef ::xsd::cxx::tree::content_order content_order;
// Flags and properties.
//
typedef ::xsd::cxx::tree::flags flags;
typedef ::xsd::cxx::tree::properties< char > properties;
// Parsing/serialization diagnostics.
//
typedef ::xsd::cxx::tree::severity severity;
typedef ::xsd::cxx::tree::error< char > error;
typedef ::xsd::cxx::tree::diagnostics< char > diagnostics;
// Exceptions.
//
typedef ::xsd::cxx::tree::exception< char > exception;
typedef ::xsd::cxx::tree::bounds< char > bounds;
typedef ::xsd::cxx::tree::duplicate_id< char > duplicate_id;
typedef ::xsd::cxx::tree::parsing< char > parsing;
typedef ::xsd::cxx::tree::expected_element< char > expected_element;
typedef ::xsd::cxx::tree::unexpected_element< char > unexpected_element;
typedef ::xsd::cxx::tree::expected_attribute< char > expected_attribute;
typedef ::xsd::cxx::tree::unexpected_enumerator< char > unexpected_enumerator;
typedef ::xsd::cxx::tree::expected_text_content< char > expected_text_content;
typedef ::xsd::cxx::tree::no_prefix_mapping< char > no_prefix_mapping;
// Error handler callback interface.
//
typedef ::xsd::cxx::xml::error_handler< char > error_handler;
// DOM interaction.
//
namespace dom
{
// Automatic pointer for DOMDocument.
//
using ::xsd::cxx::xml::dom::auto_ptr;
#ifndef XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA
#define XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA
// DOM user data key for back pointers to tree nodes.
//
const XMLCh* const tree_node_key = ::xsd::cxx::tree::user_data_keys::node;
#endif
}
}
// Forward declarations.
//
class hello;
#include <memory> // ::std::auto_ptr
#include <limits> // std::numeric_limits
#include <algorithm> // std::binary_search
#include <xsd/cxx/xml/char-utf8.hxx>
#include <xsd/cxx/tree/exceptions.hxx>
#include <xsd/cxx/tree/elements.hxx>
#include <xsd/cxx/tree/containers.hxx>
#include <xsd/cxx/tree/list.hxx>
#include <xsd/cxx/xml/dom/parsing-header.hxx>
class hello: public ::xml_schema::type
{
public:
// greeting
//
typedef ::xml_schema::string greeting_type;
typedef ::xsd::cxx::tree::traits< greeting_type, char > greeting_traits;
const greeting_type&
greeting () const;
greeting_type&
greeting ();
void
greeting (const greeting_type& x);
void
greeting (::std::auto_ptr< greeting_type > p);
// name
//
typedef ::xml_schema::string name_type;
typedef ::xsd::cxx::tree::sequence< name_type > name_sequence;
typedef name_sequence::iterator name_iterator;
typedef name_sequence::const_iterator name_const_iterator;
typedef ::xsd::cxx::tree::traits< name_type, char > name_traits;
const name_sequence&
name () const;
name_sequence&
name ();
void
name (const name_sequence& s);
// Constructors.
//
hello (const greeting_type&);
hello (const ::xercesc::DOMElement& e,
::xml_schema::flags f = 0,
::xml_schema::container* c = 0);
hello (const hello& x,
::xml_schema::flags f = 0,
::xml_schema::container* c = 0);
virtual hello*
_clone (::xml_schema::flags f = 0,
::xml_schema::container* c = 0) const;
hello&
operator= (const hello& x);
virtual
~hello ();
// Implementation.
//
protected:
void
parse (::xsd::cxx::xml::dom::parser< char >&,
::xml_schema::flags);
protected:
::xsd::cxx::tree::one< greeting_type > greeting_;
name_sequence name_;
};
#include <iosfwd>
#include <xercesc/sax/InputSource.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMErrorHandler.hpp>
// Parse a URI or a local file.
//
::std::auto_ptr< ::hello >
hello_ (const ::std::string& uri,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (const ::std::string& uri,
::xml_schema::error_handler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (const ::std::string& uri,
::xercesc::DOMErrorHandler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
// Parse std::istream.
//
::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
::xml_schema::error_handler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
::xercesc::DOMErrorHandler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
const ::std::string& id,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
const ::std::string& id,
::xml_schema::error_handler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
const ::std::string& id,
::xercesc::DOMErrorHandler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
// Parse xercesc::InputSource.
//
::std::auto_ptr< ::hello >
hello_ (::xercesc::InputSource& is,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::xercesc::InputSource& is,
::xml_schema::error_handler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::xercesc::InputSource& is,
::xercesc::DOMErrorHandler& eh,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
// Parse xercesc::DOMDocument.
//
::std::auto_ptr< ::hello >
hello_ (const ::xercesc::DOMDocument& d,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
::std::auto_ptr< ::hello >
hello_ (::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d,
::xml_schema::flags f = 0,
const ::xml_schema::properties& p = ::xml_schema::properties ());
#include <xsd/cxx/post.hxx>
// Begin epilogue.
//
//
// End epilogue.
#endif // HELLO_HXX
@melvincabatuan
Copy link
Copy Markdown
Author

$ cat hello.cxx 
// Copyright (c) 2005-2014 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema to
// C++ data binding compiler.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// In addition, as a special exception, Code Synthesis Tools CC gives
// permission to link this program with the Xerces-C++ library (or with
// modified versions of Xerces-C++ that use the same license as Xerces-C++),
// and distribute linked combinations including the two. You must obey
// the GNU General Public License version 2 in all respects for all of
// the code used other than Xerces-C++. If you modify this copy of the
// program, you may extend this exception to your version of the program,
// but you are not obligated to do so. If you do not wish to do so, delete
// this exception statement from your version.
//
// Furthermore, Code Synthesis Tools CC makes a special exception for
// the Free/Libre and Open Source Software (FLOSS) which is described
// in the accompanying FLOSSE file.
//

// Begin prologue.
//
//
// End prologue.

#include <xsd/cxx/pre.hxx>

#include "hello.hxx"

// hello
// 

const hello::greeting_type& hello::
greeting () const
{
  return this->greeting_.get ();
}

hello::greeting_type& hello::
greeting ()
{
  return this->greeting_.get ();
}

void hello::
greeting (const greeting_type& x)
{
  this->greeting_.set (x);
}

void hello::
greeting (::std::auto_ptr< greeting_type > x)
{
  this->greeting_.set (x);
}

const hello::name_sequence& hello::
name () const
{
  return this->name_;
}

hello::name_sequence& hello::
name ()
{
  return this->name_;
}

void hello::
name (const name_sequence& s)
{
  this->name_ = s;
}


#include <xsd/cxx/xml/dom/parsing-source.hxx>

// hello
//

hello::
hello (const greeting_type& greeting)
: ::xml_schema::type (),
  greeting_ (greeting, this),
  name_ (this)
{
}

hello::
hello (const hello& x,
       ::xml_schema::flags f,
       ::xml_schema::container* c)
: ::xml_schema::type (x, f, c),
  greeting_ (x.greeting_, f, this),
  name_ (x.name_, f, this)
{
}

hello::
hello (const ::xercesc::DOMElement& e,
       ::xml_schema::flags f,
       ::xml_schema::container* c)
: ::xml_schema::type (e, f | ::xml_schema::flags::base, c),
  greeting_ (this),
  name_ (this)
{
  if ((f & ::xml_schema::flags::base) == 0)
  {
    ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false);
    this->parse (p, f);
  }
}

void hello::
parse (::xsd::cxx::xml::dom::parser< char >& p,
       ::xml_schema::flags f)
{
  for (; p.more_content (); p.next_content (false))
  {
    const ::xercesc::DOMElement& i (p.cur_element ());
    const ::xsd::cxx::xml::qualified_name< char > n (
      ::xsd::cxx::xml::dom::name< char > (i));

    // greeting
    //
    if (n.name () == "greeting" && n.namespace_ ().empty ())
    {
      ::std::auto_ptr< greeting_type > r (
        greeting_traits::create (i, f, this));

      if (!greeting_.present ())
      {
        this->greeting_.set (r);
        continue;
      }
    }

    // name
    //
    if (n.name () == "name" && n.namespace_ ().empty ())
    {
      ::std::auto_ptr< name_type > r (
        name_traits::create (i, f, this));

      this->name_.push_back (r);
      continue;
    }

    break;
  }

  if (!greeting_.present ())
  {
    throw ::xsd::cxx::tree::expected_element< char > (
      "greeting",
      "");
  }
}

hello* hello::
_clone (::xml_schema::flags f,
        ::xml_schema::container* c) const
{
  return new class hello (*this, f, c);
}

hello& hello::
operator= (const hello& x)
{
  if (this != &x)
  {
    static_cast< ::xml_schema::type& > (*this) = x;
    this->greeting_ = x.greeting_;
    this->name_ = x.name_;
  }

  return *this;
}

hello::
~hello ()
{
}

#include <istream>
#include <xsd/cxx/xml/sax/std-input-source.hxx>
#include <xsd/cxx/tree/error-handler.hxx>

::std::auto_ptr< ::hello >
hello_ (const ::std::string& u,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xml_schema::flags::dont_initialize) == 0,
    (f & ::xml_schema::flags::keep_dom) == 0);

  ::xsd::cxx::tree::error_handler< char > h;

  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (
      u, h, p, f));

  h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > ();

  return ::std::auto_ptr< ::hello > (
    ::hello_ (
      d, f | ::xml_schema::flags::own_dom, p));
}

::std::auto_ptr< ::hello >
hello_ (const ::std::string& u,
        ::xml_schema::error_handler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xml_schema::flags::dont_initialize) == 0,
    (f & ::xml_schema::flags::keep_dom) == 0);

  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (
      u, h, p, f));

  if (!d.get ())
    throw ::xsd::cxx::tree::parsing< char > ();

  return ::std::auto_ptr< ::hello > (
    ::hello_ (
      d, f | ::xml_schema::flags::own_dom, p));
}

::std::auto_ptr< ::hello >
hello_ (const ::std::string& u,
        ::xercesc::DOMErrorHandler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (
      u, h, p, f));

  if (!d.get ())
    throw ::xsd::cxx::tree::parsing< char > ();

  return ::std::auto_ptr< ::hello > (
    ::hello_ (
      d, f | ::xml_schema::flags::own_dom, p));
}

::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xml_schema::flags::dont_initialize) == 0,
    (f & ::xml_schema::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is);
  return ::hello_ (isrc, f, p);
}

::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
        ::xml_schema::error_handler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xml_schema::flags::dont_initialize) == 0,
    (f & ::xml_schema::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is);
  return ::hello_ (isrc, h, f, p);
}

::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
        ::xercesc::DOMErrorHandler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::sax::std_input_source isrc (is);
  return ::hello_ (isrc, h, f, p);
}

::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
        const ::std::string& sid,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xml_schema::flags::dont_initialize) == 0,
    (f & ::xml_schema::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is, sid);
  return ::hello_ (isrc, f, p);
}

::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
        const ::std::string& sid,
        ::xml_schema::error_handler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::auto_initializer i (
    (f & ::xml_schema::flags::dont_initialize) == 0,
    (f & ::xml_schema::flags::keep_dom) == 0);

  ::xsd::cxx::xml::sax::std_input_source isrc (is, sid);
  return ::hello_ (isrc, h, f, p);
}

::std::auto_ptr< ::hello >
hello_ (::std::istream& is,
        const ::std::string& sid,
        ::xercesc::DOMErrorHandler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::xml::sax::std_input_source isrc (is, sid);
  return ::hello_ (isrc, h, f, p);
}

::std::auto_ptr< ::hello >
hello_ (::xercesc::InputSource& i,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xsd::cxx::tree::error_handler< char > h;

  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (
      i, h, p, f));

  h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > ();

  return ::std::auto_ptr< ::hello > (
    ::hello_ (
      d, f | ::xml_schema::flags::own_dom, p));
}

::std::auto_ptr< ::hello >
hello_ (::xercesc::InputSource& i,
        ::xml_schema::error_handler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (
      i, h, p, f));

  if (!d.get ())
    throw ::xsd::cxx::tree::parsing< char > ();

  return ::std::auto_ptr< ::hello > (
    ::hello_ (
      d, f | ::xml_schema::flags::own_dom, p));
}

::std::auto_ptr< ::hello >
hello_ (::xercesc::InputSource& i,
        ::xercesc::DOMErrorHandler& h,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
    ::xsd::cxx::xml::dom::parse< char > (
      i, h, p, f));

  if (!d.get ())
    throw ::xsd::cxx::tree::parsing< char > ();

  return ::std::auto_ptr< ::hello > (
    ::hello_ (
      d, f | ::xml_schema::flags::own_dom, p));
}

::std::auto_ptr< ::hello >
hello_ (const ::xercesc::DOMDocument& doc,
        ::xml_schema::flags f,
        const ::xml_schema::properties& p)
{
  if (f & ::xml_schema::flags::keep_dom)
  {
    ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d (
      static_cast< ::xercesc::DOMDocument* > (doc.cloneNode (true)));

    return ::std::auto_ptr< ::hello > (
      ::hello_ (
        d, f | ::xml_schema::flags::own_dom, p));
  }

  const ::xercesc::DOMElement& e (*doc.getDocumentElement ());
  const ::xsd::cxx::xml::qualified_name< char > n (
    ::xsd::cxx::xml::dom::name< char > (e));

  if (n.name () == "hello" &&
      n.namespace_ () == "")
  {
    ::std::auto_ptr< ::hello > r (
      ::xsd::cxx::tree::traits< ::hello, char >::create (
        e, f, 0));
    return r;
  }

  throw ::xsd::cxx::tree::unexpected_element < char > (
    n.name (),
    n.namespace_ (),
    "hello",
    "");
}

::std::auto_ptr< ::hello >
hello_ (::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > d,
        ::xml_schema::flags f,
        const ::xml_schema::properties&)
{
  ::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > c (
    ((f & ::xml_schema::flags::keep_dom) &&
     !(f & ::xml_schema::flags::own_dom))
    ? static_cast< ::xercesc::DOMDocument* > (d->cloneNode (true))
    : 0);

  ::xercesc::DOMDocument& doc (c.get () ? *c : *d);
  const ::xercesc::DOMElement& e (*doc.getDocumentElement ());

  const ::xsd::cxx::xml::qualified_name< char > n (
    ::xsd::cxx::xml::dom::name< char > (e));

  if (f & ::xml_schema::flags::keep_dom)
    doc.setUserData (::xml_schema::dom::tree_node_key,
                     (c.get () ? &c : &d),
                     0);

  if (n.name () == "hello" &&
      n.namespace_ () == "")
  {
    ::std::auto_ptr< ::hello > r (
      ::xsd::cxx::tree::traits< ::hello, char >::create (
        e, f, 0));
    return r;
  }

  throw ::xsd::cxx::tree::unexpected_element < char > (
    n.name (),
    n.namespace_ (),
    "hello",
    "");
}

#include <xsd/cxx/post.hxx>

// Begin epilogue.
//
//
// End epilogue.

@melvincabatuan
Copy link
Copy Markdown
Author

PhD:~/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ make
xsd /home/cobalt/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello/hello.xsd
c++ /home/cobalt/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello/driver.cxx
c++ /home/cobalt/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello/hello-pskel.cxx
ld /home/cobalt/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello/driver
PhD:~/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ ls
driver      driver.cxx~  hello.cxx  hello.o          hello-pskel.hxx  hello-pskel.o  hello.xsd  README
driver.cxx  driver.o     hello.hxx  hello-pskel.cxx  hello-pskel.ixx  hello.xml      makefile
PhD:~/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ ./driver hello.x
hello.xml  hello.xsd  
PhD:~/src/xsd-4.0.0+dep/xsd/examples/cxx/parser/hello$ ./driver hello.xml 
Hello, sun!
Hello, moon!
Hello, world!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment