summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml
diff options
context:
space:
mode:
Diffstat (limited to 'libxsd/xsd/cxx/xml')
-rw-r--r--libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx12
-rw-r--r--libxsd/xsd/cxx/xml/dom/parsing-source.txx139
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-header.txx6
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-source.hxx4
-rw-r--r--libxsd/xsd/cxx/xml/dom/serialization-source.txx42
-rw-r--r--libxsd/xsd/cxx/xml/elements.hxx5
-rw-r--r--libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx11
-rw-r--r--libxsd/xsd/cxx/xml/sax/std-input-source.hxx29
-rw-r--r--libxsd/xsd/cxx/xml/std-memory-manager.hxx6
9 files changed, 18 insertions, 236 deletions
diff --git a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx
index 109c0e7..d5dff65 100644
--- a/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx
+++ b/libxsd/xsd/cxx/xml/dom/bits/error-handler-proxy.txx
@@ -53,24 +53,12 @@ namespace xsd
xercesc::DOMLocator* loc (e.getLocation ());
-#if _XERCES_VERSION >= 30000
return eh_->handle (
transcode<C> (loc->getURI ()),
static_cast<unsigned long> (loc->getLineNumber ()),
static_cast<unsigned long> (loc->getColumnNumber ()),
s,
transcode<C> (e.getMessage ()));
-#else
- XMLSSize_t l (loc->getLineNumber ());
- XMLSSize_t c (loc->getColumnNumber ());
-
- return eh_->handle (
- transcode<C> (loc->getURI ()),
- (l == -1 ? 0 : static_cast<unsigned long> (l)),
- (c == -1 ? 0 : static_cast<unsigned long> (c)),
- s,
- transcode<C> (e.getMessage ()));
-#endif
}
}
}
diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/libxsd/xsd/cxx/xml/dom/parsing-source.txx
index 545eb82..cde2179 100644
--- a/libxsd/xsd/cxx/xml/dom/parsing-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/parsing-source.txx
@@ -3,12 +3,9 @@
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-#if _XERCES_VERSION >= 30000
-# include <xercesc/dom/DOMLSParser.hpp>
-# include <xercesc/dom/DOMLSException.hpp>
-#else
-# include <xercesc/dom/DOMBuilder.hpp>
-#endif
+#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>
@@ -94,12 +91,8 @@ namespace xsd
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;
@@ -116,7 +109,6 @@ namespace xsd
DOMImplementation* impl (
DOMImplementationRegistry::getDOMImplementation (ls_id));
-#if _XERCES_VERSION >= 30000
auto_ptr<DOMLSParser> parser (
impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
@@ -163,7 +155,6 @@ namespace xsd
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).
@@ -214,64 +205,9 @@ namespace xsd
bits::error_handler_proxy<C> ehp (eh);
conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
-#else // _XERCES_VERSION >= 30000
-
- // Same as above but for Xerces-C++ 2 series.
- //
- auto_ptr<DOMBuilder> parser (
- impl->createDOMBuilder (DOMImplementationLS::MODE_SYNCHRONOUS, 0));
-
- parser->setFeature (XMLUni::fgDOMComments, false);
- parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true);
- parser->setFeature (XMLUni::fgDOMEntities, false);
- parser->setFeature (XMLUni::fgDOMNamespaces, true);
- parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false);
-
- 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<void*> (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<void*> (v));
- }
-
- bits::error_handler_proxy<C> ehp (eh);
- parser->setErrorHandler (&ehp);
-
-#endif // _XERCES_VERSION >= 30000
-
xercesc::Wrapper4InputSource wrap (&is, false);
-#if _XERCES_VERSION >= 30000
auto_ptr<DOMDocument> doc;
-
try
{
doc.reset (parser->parse (&wrap));
@@ -279,9 +215,7 @@ namespace xsd
catch (const xercesc::DOMLSException&)
{
}
-#else
- auto_ptr<DOMDocument> doc (parser->parse (wrap));
-#endif
+
if (ehp.failed ())
doc.reset ();
@@ -312,12 +246,8 @@ namespace xsd
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;
@@ -332,7 +262,6 @@ namespace xsd
DOMImplementation* impl (
DOMImplementationRegistry::getDOMImplementation (ls_id));
-#if _XERCES_VERSION >= 30000
auto_ptr<DOMLSParser> parser (
impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0));
@@ -430,63 +359,7 @@ namespace xsd
bits::error_handler_proxy<C> ehp (eh);
conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp);
-#else // _XERCES_VERSION >= 30000
-
- // Same as above but for Xerces-C++ 2 series.
- //
- auto_ptr<DOMBuilder> parser (
- impl->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0));
-
- parser->setFeature (XMLUni::fgDOMComments, false);
- parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true);
- parser->setFeature (XMLUni::fgDOMEntities, false);
- parser->setFeature (XMLUni::fgDOMNamespaces, true);
- parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false);
-
- 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<void*> (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<void*> (v));
- }
-
- bits::error_handler_proxy<C> ehp (eh);
- parser->setErrorHandler (&ehp);
-
-#endif // _XERCES_VERSION >= 30000
-
-
-#if _XERCES_VERSION >= 30000
auto_ptr<DOMDocument> doc;
-
try
{
doc.reset (parser->parseURI (string (uri).c_str ()));
@@ -494,10 +367,6 @@ namespace xsd
catch (const xercesc::DOMLSException&)
{
}
-#else
- auto_ptr<DOMDocument> doc (
- parser->parseURI (string (uri).c_str ()));
-#endif
if (ehp.failed ())
doc.reset ();
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-header.txx b/libxsd/xsd/cxx/xml/dom/serialization-header.txx
index 567581a..cce3c52 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-header.txx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-header.txx
@@ -33,12 +33,8 @@ namespace xsd
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<C> (p);
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
index ce81f2a..9bfd27b 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-source.hxx
@@ -108,11 +108,7 @@ namespace xsd
//
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 write request if there was a stream failure and the
diff --git a/libxsd/xsd/cxx/xml/dom/serialization-source.txx b/libxsd/xsd/cxx/xml/dom/serialization-source.txx
index 2caf361..da0dbb7 100644
--- a/libxsd/xsd/cxx/xml/dom/serialization-source.txx
+++ b/libxsd/xsd/cxx/xml/dom/serialization-source.txx
@@ -7,12 +7,9 @@
#include <xercesc/util/XMLUniDefs.hpp> // chLatin_L, etc
#include <xercesc/validators/schema/SchemaSymbols.hpp>
-#if _XERCES_VERSION >= 30000
-# include <xercesc/dom/DOMLSOutput.hpp>
-# include <xercesc/dom/DOMLSSerializer.hpp>
-#else
-# include <xercesc/dom/DOMWriter.hpp>
-#endif
+#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>
@@ -298,13 +295,9 @@ namespace xsd
//
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,
@@ -316,7 +309,6 @@ namespace xsd
bits::error_handler_proxy<C> ehp (eh);
-#if _XERCES_VERSION >= 30000
xml::dom::auto_ptr<DOMLSSerializer> writer (
impl->createLSSerializer ());
@@ -345,33 +337,7 @@ namespace xsd
out->setEncoding (xml::string (encoding).c_str ());
out->setByteStream (&target);
- bool r (writer->write (&doc, out.get ()));
-#else
- xml::dom::auto_ptr<DOMWriter> 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 ())
+ if (!writer->write (&doc, out.get ()) || ehp.failed ())
return false;
return true;
diff --git a/libxsd/xsd/cxx/xml/elements.hxx b/libxsd/xsd/cxx/xml/elements.hxx
index 990a2aa..4c6e887 100644
--- a/libxsd/xsd/cxx/xml/elements.hxx
+++ b/libxsd/xsd/cxx/xml/elements.hxx
@@ -8,8 +8,13 @@
#include <string>
+#include <xercesc/util/XercesVersion.hpp>
#include <xercesc/util/PlatformUtils.hpp>
+#if _XERCES_VERSION < 30000
+# error Xerces-C++ 2-series is not supported
+#endif
+
namespace xsd
{
namespace cxx
diff --git a/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx b/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx
index 8487e74..31b1a34 100644
--- a/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx
+++ b/libxsd/xsd/cxx/xml/sax/bits/error-handler-proxy.txx
@@ -65,22 +65,11 @@ namespace xsd
if (id == 0)
id = e.getSystemId ();
-#if _XERCES_VERSION >= 30000
eh_->handle (transcode<C> (id),
static_cast<unsigned long> (e.getLineNumber ()),
static_cast<unsigned long> (e.getColumnNumber ()),
s,
transcode<C> (e.getMessage ()));
-#else
- XMLSSize_t l (e.getLineNumber ());
- XMLSSize_t c (e.getColumnNumber ());
-
- eh_->handle (transcode<C> (id),
- (l == -1 ? 0 : static_cast<unsigned long> (l)),
- (c == -1 ? 0 : static_cast<unsigned long> (c)),
- s,
- transcode<C> (e.getMessage ()));
-#endif
}
}
}
diff --git a/libxsd/xsd/cxx/xml/sax/std-input-source.hxx b/libxsd/xsd/cxx/xml/sax/std-input-source.hxx
index 6b0af98..6f3ee38 100644
--- a/libxsd/xsd/cxx/xml/sax/std-input-source.hxx
+++ b/libxsd/xsd/cxx/xml/sax/std-input-source.hxx
@@ -29,27 +29,14 @@ namespace xsd
{
}
-#if _XERCES_VERSION >= 30000
virtual XMLFilePos
curPos () const
{
return static_cast<XMLFilePos> (is_.tellg ());
}
-#else
- virtual unsigned int
- curPos () const
- {
- return static_cast<unsigned int> (is_.tellg ());
- }
-#endif
-#if _XERCES_VERSION >= 30000
virtual XMLSize_t
readBytes (XMLByte* const buf, const XMLSize_t size)
-#else
- virtual unsigned int
- readBytes (XMLByte* const buf, const unsigned int size)
-#endif
{
// Some implementations don't clear gcount if you
// call read() on a stream that is in the eof state.
@@ -78,25 +65,17 @@ namespace xsd
// Make sure that if we failed, readBytes won't be called
// again.
//
- if (!is_.fail ())
- {
-#if _XERCES_VERSION >= 30000
- return static_cast<XMLSize_t> (is_.gcount ());
-#else
- return static_cast<unsigned int> (is_.gcount ());
-#endif
- }
- else
- return 0;
+ return !is_.fail ()
+ ? static_cast<XMLSize_t> (is_.gcount ())
+ : 0;
}
-#if _XERCES_VERSION >= 30000
virtual const XMLCh*
getContentType () const
{
return 0;
}
-#endif
+
private:
std::istream& is_;
};
diff --git a/libxsd/xsd/cxx/xml/std-memory-manager.hxx b/libxsd/xsd/cxx/xml/std-memory-manager.hxx
index 7598e22..bd8fbab 100644
--- a/libxsd/xsd/cxx/xml/std-memory-manager.hxx
+++ b/libxsd/xsd/cxx/xml/std-memory-manager.hxx
@@ -19,11 +19,7 @@ namespace xsd
{
public:
virtual void*
-#if _XERCES_VERSION >= 30000
allocate(XMLSize_t size)
-#else
- allocate(size_t size)
-#endif
{
return operator new (size);
}
@@ -35,13 +31,11 @@ namespace xsd
operator delete (p);
}
-#if _XERCES_VERSION >= 30000
virtual xercesc::MemoryManager*
getExceptionMemoryManager()
{
return xercesc::XMLPlatformUtils::fgMemoryManager;
}
-#endif
};
}
}