From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- libxsd/xsd/cxx/xml/dom/auto-ptr.hxx | 158 +++++++ .../xsd/cxx/xml/dom/bits/error-handler-proxy.hxx | 61 +++ .../xsd/cxx/xml/dom/bits/error-handler-proxy.txx | 80 ++++ libxsd/xsd/cxx/xml/dom/elements.hxx | 36 ++ libxsd/xsd/cxx/xml/dom/elements.txx | 57 +++ libxsd/xsd/cxx/xml/dom/parsing-header.hxx | 24 ++ libxsd/xsd/cxx/xml/dom/parsing-source.hxx | 138 +++++++ libxsd/xsd/cxx/xml/dom/parsing-source.txx | 458 +++++++++++++++++++++ libxsd/xsd/cxx/xml/dom/serialization-header.hxx | 81 ++++ libxsd/xsd/cxx/xml/dom/serialization-header.txx | 192 +++++++++ libxsd/xsd/cxx/xml/dom/serialization-source.hxx | 152 +++++++ libxsd/xsd/cxx/xml/dom/serialization-source.txx | 394 ++++++++++++++++++ libxsd/xsd/cxx/xml/dom/wildcard-source.hxx | 31 ++ libxsd/xsd/cxx/xml/dom/wildcard-source.txx | 39 ++ 14 files changed, 1901 insertions(+) create mode 100644 libxsd/xsd/cxx/xml/dom/auto-ptr.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx create mode 100644 libxsd/xsd/cxx/xml/dom/elements.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/elements.txx create mode 100644 libxsd/xsd/cxx/xml/dom/parsing-header.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/parsing-source.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/parsing-source.txx create mode 100644 libxsd/xsd/cxx/xml/dom/serialization-header.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/serialization-header.txx create mode 100644 libxsd/xsd/cxx/xml/dom/serialization-source.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/serialization-source.txx create mode 100644 libxsd/xsd/cxx/xml/dom/wildcard-source.hxx create mode 100644 libxsd/xsd/cxx/xml/dom/wildcard-source.txx (limited to 'libxsd/xsd/cxx/xml/dom') diff --git a/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx new file mode 100644 index 0000000..624c0e8 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx @@ -0,0 +1,158 @@ +// file : xsd/cxx/xml/dom/auto-ptr.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_AUTO_PTR_HXX +#define XSD_CXX_XML_DOM_AUTO_PTR_HXX + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // Simple auto_ptr version that calls release() instead of delete. + // + + template + struct remove_c + { + typedef T r; + }; + + template + struct remove_c + { + typedef T r; + }; + + template + struct auto_ptr_ref + { + T* x_; + + explicit + auto_ptr_ref (T* x) + : x_ (x) + { + } + }; + + template + struct auto_ptr + { + ~auto_ptr () + { + reset (); + } + + explicit + auto_ptr (T* x = 0) + : x_ (x) + { + } + + auto_ptr (auto_ptr& y) + : x_ (y.release ()) + { + } + + template + auto_ptr (auto_ptr& y) + : x_ (y.release ()) + { + } + + auto_ptr (auto_ptr_ref r) + : x_ (r.x_) + { + } + + auto_ptr& + operator= (auto_ptr& y) + { + if (x_ != y.x_) + reset (y.release ()); + + return *this; + } + + template + auto_ptr& + operator= (auto_ptr& y) + { + if (x_ != y.x_) + reset (y.release ()); + + return *this; + } + + auto_ptr& + operator= (auto_ptr_ref r) + { + if (r.x_ != x_) + reset (r.x_); + + return *this; + } + + template + operator auto_ptr_ref () + { + return auto_ptr_ref (release ()); + } + + template + operator auto_ptr () + { + return auto_ptr (release ()); + } + + public: + T& + operator* () const + { + return *x_; + } + + T* + operator-> () const + { + return x_; + } + + T* + get () const + { + return x_; + } + + T* + release () + { + T* x (x_); + x_ = 0; + return x; + } + + void + reset (T* x = 0) + { + if (x_) + const_cast::r*> (x_)->release (); + + x_ = x; + } + + private: + T* x_; + }; + } + } + } +} + +#endif // XSD_CXX_XML_DOM_AUTO_PTR_HXX diff --git a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx new file mode 100644 index 0000000..e0d9f1d --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx @@ -0,0 +1,61 @@ +// file : xsd/cxx/xml/dom/bits/error-handler-proxy.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_BITS_ERROR_HANDLER_PROXY_HXX +#define XSD_CXX_XML_DOM_BITS_ERROR_HANDLER_PROXY_HXX + +#include +#include +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + namespace bits + { + template + class error_handler_proxy: public xercesc::DOMErrorHandler + { + public: + error_handler_proxy (error_handler& eh) + : failed_ (false), eh_ (&eh), native_eh_ (0) + { + } + + error_handler_proxy (xercesc::DOMErrorHandler& eh) + : failed_ (false), eh_ (0), native_eh_ (&eh) + { + } + + virtual bool + handleError (const xercesc::DOMError& e); + + bool + failed () const + { + return failed_; + } + + private: + bool failed_; + error_handler* eh_; + xercesc::DOMErrorHandler* native_eh_; + }; + } + } + } + } +} + +#include + +#endif // XSD_CXX_XML_DOM_BITS_ERROR_HANDLER_PROXY_HXX diff --git a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx new file mode 100644 index 0000000..65a2cf3 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx @@ -0,0 +1,80 @@ +// file : xsd/cxx/xml/dom/bits/error-handler-proxy.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + namespace bits + { + template + bool error_handler_proxy:: + handleError (const xercesc::DOMError& e) + { + using xercesc::DOMError; + + if (e.getSeverity() != DOMError::DOM_SEVERITY_WARNING) + failed_ = true; + + if (native_eh_) + return native_eh_->handleError (e); + else + { + typedef typename error_handler::severity severity; + + severity s (severity::error); + + switch (e.getSeverity()) + { + case DOMError::DOM_SEVERITY_WARNING: + { + s = severity::warning; + break; + } + case DOMError::DOM_SEVERITY_ERROR: + { + s = severity::error; + break; + } + case DOMError::DOM_SEVERITY_FATAL_ERROR: + { + s = severity::fatal; + break; + } + } + + xercesc::DOMLocator* loc (e.getLocation ()); + +#if _XERCES_VERSION >= 30000 + return eh_->handle ( + transcode (loc->getURI ()), + static_cast (loc->getLineNumber ()), + static_cast (loc->getColumnNumber ()), + s, + transcode (e.getMessage ())); +#else + XMLSSize_t l (loc->getLineNumber ()); + XMLSSize_t c (loc->getColumnNumber ()); + + return eh_->handle ( + transcode (loc->getURI ()), + (l == -1 ? 0 : static_cast (l)), + (c == -1 ? 0 : static_cast (c)), + s, + transcode (e.getMessage ())); +#endif + } + } + } + } + } + } +} diff --git a/libxsd/xsd/cxx/xml/dom/elements.hxx b/libxsd/xsd/cxx/xml/dom/elements.hxx new file mode 100644 index 0000000..9c4623b --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/elements.hxx @@ -0,0 +1,36 @@ +// file : xsd/cxx/xml/dom/elements.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_ELEMENTS_HXX +#define XSD_CXX_XML_DOM_ELEMENTS_HXX + +#include +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + template + qualified_name + name (const xercesc::DOMAttr&); + + template + qualified_name + name (const xercesc::DOMElement&); + } + } + } +} + +#include + +#endif // XSD_CXX_XML_DOM_ELEMENTS_HXX diff --git a/libxsd/xsd/cxx/xml/dom/elements.txx b/libxsd/xsd/cxx/xml/dom/elements.txx new file mode 100644 index 0000000..0286237 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/elements.txx @@ -0,0 +1,57 @@ +// file : xsd/cxx/xml/dom/elements.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + template + qualified_name + name (const xercesc::DOMAttr& a) + { + const XMLCh* n (a.getLocalName ()); + + // If this DOM doesn't support namespaces then use getName. + // + if (n != 0) + { + if (const XMLCh* ns = a.getNamespaceURI ()) + return qualified_name (transcode (n), transcode (ns)); + else + return qualified_name (transcode (n)); + } + else + return qualified_name (transcode (a.getName ())); + } + + + template + qualified_name + name (const xercesc::DOMElement& e) + { + const XMLCh* n (e.getLocalName ()); + + // If this DOM doesn't support namespaces then use getTagName. + // + if (n != 0) + { + if (const XMLCh* ns = e.getNamespaceURI ()) + return qualified_name (transcode (n), transcode (ns)); + else + return qualified_name (transcode (n)); + } + else + return qualified_name (transcode (e.getTagName ())); + } + } + } + } +} diff --git a/libxsd/xsd/cxx/xml/dom/parsing-header.hxx b/libxsd/xsd/cxx/xml/dom/parsing-header.hxx new file mode 100644 index 0000000..6e82c7e --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/parsing-header.hxx @@ -0,0 +1,24 @@ +// file : xsd/cxx/xml/dom/parsing-header.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_PARSING_HEADER_HXX +#define XSD_CXX_XML_DOM_PARSING_HEADER_HXX + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + template + class parser; + } + } + } +} + +#endif // XSD_CXX_XML_DOM_PARSING_HEADER_HXX diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.hxx b/libxsd/xsd/cxx/xml/dom/parsing-source.hxx new file mode 100644 index 0000000..b6abd58 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/parsing-source.hxx @@ -0,0 +1,138 @@ +// file : xsd/cxx/xml/dom/parsing-source.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_PARSING_SOURCE_HXX +#define XSD_CXX_XML_DOM_PARSING_SOURCE_HXX + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include // properies +#include + +#include +#include // name +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // Parser state object. Can be used for parsing element, attributes, + // or both. + // + template + class parser + { + public: + parser (const xercesc::DOMElement& e, bool ep, bool ap); + + bool + more_elements () + { + return next_element_ != 0; + } + + const xercesc::DOMElement& + cur_element () + { + return *static_cast (next_element_); + } + + void + next_element (); + + bool + more_attributes () + { + return as_ > ai_; + } + + const xercesc::DOMAttr& + next_attribute () + { + return *static_cast (a_->item (ai_++)); + } + + void + reset_attributes () + { + ai_ = 0; + } + + const xercesc::DOMElement& + element () const + { + return element_; + } + + private: + parser (const parser&); + + parser& + operator= (const parser&); + + private: + const xercesc::DOMElement& element_; + const xercesc::DOMNode* next_element_; + + const xercesc::DOMNamedNodeMap* a_; + XMLSize_t ai_; // Index of the next DOMAttr. + XMLSize_t as_; // Cached size of a_. + }; + + + // Parsing flags. + // + const unsigned long dont_validate = 0x00000400UL; + const unsigned long no_muliple_imports = 0x00000800UL; + + template + xml::dom::auto_ptr + parse (xercesc::InputSource&, + error_handler&, + const properties&, + unsigned long flags); + + template + xml::dom::auto_ptr + parse (xercesc::InputSource&, + xercesc::DOMErrorHandler&, + const properties&, + unsigned long flags); + + template + xml::dom::auto_ptr + parse (const std::basic_string& uri, + error_handler&, + const properties&, + unsigned long flags); + + template + xml::dom::auto_ptr + parse (const std::basic_string& uri, + xercesc::DOMErrorHandler&, + const properties&, + unsigned long flags); + } + } + } +} + +#include + +#endif // XSD_CXX_XML_DOM_PARSING_SOURCE_HXX diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/libxsd/xsd/cxx/xml/dom/parsing-source.txx new file mode 100644 index 0000000..ae7ceea --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/parsing-source.txx @@ -0,0 +1,458 @@ +// file : xsd/cxx/xml/dom/parsing-source.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#if _XERCES_VERSION >= 30000 +# include +#else +# include +#endif +#include +#include +#include + +#include // xercesc::fg* +#include // chLatin_L, etc + +#include + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // parser + // + template + parser:: + parser (const xercesc::DOMElement& e, bool ep, bool ap) + : element_ (e), + next_element_ (0), + a_ (0), + ai_ (0) + { + using xercesc::DOMNode; + + if (ep) + { + for (next_element_ = e.getFirstChild (); + next_element_ != 0 && + next_element_->getNodeType () != DOMNode::ELEMENT_NODE; + next_element_ = next_element_->getNextSibling ()) /*noop*/; + } + + if (ap) + { + a_ = e.getAttributes (); + as_ = a_->getLength (); + } + } + + template + void parser:: + next_element () + { + using xercesc::DOMNode; + + for (next_element_ = next_element_->getNextSibling (); + next_element_ != 0 && + next_element_->getNodeType () != DOMNode::ELEMENT_NODE; + next_element_ = next_element_->getNextSibling ())/*noop*/; + } + + // parse() + // + template + xml::dom::auto_ptr + parse (xercesc::InputSource& is, + error_handler& eh, + const properties& prop, + unsigned long flags) + { + bits::error_handler_proxy ehp (eh); + return xml::dom::parse (is, ehp, prop, flags); + } + + template + auto_ptr + parse (xercesc::InputSource& is, + xercesc::DOMErrorHandler& eh, + const properties& prop, + unsigned long flags) + { + // HP aCC cannot handle using namespace xercesc; + // + using xercesc::DOMImplementationRegistry; + using xercesc::DOMImplementationLS; + using xercesc::DOMImplementation; + using xercesc::DOMDocument; +#if _XERCES_VERSION >= 30000 + using xercesc::DOMLSParser; + using xercesc::DOMConfiguration; +#else + using xercesc::DOMBuilder; +#endif + + using xercesc::Wrapper4InputSource; + using xercesc::XMLUni; + + + // Instantiate the DOM parser. + // + const XMLCh ls_id[] = {xercesc::chLatin_L, + xercesc::chLatin_S, + xercesc::chNull}; + + // Get an implementation of the Load-Store (LS) interface. + // + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + +#if _XERCES_VERSION >= 30000 + 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); + + if (flags & dont_validate) + { + conf->setParameter (XMLUni::fgDOMValidate, false); + conf->setParameter (XMLUni::fgXercesSchema, false); + conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + } + else + { + conf->setParameter (XMLUni::fgDOMValidate, true); + conf->setParameter (XMLUni::fgXercesSchema, true); + + if (!(flags & no_muliple_imports)) + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); + + // This feature checks the schema grammar for additional + // errors. We most likely do not need it when validating + // instances (assuming the schema is valid). + // + conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + } + + // We will release DOM ourselves. + // + conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); + + + // Transfer properies if any. + // + + if (!prop.schema_location ().empty ()) + { + xml::string sl (prop.schema_location ()); + const void* v (sl.c_str ()); + + conf->setParameter ( + XMLUni::fgXercesSchemaExternalSchemaLocation, + const_cast (v)); + } + + if (!prop.no_namespace_schema_location ().empty ()) + { + xml::string sl (prop.no_namespace_schema_location ()); + const void* v (sl.c_str ()); + + conf->setParameter ( + XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + const_cast (v)); + } + + // Set error handler. + // + bits::error_handler_proxy ehp (eh); + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + +#else // _XERCES_VERSION >= 30000 + + // Same as above but for Xerces-C++ 2 series. + // + auto_ptr 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); + + if (flags & dont_validate) + { + parser->setFeature (XMLUni::fgDOMValidation, false); + parser->setFeature (XMLUni::fgXercesSchema, false); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + else + { + parser->setFeature (XMLUni::fgDOMValidation, true); + parser->setFeature (XMLUni::fgXercesSchema, true); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + + parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); + + if (!prop.schema_location ().empty ()) + { + xml::string sl (prop.schema_location ()); + const void* v (sl.c_str ()); + + parser->setProperty ( + XMLUni::fgXercesSchemaExternalSchemaLocation, + const_cast (v)); + } + + if (!prop.no_namespace_schema_location ().empty ()) + { + xml::string sl (prop.no_namespace_schema_location ()); + const void* v (sl.c_str ()); + + parser->setProperty ( + XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + const_cast (v)); + } + + bits::error_handler_proxy ehp (eh); + parser->setErrorHandler (&ehp); + +#endif // _XERCES_VERSION >= 30000 + + xercesc::Wrapper4InputSource wrap (&is, false); + +#if _XERCES_VERSION >= 30000 + auto_ptr doc (parser->parse (&wrap)); +#else + auto_ptr doc (parser->parse (wrap)); +#endif + if (ehp.failed ()) + doc.reset (); + + return doc; + } + + template + xml::dom::auto_ptr + parse (const std::basic_string& uri, + error_handler& eh, + const properties& prop, + unsigned long flags) + { + bits::error_handler_proxy ehp (eh); + return xml::dom::parse (uri, ehp, prop, flags); + } + + template + auto_ptr + parse (const std::basic_string& uri, + xercesc::DOMErrorHandler& eh, + const properties& prop, + unsigned long flags) + { + // HP aCC cannot handle using namespace xercesc; + // + using xercesc::DOMImplementationRegistry; + using xercesc::DOMImplementationLS; + using xercesc::DOMImplementation; + using xercesc::DOMDocument; +#if _XERCES_VERSION >= 30000 + using xercesc::DOMLSParser; + using xercesc::DOMConfiguration; +#else + using xercesc::DOMBuilder; +#endif + using xercesc::XMLUni; + + + // Instantiate the DOM parser. + // + const XMLCh ls_id[] = {xercesc::chLatin_L, + xercesc::chLatin_S, + xercesc::chNull}; + + // Get an implementation of the Load-Store (LS) interface. + // + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls_id)); + +#if _XERCES_VERSION >= 30000 + 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); + + if (flags & dont_validate) + { + conf->setParameter (XMLUni::fgDOMValidate, false); + conf->setParameter (XMLUni::fgXercesSchema, false); + conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + } + else + { + conf->setParameter (XMLUni::fgDOMValidate, true); + conf->setParameter (XMLUni::fgXercesSchema, true); + + if (!(flags & no_muliple_imports)) + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); + + // This feature checks the schema grammar for additional + // errors. We most likely do not need it when validating + // instances (assuming the schema is valid). + // + conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + } + + // We will release DOM ourselves. + // + conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); + + + // Transfer properies if any. + // + + if (!prop.schema_location ().empty ()) + { + xml::string sl (prop.schema_location ()); + const void* v (sl.c_str ()); + + conf->setParameter ( + XMLUni::fgXercesSchemaExternalSchemaLocation, + const_cast (v)); + } + + if (!prop.no_namespace_schema_location ().empty ()) + { + xml::string sl (prop.no_namespace_schema_location ()); + const void* v (sl.c_str ()); + + conf->setParameter ( + XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + const_cast (v)); + } + + // Set error handler. + // + bits::error_handler_proxy ehp (eh); + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + +#else // _XERCES_VERSION >= 30000 + + // Same as above but for Xerces-C++ 2 series. + // + auto_ptr 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); + + if (flags & dont_validate) + { + parser->setFeature (XMLUni::fgDOMValidation, false); + parser->setFeature (XMLUni::fgXercesSchema, false); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + else + { + parser->setFeature (XMLUni::fgDOMValidation, true); + parser->setFeature (XMLUni::fgXercesSchema, true); + parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + } + + parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); + + if (!prop.schema_location ().empty ()) + { + xml::string sl (prop.schema_location ()); + const void* v (sl.c_str ()); + + parser->setProperty ( + XMLUni::fgXercesSchemaExternalSchemaLocation, + const_cast (v)); + } + + if (!prop.no_namespace_schema_location ().empty ()) + { + xml::string sl (prop.no_namespace_schema_location ()); + const void* v (sl.c_str ()); + + parser->setProperty ( + XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, + const_cast (v)); + } + + bits::error_handler_proxy ehp (eh); + parser->setErrorHandler (&ehp); + +#endif // _XERCES_VERSION >= 30000 + + auto_ptr doc ( + parser->parseURI (string (uri).c_str ())); + + if (ehp.failed ()) + doc.reset (); + + return doc; + } + } + } + } +} diff --git a/libxsd/xsd/cxx/xml/dom/serialization-header.hxx b/libxsd/xsd/cxx/xml/dom/serialization-header.hxx new file mode 100644 index 0000000..c8d836c --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/serialization-header.hxx @@ -0,0 +1,81 @@ +// file : xsd/cxx/xml/dom/serialization-header.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_SERIALIZATION_HEADER_HXX +#define XSD_CXX_XML_DOM_SERIALIZATION_HEADER_HXX + +#include +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // Find an existing prefix or establish a new one. Try to use + // hint if provided and available. + // + template + std::basic_string + prefix (const C* ns, xercesc::DOMElement&, const C* hint = 0); + + template + inline std::basic_string + prefix (const std::basic_string& ns, + xercesc::DOMElement& e, + const C* hint = 0) + { + return prefix (ns.c_str (), e, hint); + } + + // + // + template + void + clear (xercesc::DOMElement&); + + // + // + template + class namespace_info + { + public: + typedef std::basic_string string; + + namespace_info () + { + } + + namespace_info (const string& name_, const string& schema_) + : name (name_), + schema (schema_) + { + } + + std::basic_string name; + std::basic_string schema; + }; + + + // Map of namespace prefix to namespace_info. + // + template + class namespace_infomap: + public std::map, namespace_info > + { + }; + } + } + } +} + +#include + +#endif // XSD_CXX_XML_DOM_SERIALIZATION_HEADER_HXX diff --git a/libxsd/xsd/cxx/xml/dom/serialization-header.txx b/libxsd/xsd/cxx/xml/dom/serialization-header.txx new file mode 100644 index 0000000..76d3d43 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/serialization-header.txx @@ -0,0 +1,192 @@ +// file : xsd/cxx/xml/dom/serialization-header.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include +#include // std::size_t + +#include +#include +#include + +#include // xercesc::fg* +#include +#include + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // + // + template + std::basic_string + prefix (const C* ns, xercesc::DOMElement& e, const C* hint) + { + string xns (ns); + +#if _XERCES_VERSION >= 30000 + const XMLCh* p (e.lookupPrefix (xns.c_str ())); +#else + const XMLCh* p (e.lookupNamespacePrefix (xns.c_str (), false)); +#endif + if (p != 0) + return transcode (p); + + if (e.isDefaultNamespace (xns.c_str ())) + return std::basic_string (); + + // 'xml' prefix requires special handling and Xerces folks + // refuse to handle this in DOM so I have to do it myself. + // + if (std::basic_string (ns) == xml::bits::xml_namespace ()) + return xml::bits::xml_prefix (); + + // No prefix for this namespace. Will need to establish one. + // + std::basic_string prefix; + + if (hint != 0 && + e.lookupNamespaceURI (xml::string (hint).c_str ()) == 0) + { + prefix = hint; + } + else + { + for (unsigned long n (1);; ++n) + { + // Make finding the first few prefixes fast. + // + switch (n) + { + case 1: + { + prefix = xml::bits::first_prefix (); + break; + } + case 2: + { + prefix = xml::bits::second_prefix (); + break; + } + case 3: + { + prefix = xml::bits::third_prefix (); + break; + } + case 4: + { + prefix = xml::bits::fourth_prefix (); + break; + } + case 5: + { + prefix = xml::bits::fifth_prefix (); + break; + } + default: + { + std::basic_ostringstream ostr; + ostr << C ('p') << n; + prefix = ostr.str (); + break; + } + } + + if (e.lookupNamespaceURI (xml::string (prefix).c_str ()) == 0) + break; + } + } + + std::basic_string name (xml::bits::xmlns_prefix ()); + name += C(':'); + name += prefix; + + e.setAttributeNS ( + xercesc::XMLUni::fgXMLNSURIName, + xml::string (name).c_str (), + xns.c_str ()); + + return prefix; + } + + // + // + template + void + clear (xercesc::DOMElement& e) + { + // HP aCC cannot handle using namespace xercesc; + // + using xercesc::DOMNode; + using xercesc::DOMAttr; + using xercesc::DOMNamedNodeMap; + using xercesc::XMLString; + using xercesc::SchemaSymbols; + + // Remove child nodes. + // + while (xercesc::DOMNode* n = e.getFirstChild ()) + { + e.removeChild (n); + n->release (); + } + + // Remove attributes. + // + DOMNamedNodeMap* att_map (e.getAttributes ()); + XMLSize_t n (att_map->getLength ()); + + if (n != 0) + { + std::vector atts; + + // Collect all attributes to be removed while filtering + // out special cases (xmlns & xsi). + // + for (XMLSize_t i (0); i != n; ++i) + { + DOMAttr* a (static_cast (att_map->item (i))); + const XMLCh* ns (a->getNamespaceURI ()); + + if (ns != 0) + { + if (XMLString::equals (ns, xercesc::XMLUni::fgXMLNSURIName)) + continue; + + if (XMLString::equals (ns, SchemaSymbols::fgURI_XSI)) + { + const XMLCh* name (a->getLocalName ()); + + if (XMLString::equals ( + name, SchemaSymbols::fgXSI_SCHEMALOCACTION) || + XMLString::equals ( + name, SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCACTION)) + continue; + } + } + + atts.push_back (a); + } + + for (std::vector::iterator i (atts.begin ()), + end (atts.end ()); i != end; ++i) + { + e.removeAttributeNode (*i); + (*i)->release (); + } + } + } + } + } + } +} diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx new file mode 100644 index 0000000..4593f9c --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx @@ -0,0 +1,152 @@ +// file : xsd/cxx/xml/dom/serialization-source.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX +#define XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX + +#include +#include + +#include +#include +#include +#include +#include // XMLFormatTarget, XMLFormatter + +#include +#include +#include // name +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // + // + template + xercesc::DOMAttr& + create_attribute (const C* name, xercesc::DOMElement&); + + template + xercesc::DOMAttr& + create_attribute (const C* name, const C* ns, xercesc::DOMElement&); + + template + xercesc::DOMElement& + create_element (const C* name, xercesc::DOMElement&); + + template + xercesc::DOMElement& + create_element (const C* name, const C* ns, xercesc::DOMElement&); + + // Serialization flags. + // + const unsigned long no_xml_declaration = 0x00010000UL; + const unsigned long dont_pretty_print = 0x00020000UL; + + template + xml::dom::auto_ptr + serialize (const std::basic_string& root_element, + const std::basic_string& root_element_namespace, + const namespace_infomap& map, + unsigned long flags); + + // This one helps Sun C++ to overcome its fears. + // + template + inline xml::dom::auto_ptr + serialize (const C* root_element, + const C* root_element_namespace, + const namespace_infomap& map, + unsigned long flags) + { + return serialize (std::basic_string (root_element), + std::basic_string (root_element_namespace), + map, + flags); + } + + // + // + template + bool + serialize (xercesc::XMLFormatTarget& target, + const xercesc::DOMDocument& doc, + const std::basic_string& enconding, + error_handler& eh, + unsigned long flags); + + template + bool + serialize (xercesc::XMLFormatTarget& target, + const xercesc::DOMDocument& doc, + const std::basic_string& enconding, + xercesc::DOMErrorHandler& eh, + unsigned long flags); + + // + // + class ostream_format_target: public xercesc::XMLFormatTarget + { + public: + ostream_format_target (std::ostream& os) + : os_ (os) + { + } + + + public: + // I know, some of those consts are stupid. But that's what + // Xerces folks put into their interfaces and VC-7.1 thinks + // there are different signatures if one strips this fluff off. + // + virtual void + writeChars (const XMLByte* const buf, +#if _XERCES_VERSION >= 30000 + const XMLSize_t size, +#else + const unsigned int size, +#endif + xercesc::XMLFormatter* const) + { + // Ignore the data if there was a stream failure and + // the stream is not using exceptions. + // + if (!(os_.bad () || os_.fail ())) + { + os_.write (reinterpret_cast (buf), + static_cast (size)); + } + } + + + virtual void + flush () + { + // Ignore the flush request if there was a stream failure + // and the stream is not using exceptions. + // + if (!(os_.bad () || os_.fail ())) + { + os_.flush (); + } + } + + private: + std::ostream& os_; + }; + } + } + } +} + +#include + +#endif // XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.txx b/libxsd/xsd/cxx/xml/dom/serialization-source.txx new file mode 100644 index 0000000..5aaaaed --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/serialization-source.txx @@ -0,0 +1,394 @@ +// file : xsd/cxx/xml/dom/serialization-source.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include // xercesc::fg* +#include // chLatin_L, etc +#include + +#if _XERCES_VERSION >= 30000 +# include +# include +#else +# include +#endif +#include +#include +#include + +#include +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + // + // + template + xercesc::DOMAttr& + create_attribute (const C* name, xercesc::DOMElement& parent) + { + xercesc::DOMDocument* doc (parent.getOwnerDocument ()); + xercesc::DOMAttr* a (doc->createAttribute (string (name).c_str ())); + parent.setAttributeNode (a); + return *a; + } + + template + xercesc::DOMAttr& + create_attribute (const C* name, + const C* ns, + xercesc::DOMElement& parent) + { + if (ns[0] == C ('\0')) + return create_attribute (name, parent); + + xercesc::DOMDocument* doc (parent.getOwnerDocument ()); + + xercesc::DOMAttr* a; + std::basic_string p (prefix (ns, parent)); + + if (!p.empty ()) + { + p += ':'; + p += name; + a = doc->createAttributeNS (string (ns).c_str (), + string (p).c_str ()); + } + else + a = doc->createAttributeNS (string (ns).c_str (), + string (name).c_str ()); + + parent.setAttributeNodeNS (a); + return *a; + } + + template + xercesc::DOMElement& + create_element (const C* name, xercesc::DOMElement& parent) + { + xercesc::DOMDocument* doc (parent.getOwnerDocument ()); + xercesc::DOMElement* e (doc->createElement (string (name).c_str ())); + parent.appendChild (e); + return *e; + } + + template + xercesc::DOMElement& + create_element (const C* name, + const C* ns, + xercesc::DOMElement& parent) + { + if (ns[0] == C ('\0')) + return create_element (name, parent); + + xercesc::DOMDocument* doc (parent.getOwnerDocument ()); + + xercesc::DOMElement* e; + std::basic_string p (prefix (ns, parent)); + + if (!p.empty ()) + { + p += ':'; + p += name; + e = doc->createElementNS (string (ns).c_str (), + string (p).c_str ()); + } + else + e = doc->createElementNS (string (ns).c_str (), + string (name).c_str ()); + + parent.appendChild (e); + return *e; + } + + + // + // + template + auto_ptr + serialize (const std::basic_string& el, + const std::basic_string& ns, + const namespace_infomap& map, + unsigned long) + { + // HP aCC cannot handle using namespace xercesc; + // + using xercesc::DOMImplementationRegistry; + using xercesc::DOMImplementation; + using xercesc::DOMDocument; + using xercesc::DOMElement; + + // + // + typedef std::basic_string string; + typedef namespace_infomap infomap; + typedef typename infomap::const_iterator infomap_iterator; + + C colon (':'), space (' '); + + string prefix; + + if (!ns.empty ()) + { + infomap_iterator i (map.begin ()), e (map.end ()); + + for ( ;i != e; ++i) + { + if (i->second.name == ns) + { + prefix = i->first; + break; + } + } + + // Since this is the first namespace in document we don't + // need to worry about conflicts. + // + if (i == e) + prefix = xml::bits::first_prefix (); + } + + const XMLCh ls[] = {xercesc::chLatin_L, + xercesc::chLatin_S, + xercesc::chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls)); + + auto_ptr doc ( + impl->createDocument ( + (ns.empty () ? 0 : xml::string (ns).c_str ()), + xml::string ((prefix.empty () + ? el + : prefix + colon + el)).c_str (), + 0)); + + DOMElement* root (doc->getDocumentElement ()); + + // Check if we need to provide xsi mapping. + // + bool xsi (false); + string xsi_prefix; + string xmlns_prefix (xml::bits::xmlns_prefix ()); + + for (infomap_iterator i (map.begin ()), e (map.end ()); i != e; ++i) + { + if (!i->second.schema.empty ()) + { + xsi = true; + break; + } + } + + // Check if we were told to provide xsi mapping. + // + if (xsi) + { + for (infomap_iterator i (map.begin ()), e (map.end ()); + i != e; + ++i) + { + if (i->second.name == xml::bits::xsi_namespace ()) + { + xsi_prefix = i->first; + xsi = false; + break; + } + } + } + + // Create user-defined mappings. + // + for (infomap_iterator i (map.begin ()), e (map.end ()); i != e; ++i) + { + if (i->first.empty ()) + { + // Empty prefix. + // + if (!i->second.name.empty ()) + root->setAttributeNS ( + xercesc::XMLUni::fgXMLNSURIName, + xml::string (xmlns_prefix).c_str (), + xml::string (i->second.name).c_str ()); + } + else + { + root->setAttributeNS ( + xercesc::XMLUni::fgXMLNSURIName, + xml::string (xmlns_prefix + colon + i->first).c_str (), + xml::string (i->second.name).c_str ()); + } + } + + // If we were not told to provide xsi mapping but we need it + // then we will have to add it ourselves. + // + if (xsi) + xsi_prefix = dom::prefix (xml::bits::xsi_namespace (), + *root, + xml::bits::xsi_prefix ()); + + // Create xsi:schemaLocation and xsi:noNamespaceSchemaLocation + // attributes. + // + string schema_location; + string no_namespace_schema_location; + + for (infomap_iterator i (map.begin ()), e (map.end ()); i != e; ++i) + { + if (!i->second.schema.empty ()) + { + if (i->second.name.empty ()) + { + if (!no_namespace_schema_location.empty ()) + no_namespace_schema_location += space; + + no_namespace_schema_location += i->second.schema; + } + else + { + if (!schema_location.empty ()) + schema_location += space; + + schema_location += i->second.name + space + i->second.schema; + } + } + } + + if (!schema_location.empty ()) + { + root->setAttributeNS ( + xercesc::SchemaSymbols::fgURI_XSI, + xml::string (xsi_prefix + colon + + xml::bits::schema_location ()).c_str (), + xml::string (schema_location).c_str ()); + } + + if (!no_namespace_schema_location.empty ()) + { + root->setAttributeNS ( + xercesc::SchemaSymbols::fgURI_XSI, + xml::string ( + xsi_prefix + colon + + xml::bits::no_namespace_schema_location ()).c_str (), + xml::string (no_namespace_schema_location).c_str ()); + } + + return doc; + } + + + template + bool + serialize (xercesc::XMLFormatTarget& target, + const xercesc::DOMDocument& doc, + const std::basic_string& encoding, + xercesc::DOMErrorHandler& eh, + unsigned long flags) + { + // HP aCC cannot handle using namespace xercesc; + // + using xercesc::DOMImplementationRegistry; + using xercesc::DOMImplementation; +#if _XERCES_VERSION >= 30000 + using xercesc::DOMLSSerializer; + using xercesc::DOMConfiguration; + using xercesc::DOMLSOutput; +#else + using xercesc::DOMWriter; +#endif + using xercesc::XMLUni; + + const XMLCh ls[] = {xercesc::chLatin_L, + xercesc::chLatin_S, + xercesc::chNull}; + + DOMImplementation* impl ( + DOMImplementationRegistry::getDOMImplementation (ls)); + + bits::error_handler_proxy ehp (eh); + +#if _XERCES_VERSION >= 30000 + xml::dom::auto_ptr writer ( + impl->createLSSerializer ()); + + DOMConfiguration* conf (writer->getDomConfig ()); + + conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); + + // Set some nice features if the serializer supports them. + // + if (conf->canSetParameter ( + XMLUni::fgDOMWRTDiscardDefaultContent, true)) + conf->setParameter (XMLUni::fgDOMWRTDiscardDefaultContent, true); + + if (!(flags & dont_pretty_print) && + conf->canSetParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true)) + conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); + + // See if we need to write XML declaration. + // + if ((flags & no_xml_declaration) && + conf->canSetParameter (XMLUni::fgDOMXMLDeclaration, false)) + conf->setParameter (XMLUni::fgDOMXMLDeclaration, false); + + xml::dom::auto_ptr out (impl->createLSOutput ()); + + out->setEncoding (xml::string (encoding).c_str ()); + out->setByteStream (&target); + + bool r (writer->write (&doc, out.get ())); +#else + xml::dom::auto_ptr writer (impl->createDOMWriter ()); + + writer->setErrorHandler (&ehp); + writer->setEncoding (xml::string (encoding).c_str ()); + + // Set some nice features if the serializer supports them. + // + if (writer->canSetFeature ( + XMLUni::fgDOMWRTDiscardDefaultContent, true)) + writer->setFeature (XMLUni::fgDOMWRTDiscardDefaultContent, true); + + if (!(flags & dont_pretty_print) && + writer->canSetFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true)) + writer->setFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true); + + // See if we need to write XML declaration. + // + if ((flags & no_xml_declaration) && + writer->canSetFeature (XMLUni::fgDOMXMLDeclaration, false)) + writer->setFeature (XMLUni::fgDOMXMLDeclaration, false); + + bool r (writer->writeNode (&target, doc)); +#endif + + if (!r || ehp.failed ()) + return false; + + return true; + } + + template + bool + serialize (xercesc::XMLFormatTarget& target, + const xercesc::DOMDocument& doc, + const std::basic_string& enconding, + error_handler& eh, + unsigned long flags) + { + bits::error_handler_proxy ehp (eh); + return serialize (target, doc, enconding, ehp, flags); + } + } + } + } +} diff --git a/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx b/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx new file mode 100644 index 0000000..b001f56 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx @@ -0,0 +1,31 @@ +// file : xsd/cxx/xml/dom/wildcard-source.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_XML_DOM_WILDCARD_SOURCE_HXX +#define XSD_CXX_XML_DOM_WILDCARD_SOURCE_HXX + +#include + +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + template + xml::dom::auto_ptr + create_document (); + } + } + } +} + +#include + +#endif // XSD_CXX_XML_DOM_WILDCARD_SOURCE_HXX diff --git a/libxsd/xsd/cxx/xml/dom/wildcard-source.txx b/libxsd/xsd/cxx/xml/dom/wildcard-source.txx new file mode 100644 index 0000000..dcd54d2 --- /dev/null +++ b/libxsd/xsd/cxx/xml/dom/wildcard-source.txx @@ -0,0 +1,39 @@ +// file : xsd/cxx/xml/dom/wildcard-source.txx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include // chLatin_L, etc + +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace xml + { + namespace dom + { + template + xml::dom::auto_ptr + create_document () + { + const XMLCh ls[] = {xercesc::chLatin_L, + xercesc::chLatin_S, + xercesc::chNull}; + + // Get an implementation of the Load-Store (LS) interface. + // + xercesc::DOMImplementation* impl ( + xercesc::DOMImplementationRegistry::getDOMImplementation (ls)); + + return xml::dom::auto_ptr ( + impl->createDocument ()); + } + } + } + } +} + -- cgit v1.1