summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml/dom
diff options
context:
space:
mode:
Diffstat (limited to 'libxsd/xsd/cxx/xml/dom')
-rw-r--r--libxsd/xsd/cxx/xml/dom/auto-ptr.hxx232
-rw-r--r--libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx59
-rw-r--r--libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx66
-rw-r--r--libxsd/xsd/cxx/xml/dom/elements.hxx34
-rw-r--r--libxsd/xsd/cxx/xml/dom/elements.txx55
-rw-r--r--libxsd/xsd/cxx/xml/dom/parsing-header.hxx22
-rw-r--r--libxsd/xsd/cxx/xml/dom/parsing-source.hxx152
-rw-r--r--libxsd/xsd/cxx/xml/dom/parsing-source.txx379
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-header.hxx79
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-header.txx188
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-source.hxx181
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-source.txx362
-rw-r--r--libxsd/xsd/cxx/xml/dom/wildcard-source.hxx29
-rw-r--r--libxsd/xsd/cxx/xml/dom/wildcard-source.txx36
14 files changed, 0 insertions, 1874 deletions
diff --git a/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx b/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
deleted file mode 100644
index 97c9399..0000000
--- a/libxsd/xsd/cxx/xml/dom/auto-ptr.hxx
+++ /dev/null
@@ -1,232 +0,0 @@
-// file : xsd/cxx/xml/dom/auto-ptr.hxx
-// 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
-
-#include <xsd/cxx/config.hxx> // XSD_CXX11_*
-
-#ifdef XSD_CXX11
-# include <memory> // std::unique_ptr
-# include <utility> // std::move
-# include <type_traits> // std::remove_const
-#endif
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
-#ifdef XSD_CXX11
- template <typename T>
- struct deleter
- {
- void
- operator() (T* p) const
- {
- if (p != 0)
- const_cast<typename std::remove_const<T>::type*> (p)->release ();
- }
- };
-
-#ifdef XSD_CXX11_TEMPLATE_ALIAS
- template <typename T>
- using unique_ptr = std::unique_ptr<T, deleter<T>>;
-#else
- template <typename T>
- class unique_ptr: public std::unique_ptr<T, deleter<T>>
- {
- public:
- typedef std::unique_ptr<T, deleter<T>> base;
-
- typedef typename base::pointer pointer;
- typedef T element_type;
- typedef deleter<T> deleter_type;
-
- unique_ptr (): base () {}
- explicit unique_ptr (pointer p): base (p) {}
- unique_ptr (pointer p, const deleter_type& d): base (p, d) {}
- unique_ptr (pointer p, deleter_type&& d): base (p, std::move (d)) {}
- unique_ptr (unique_ptr&& p): base (std::move (p)) {}
- template <class T1>
- unique_ptr (unique_ptr<T1>&& p): base (std::move (p)) {}
- template <class T1>
- unique_ptr (std::auto_ptr<T1>&& p): base (std::move (p)) {}
-
- unique_ptr& operator= (unique_ptr&& p)
- {
- static_cast<base&> (*this) = std::move (p);
- return *this;
- }
-
- template <class T1>
- unique_ptr& operator= (unique_ptr<T1>&& p)
- {
- static_cast<base&> (*this) = std::move (p);
- return *this;
- }
-
-#ifdef XSD_CXX11_NULLPTR
- unique_ptr (std::nullptr_t p): base (p) {}
-
- unique_ptr& operator= (std::nullptr_t p)
- {
- static_cast<base&> (*this) = p;
- return *this;
- }
-#endif
- };
-#endif // XSD_CXX11_TEMPLATE_ALIAS
-
-#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::unique_ptr
-
-#else
- // Simple auto_ptr version for C++98 that calls release() instead
- // of delete.
- //
- template <typename T>
- struct remove_c
- {
- typedef T r;
- };
-
- template <typename T>
- struct remove_c<const T>
- {
- typedef T r;
- };
-
- template <typename T>
- struct auto_ptr_ref
- {
- T* x_;
-
- explicit
- auto_ptr_ref (T* x)
- : x_ (x)
- {
- }
- };
-
- template <typename T>
- struct auto_ptr
- {
- ~auto_ptr ()
- {
- reset ();
- }
-
- explicit
- auto_ptr (T* x = 0)
- : x_ (x)
- {
- }
-
- auto_ptr (auto_ptr& y)
- : x_ (y.release ())
- {
- }
-
- template <typename T2>
- auto_ptr (auto_ptr<T2>& y)
- : x_ (y.release ())
- {
- }
-
- auto_ptr (auto_ptr_ref<T> r)
- : x_ (r.x_)
- {
- }
-
- auto_ptr&
- operator= (auto_ptr& y)
- {
- if (x_ != y.x_)
- reset (y.release ());
-
- return *this;
- }
-
- template <typename T2>
- auto_ptr&
- operator= (auto_ptr<T2>& y)
- {
- if (x_ != y.x_)
- reset (y.release ());
-
- return *this;
- }
-
- auto_ptr&
- operator= (auto_ptr_ref<T> r)
- {
- if (r.x_ != x_)
- reset (r.x_);
-
- return *this;
- }
-
- template <typename T2>
- operator auto_ptr_ref<T2> ()
- {
- return auto_ptr_ref<T2> (release ());
- }
-
- template <typename T2>
- operator auto_ptr<T2> ()
- {
- return auto_ptr<T2> (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<typename remove_c<T>::r*> (x_)->release ();
-
- x_ = x;
- }
-
- private:
- T* x_;
- };
-
-#define XSD_DOM_AUTO_PTR xsd::cxx::xml::dom::auto_ptr
-
-#endif // XSD_CXX11
- }
- }
- }
-}
-
-#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
deleted file mode 100644
index 5154b62..0000000
--- a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.hxx
+++ /dev/null
@@ -1,59 +0,0 @@
-// file : xsd/cxx/xml/dom/bits/error-handler-proxy.hxx
-// 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 <xercesc/dom/DOMError.hpp>
-#include <xercesc/dom/DOMLocator.hpp>
-#include <xercesc/dom/DOMErrorHandler.hpp>
-
-#include <xsd/cxx/xml/error-handler.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- namespace bits
- {
- template <typename C>
- class error_handler_proxy: public xercesc::DOMErrorHandler
- {
- public:
- error_handler_proxy (error_handler<C>& 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<C>* eh_;
- xercesc::DOMErrorHandler* native_eh_;
- };
- }
- }
- }
- }
-}
-
-#include <xsd/cxx/xml/dom/bits/error-handler-proxy.txx>
-
-#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
deleted file mode 100644
index a1f83ff..0000000
--- a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx
+++ /dev/null
@@ -1,66 +0,0 @@
-// file : xsd/cxx/xml/dom/bits/error-handler-proxy.txx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#include <xsd/cxx/xml/string.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- namespace bits
- {
- template <typename C>
- bool error_handler_proxy<C>::
- 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<C>::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 ());
-
- return eh_->handle (
- transcode<C> (loc->getURI ()),
- static_cast<unsigned long> (loc->getLineNumber ()),
- static_cast<unsigned long> (loc->getColumnNumber ()),
- s,
- transcode<C> (e.getMessage ()));
- }
- }
- }
- }
- }
- }
-}
diff --git a/libxsd/xsd/cxx/xml/dom/elements.hxx b/libxsd/xsd/cxx/xml/dom/elements.hxx
deleted file mode 100644
index 1244395..0000000
--- a/libxsd/xsd/cxx/xml/dom/elements.hxx
+++ /dev/null
@@ -1,34 +0,0 @@
-// file : xsd/cxx/xml/dom/elements.hxx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#ifndef XSD_CXX_XML_DOM_ELEMENTS_HXX
-#define XSD_CXX_XML_DOM_ELEMENTS_HXX
-
-#include <xercesc/dom/DOMAttr.hpp>
-#include <xercesc/dom/DOMElement.hpp>
-
-#include <xsd/cxx/xml/qualified-name.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- template <typename C>
- qualified_name<C>
- name (const xercesc::DOMAttr&);
-
- template <typename C>
- qualified_name<C>
- name (const xercesc::DOMElement&);
- }
- }
- }
-}
-
-#include <xsd/cxx/xml/dom/elements.txx>
-
-#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
deleted file mode 100644
index 46e4866..0000000
--- a/libxsd/xsd/cxx/xml/dom/elements.txx
+++ /dev/null
@@ -1,55 +0,0 @@
-// file : xsd/cxx/xml/dom/elements.txx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#include <xsd/cxx/xml/string.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- template <typename C>
- qualified_name<C>
- 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<C> (transcode<C> (n), transcode<C> (ns));
- else
- return qualified_name<C> (transcode<C> (n));
- }
- else
- return qualified_name<C> (transcode<C> (a.getName ()));
- }
-
-
- template <typename C>
- qualified_name<C>
- 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<C> (transcode<C> (n), transcode<C> (ns));
- else
- return qualified_name<C> (transcode<C> (n));
- }
- else
- return qualified_name<C> (transcode<C> (e.getTagName ()));
- }
- }
- }
- }
-}
diff --git a/libxsd/xsd/cxx/xml/dom/parsing-header.hxx b/libxsd/xsd/cxx/xml/dom/parsing-header.hxx
deleted file mode 100644
index b7bf344..0000000
--- a/libxsd/xsd/cxx/xml/dom/parsing-header.hxx
+++ /dev/null
@@ -1,22 +0,0 @@
-// file : xsd/cxx/xml/dom/parsing-header.hxx
-// 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 <typename C>
- 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
deleted file mode 100644
index fc0bd71..0000000
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.hxx
+++ /dev/null
@@ -1,152 +0,0 @@
-// file : xsd/cxx/xml/dom/parsing-source.hxx
-// 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 <string>
-
-#include <xercesc/dom/DOMNode.hpp>
-#include <xercesc/dom/DOMAttr.hpp>
-#include <xercesc/dom/DOMElement.hpp>
-#include <xercesc/dom/DOMDocument.hpp>
-#include <xercesc/dom/DOMNamedNodeMap.hpp>
-#include <xercesc/dom/DOMErrorHandler.hpp>
-
-#include <xercesc/sax/InputSource.hpp>
-
-#include <xsd/cxx/xml/elements.hxx> // properies
-#include <xsd/cxx/xml/error-handler.hxx>
-#include <xsd/cxx/xml/dom/auto-ptr.hxx>
-#include <xsd/cxx/xml/dom/elements.hxx> // name
-#include <xsd/cxx/xml/dom/parsing-header.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- // Parser state object. Can be used for parsing elements (and
- // optionally text), attributes, or both.
- //
- template <typename C>
- class parser
- {
- public:
- parser (const xercesc::DOMElement& e, bool ep, bool tp, bool ap);
-
- // Content parsing.
- //
- bool
- more_content ()
- {
- return next_content_ != 0;
- }
-
- const xercesc::DOMElement&
- cur_element ()
- {
- return *static_cast<const xercesc::DOMElement*> (next_content_);
- }
-
- const xercesc::DOMText&
- cur_text ()
- {
- return *static_cast<const xercesc::DOMText*> (next_content_);
- }
-
- bool
- cur_is_text ()
- {
- return next_content_->getNodeType () !=
- xercesc::DOMNode::ELEMENT_NODE;
- }
-
- void
- next_content (bool text);
-
- // Attribute parsing.
- //
- bool
- more_attributes ()
- {
- return as_ > ai_;
- }
-
- const xercesc::DOMAttr&
- next_attribute ()
- {
- return *static_cast<const xercesc::DOMAttr*> (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_content_;
-
- 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 <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (xercesc::InputSource&,
- error_handler<C>&,
- const properties<C>&,
- unsigned long flags);
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (xercesc::InputSource&,
- xercesc::DOMErrorHandler&,
- const properties<C>&,
- unsigned long flags);
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (const std::basic_string<C>& uri,
- error_handler<C>&,
- const properties<C>&,
- unsigned long flags);
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (const std::basic_string<C>& uri,
- xercesc::DOMErrorHandler&,
- const properties<C>&,
- unsigned long flags);
- }
- }
- }
-}
-
-#include <xsd/cxx/xml/dom/parsing-source.txx>
-
-#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
deleted file mode 100644
index 6543671..0000000
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.txx
+++ /dev/null
@@ -1,379 +0,0 @@
-// file : xsd/cxx/xml/dom/parsing-source.txx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#include <xercesc/dom/DOMLSParser.hpp>
-#include <xercesc/dom/DOMLSException.hpp>
-
-#include <xercesc/dom/DOMNamedNodeMap.hpp>
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/dom/DOMImplementationRegistry.hpp>
-
-#include <xercesc/util/XMLUni.hpp> // xercesc::fg*
-#include <xercesc/util/XMLUniDefs.hpp> // chLatin_L, etc
-
-#include <xercesc/framework/Wrapper4InputSource.hpp>
-
-#include <xsd/cxx/xml/string.hxx>
-#include <xsd/cxx/xml/dom/bits/error-handler-proxy.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- // parser
- //
- template <typename C>
- parser<C>::
- parser (const xercesc::DOMElement& e, bool ep, bool tp, bool ap)
- : element_ (e),
- next_content_ (0),
- a_ (0),
- ai_ (0)
- {
- using xercesc::DOMNode;
-
- if (ep)
- {
- for (next_content_ = e.getFirstChild ();;
- next_content_ = next_content_->getNextSibling ())
- {
- if (next_content_ == 0)
- break;
-
- DOMNode::NodeType t (next_content_->getNodeType ());
-
- if (t == DOMNode::ELEMENT_NODE)
- break;
-
- if (tp && (t == DOMNode::TEXT_NODE ||
- t == DOMNode::CDATA_SECTION_NODE))
- break;
- }
- }
-
- if (ap)
- {
- a_ = e.getAttributes ();
- as_ = a_->getLength ();
- }
- }
-
- template <typename C>
- void parser<C>::
- next_content (bool tp)
- {
- using xercesc::DOMNode;
-
- for (next_content_ = next_content_->getNextSibling ();;
- next_content_ = next_content_->getNextSibling ())
- {
- if (next_content_ == 0)
- break;
-
- DOMNode::NodeType t (next_content_->getNodeType ());
-
- if (t == DOMNode::ELEMENT_NODE)
- break;
-
- if (tp && (t == DOMNode::TEXT_NODE ||
- t == DOMNode::CDATA_SECTION_NODE))
- break;
- }
- }
-
- // parse()
- //
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (xercesc::InputSource& is,
- error_handler<C>& eh,
- const properties<C>& prop,
- unsigned long flags)
- {
- bits::error_handler_proxy<C> ehp (eh);
- return xml::dom::parse (is, ehp, prop, flags);
- }
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (xercesc::InputSource& is,
- xercesc::DOMErrorHandler& eh,
- const properties<C>& prop,
- unsigned long flags)
- {
- using namespace xercesc;
-
- // 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));
-
- XSD_DOM_AUTO_PTR<DOMLSParser> 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);
-
- // Xerces-C++ 3.1.0 is the first version with working multi import
- // support.
- //
-#if _XERCES_VERSION >= 30100
- if (!(flags & no_muliple_imports))
- conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true);
-#endif
- // 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<void*> (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<void*> (v));
- }
-
- // If external schema location was specified, disable loading
- // schemas via the schema location attributes in the document.
- //
-#if _XERCES_VERSION >= 30100
- if (!prop.schema_location ().empty () ||
- !prop.no_namespace_schema_location ().empty ())
- {
- conf->setParameter (XMLUni::fgXercesLoadSchema, false);
- }
-#endif
- // Set error handler.
- //
- bits::error_handler_proxy<C> ehp (eh);
- conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
-
- xercesc::Wrapper4InputSource wrap (&is, false);
-
- XSD_DOM_AUTO_PTR<DOMDocument> doc;
- try
- {
- doc.reset (parser->parse (&wrap));
- }
- catch (const xercesc::DOMLSException&)
- {
- }
-
- if (ehp.failed ())
- doc.reset ();
-
- return doc;
- }
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (const std::basic_string<C>& uri,
- error_handler<C>& eh,
- const properties<C>& prop,
- unsigned long flags)
- {
- bits::error_handler_proxy<C> ehp (eh);
- return xml::dom::parse (uri, ehp, prop, flags);
- }
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- parse (const std::basic_string<C>& uri,
- xercesc::DOMErrorHandler& eh,
- const properties<C>& prop,
- unsigned long flags)
- {
- using namespace xercesc;
-
- // 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));
-
- XSD_DOM_AUTO_PTR<DOMLSParser> 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);
-
- // Xerces-C++ 3.1.0 is the first version with working multi import
- // support.
- //
-#if _XERCES_VERSION >= 30100
- if (!(flags & no_muliple_imports))
- conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true);
-#endif
-
- // 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<void*> (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<void*> (v));
- }
-
- // If external schema location was specified, disable loading
- // schemas via the schema location attributes in the document.
- //
-#if _XERCES_VERSION >= 30100
- if (!prop.schema_location ().empty () ||
- !prop.no_namespace_schema_location ().empty ())
- {
- conf->setParameter (XMLUni::fgXercesLoadSchema, false);
- }
-#endif
- // Set error handler.
- //
- bits::error_handler_proxy<C> ehp (eh);
- conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
-
- XSD_DOM_AUTO_PTR<DOMDocument> doc;
- try
- {
- doc.reset (parser->parseURI (string (uri).c_str ()));
- }
- catch (const xercesc::DOMLSException&)
- {
- }
-
- 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
deleted file mode 100644
index 8d3d6e9..0000000
--- a/libxsd/xsd/cxx/xml/dom/serialization-header.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-// file : xsd/cxx/xml/dom/serialization-header.hxx
-// 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 <map>
-#include <string>
-
-#include <xercesc/dom/DOMElement.hpp>
-
-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 <typename C>
- std::basic_string<C>
- prefix (const C* ns, xercesc::DOMElement&, const C* hint = 0);
-
- template <typename C>
- inline std::basic_string<C>
- prefix (const std::basic_string<C>& ns,
- xercesc::DOMElement& e,
- const C* hint = 0)
- {
- return prefix (ns.c_str (), e, hint);
- }
-
- //
- //
- template <typename C>
- void
- clear (xercesc::DOMElement&);
-
- //
- //
- template <typename C>
- class namespace_info
- {
- public:
- typedef std::basic_string<C> string;
-
- namespace_info ()
- {
- }
-
- namespace_info (const string& name_, const string& schema_)
- : name (name_),
- schema (schema_)
- {
- }
-
- std::basic_string<C> name;
- std::basic_string<C> schema;
- };
-
-
- // Map of namespace prefix to namespace_info.
- //
- template <typename C>
- class namespace_infomap:
- public std::map<std::basic_string<C>, namespace_info<C> >
- {
- };
- }
- }
- }
-}
-
-#include <xsd/cxx/xml/dom/serialization-header.txx>
-
-#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
deleted file mode 100644
index 997dfe9..0000000
--- a/libxsd/xsd/cxx/xml/dom/serialization-header.txx
+++ /dev/null
@@ -1,188 +0,0 @@
-// file : xsd/cxx/xml/dom/serialization-header.txx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#include <vector>
-#include <sstream>
-#include <cstddef> // std::size_t
-
-#include <xercesc/dom/DOMNode.hpp>
-#include <xercesc/dom/DOMAttr.hpp>
-#include <xercesc/dom/DOMNamedNodeMap.hpp>
-
-#include <xercesc/util/XMLUni.hpp> // xercesc::fg*
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/validators/schema/SchemaSymbols.hpp>
-
-#include <xsd/cxx/xml/string.hxx>
-#include <xsd/cxx/xml/bits/literals.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- //
- //
- template <typename C>
- std::basic_string<C>
- prefix (const C* ns, xercesc::DOMElement& e, const C* hint)
- {
- string xns (ns);
- const XMLCh* p (e.lookupPrefix (xns.c_str ()));
-
- if (p != 0)
- return transcode<C> (p);
-
- if (e.isDefaultNamespace (xns.c_str ()))
- return std::basic_string<C> ();
-
- // '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<C> (ns) == xml::bits::xml_namespace<C> ())
- return xml::bits::xml_prefix<C> ();
-
- // No prefix for this namespace. Will need to establish one.
- //
- std::basic_string<C> 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<C> ();
- break;
- }
- case 2:
- {
- prefix = xml::bits::second_prefix<C> ();
- break;
- }
- case 3:
- {
- prefix = xml::bits::third_prefix<C> ();
- break;
- }
- case 4:
- {
- prefix = xml::bits::fourth_prefix<C> ();
- break;
- }
- case 5:
- {
- prefix = xml::bits::fifth_prefix<C> ();
- break;
- }
- default:
- {
- std::basic_ostringstream<C> ostr;
- ostr << C ('p') << n;
- prefix = ostr.str ();
- break;
- }
- }
-
- if (e.lookupNamespaceURI (xml::string (prefix).c_str ()) == 0)
- break;
- }
- }
-
- std::basic_string<C> name (xml::bits::xmlns_prefix<C> ());
- name += C(':');
- name += prefix;
-
- e.setAttributeNS (
- xercesc::XMLUni::fgXMLNSURIName,
- xml::string (name).c_str (),
- xns.c_str ());
-
- return prefix;
- }
-
- //
- //
- template <typename C>
- void
- clear (xercesc::DOMElement& e)
- {
- // Cannot use 'using namespace' because of MSXML conflict.
- //
- using xercesc::XMLUni;
- using xercesc::XMLString;
- using xercesc::SchemaSymbols;
-
- using xercesc::DOMNode;
- using xercesc::DOMAttr;
- using xercesc::DOMNamedNodeMap;
-
- // Remove child nodes.
- //
- while (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<DOMAttr*> 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<DOMAttr*> (att_map->item (i)));
- const XMLCh* ns (a->getNamespaceURI ());
-
- if (ns != 0)
- {
- if (XMLString::equals (ns, 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<DOMAttr*>::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
deleted file mode 100644
index a25e2ca..0000000
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
+++ /dev/null
@@ -1,181 +0,0 @@
-// file : xsd/cxx/xml/dom/serialization-source.hxx
-// 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 <string>
-#include <cstring> // std::memcpy
-#include <ostream>
-
-#include <xercesc/dom/DOMAttr.hpp>
-#include <xercesc/dom/DOMElement.hpp>
-#include <xercesc/dom/DOMDocument.hpp>
-#include <xercesc/dom/DOMErrorHandler.hpp>
-#include <xercesc/framework/XMLFormatter.hpp> // XMLFormatTarget, XMLFormatter
-
-#include <xsd/cxx/xml/error-handler.hxx>
-#include <xsd/cxx/xml/dom/auto-ptr.hxx>
-#include <xsd/cxx/xml/dom/elements.hxx> // name
-#include <xsd/cxx/xml/dom/serialization-header.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- //
- //
- template <typename C>
- xercesc::DOMAttr&
- create_attribute (const C* name, xercesc::DOMElement&);
-
- template <typename C>
- xercesc::DOMAttr&
- create_attribute (const C* name, const C* ns, xercesc::DOMElement&);
-
- template <typename C>
- xercesc::DOMElement&
- create_element (const C* name, xercesc::DOMElement&);
-
- template <typename C>
- xercesc::DOMElement&
- create_element (const C* name, const C* ns, xercesc::DOMElement&);
-
- // Add namespace declarations and schema locations.
- //
- template <typename C>
- void
- add_namespaces (xercesc::DOMElement&, const namespace_infomap<C>&);
-
- // Serialization flags.
- //
- const unsigned long no_xml_declaration = 0x00010000UL;
- const unsigned long dont_pretty_print = 0x00020000UL;
-
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- serialize (const std::basic_string<C>& root_element,
- const std::basic_string<C>& root_element_namespace,
- const namespace_infomap<C>& map,
- unsigned long flags);
-
- // This one helps Sun C++ to overcome its fears.
- //
- template <typename C>
- inline XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- serialize (const C* root_element,
- const C* root_element_namespace,
- const namespace_infomap<C>& map,
- unsigned long flags)
- {
- return serialize (std::basic_string<C> (root_element),
- std::basic_string<C> (root_element_namespace),
- map,
- flags);
- }
-
- //
- //
- template <typename C>
- bool
- serialize (xercesc::XMLFormatTarget& target,
- const xercesc::DOMDocument& doc,
- const std::basic_string<C>& enconding,
- error_handler<C>& eh,
- unsigned long flags);
-
- template <typename C>
- bool
- serialize (xercesc::XMLFormatTarget& target,
- const xercesc::DOMDocument& doc,
- const std::basic_string<C>& enconding,
- xercesc::DOMErrorHandler& eh,
- unsigned long flags);
-
-
- class ostream_format_target: public xercesc::XMLFormatTarget
- {
- public:
- ostream_format_target (std::ostream& os)
- : n_ (0), os_ (os)
- {
- }
-
- public:
- // I know, some of those consts are stupid. But that's what
- // Xerces folks put into their interfaces and VC thinks there
- // are different signatures if one strips this fluff off.
- //
- virtual void
- writeChars (const XMLByte* const buf,
- const XMLSize_t size,
- xercesc::XMLFormatter* const)
- {
- // Ignore the write request if there was a stream failure and the
- // stream is not using exceptions.
- //
- if (os_.fail ())
- return;
-
- // Flush the buffer if the block is too large or if we don't have
- // any space left.
- //
- if ((size >= buf_size_ / 8 || n_ + size > buf_size_) && n_ != 0)
- {
- os_.write (buf_, static_cast<std::streamsize> (n_));
- n_ = 0;
-
- if (os_.fail ())
- return;
- }
-
- if (size < buf_size_ / 8)
- {
- std::memcpy (buf_ + n_, reinterpret_cast<const char*> (buf), size);
- n_ += size;
- }
- else
- os_.write (reinterpret_cast<const char*> (buf),
- static_cast<std::streamsize> (size));
- }
-
-
- virtual void
- flush ()
- {
- // Ignore the flush request if there was a stream failure
- // and the stream is not using exceptions.
- //
- if (!os_.fail ())
- {
- if (n_ != 0)
- {
- os_.write (buf_, static_cast<std::streamsize> (n_));
- n_ = 0;
-
- if (os_.fail ())
- return;
- }
-
- os_.flush ();
- }
- }
-
- private:
- static const std::size_t buf_size_ = 1024;
- char buf_[buf_size_];
- std::size_t n_;
- std::ostream& os_;
- };
- }
- }
- }
-}
-
-#include <xsd/cxx/xml/dom/serialization-source.txx>
-
-#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
deleted file mode 100644
index b59e109..0000000
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.txx
+++ /dev/null
@@ -1,362 +0,0 @@
-// file : xsd/cxx/xml/dom/serialization-source.txx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#include <xercesc/util/XMLUni.hpp> // xercesc::fg*
-#include <xercesc/util/XMLUniDefs.hpp> // chLatin_L, etc
-#include <xercesc/validators/schema/SchemaSymbols.hpp>
-
-#include <xercesc/dom/DOMLSOutput.hpp>
-#include <xercesc/dom/DOMLSSerializer.hpp>
-
-#include <xercesc/dom/DOMElement.hpp>
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/dom/DOMImplementationRegistry.hpp>
-
-#include <xsd/cxx/xml/string.hxx>
-#include <xsd/cxx/xml/bits/literals.hxx>
-#include <xsd/cxx/xml/dom/bits/error-handler-proxy.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- //
- //
- template <typename C>
- 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 <typename C>
- 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<C> p (prefix<C> (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 <typename C>
- 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 <typename C>
- 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<C> p (prefix<C> (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 <typename C>
- void
- add_namespaces (xercesc::DOMElement& el,
- const namespace_infomap<C>& map)
- {
- using namespace xercesc;
-
- typedef std::basic_string<C> string;
- typedef namespace_infomap<C> infomap;
- typedef typename infomap::const_iterator infomap_iterator;
-
- C colon (':'), space (' ');
-
- // Check if we need to provide xsi mapping.
- //
- bool xsi (false);
- string xsi_prefix;
- string xmlns_prefix (xml::bits::xmlns_prefix<C> ());
-
- 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<C> ())
- {
- 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 ())
- el.setAttributeNS (
- xercesc::XMLUni::fgXMLNSURIName,
- xml::string (xmlns_prefix).c_str (),
- xml::string (i->second.name).c_str ());
- }
- else
- {
- el.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<C> (),
- el,
- xml::bits::xsi_prefix<C> ());
-
- // 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 ())
- {
- el.setAttributeNS (
- xercesc::SchemaSymbols::fgURI_XSI,
- xml::string (xsi_prefix + colon +
- xml::bits::schema_location<C> ()).c_str (),
- xml::string (schema_location).c_str ());
- }
-
- if (!no_namespace_schema_location.empty ())
- {
- el.setAttributeNS (
- xercesc::SchemaSymbols::fgURI_XSI,
- xml::string (
- xsi_prefix + colon +
- xml::bits::no_namespace_schema_location<C> ()).c_str (),
- xml::string (no_namespace_schema_location).c_str ());
- }
- }
-
- //
- //
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- serialize (const std::basic_string<C>& el,
- const std::basic_string<C>& ns,
- const namespace_infomap<C>& map,
- unsigned long)
- {
- using namespace xercesc;
-
- typedef std::basic_string<C> string;
- typedef namespace_infomap<C> infomap;
- typedef typename infomap::const_iterator infomap_iterator;
-
- 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<C> ();
- }
-
- const XMLCh ls[] = {xercesc::chLatin_L,
- xercesc::chLatin_S,
- xercesc::chNull};
-
- DOMImplementation* impl (
- DOMImplementationRegistry::getDOMImplementation (ls));
-
- XSD_DOM_AUTO_PTR<DOMDocument> doc (
- impl->createDocument (
- (ns.empty () ? 0 : xml::string (ns).c_str ()),
- xml::string ((prefix.empty ()
- ? el
- : prefix + C (':') + el)).c_str (),
- 0));
-
- add_namespaces (*doc->getDocumentElement (), map);
-
- return doc;
- }
-
-
- template <typename C>
- bool
- serialize (xercesc::XMLFormatTarget& target,
- const xercesc::DOMDocument& doc,
- const std::basic_string<C>& encoding,
- xercesc::DOMErrorHandler& eh,
- unsigned long flags)
- {
- using namespace xercesc;
-
- const XMLCh ls[] = {xercesc::chLatin_L,
- xercesc::chLatin_S,
- xercesc::chNull};
-
- DOMImplementation* impl (
- DOMImplementationRegistry::getDOMImplementation (ls));
-
- bits::error_handler_proxy<C> ehp (eh);
-
- XSD_DOM_AUTO_PTR<DOMLSSerializer> 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);
-
- // Don't add extra new lines between first-level elements.
- //
- if (conf->canSetParameter (XMLUni::fgDOMWRTXercesPrettyPrint, true))
- conf->setParameter (XMLUni::fgDOMWRTXercesPrettyPrint, false);
- }
-
- // See if we need to write XML declaration.
- //
- if ((flags & no_xml_declaration) &&
- conf->canSetParameter (XMLUni::fgDOMXMLDeclaration, false))
- conf->setParameter (XMLUni::fgDOMXMLDeclaration, false);
-
- XSD_DOM_AUTO_PTR<DOMLSOutput> out (impl->createLSOutput ());
-
- out->setEncoding (xml::string (encoding).c_str ());
- out->setByteStream (&target);
-
- if (!writer->write (&doc, out.get ()) || ehp.failed ())
- return false;
-
- return true;
- }
-
- template <typename C>
- bool
- serialize (xercesc::XMLFormatTarget& target,
- const xercesc::DOMDocument& doc,
- const std::basic_string<C>& enconding,
- error_handler<C>& eh,
- unsigned long flags)
- {
- bits::error_handler_proxy<C> 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
deleted file mode 100644
index 66c0ae6..0000000
--- a/libxsd/xsd/cxx/xml/dom/wildcard-source.hxx
+++ /dev/null
@@ -1,29 +0,0 @@
-// file : xsd/cxx/xml/dom/wildcard-source.hxx
-// 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 <xercesc/dom/DOMDocument.hpp>
-
-#include <xsd/cxx/xml/dom/auto-ptr.hxx>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- create_document ();
- }
- }
- }
-}
-
-#include <xsd/cxx/xml/dom/wildcard-source.txx>
-
-#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
deleted file mode 100644
index 5249235..0000000
--- a/libxsd/xsd/cxx/xml/dom/wildcard-source.txx
+++ /dev/null
@@ -1,36 +0,0 @@
-// file : xsd/cxx/xml/dom/wildcard-source.txx
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#include <xercesc/util/XMLUniDefs.hpp> // chLatin_L, etc
-
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/dom/DOMImplementationRegistry.hpp>
-
-namespace xsd
-{
- namespace cxx
- {
- namespace xml
- {
- namespace dom
- {
- template <typename C>
- XSD_DOM_AUTO_PTR<xercesc::DOMDocument>
- 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 XSD_DOM_AUTO_PTR<xercesc::DOMDocument> (
- impl->createDocument ());
- }
- }
- }
- }
-}