remove xcerces2
This commit is contained in:
@@ -50,41 +50,6 @@ StdInputStream::~StdInputStream() = default;
|
||||
// ---------------------------------------------------------------------------
|
||||
// StdInputStream: Implementation of the input stream interface
|
||||
// ---------------------------------------------------------------------------
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
unsigned int StdInputStream::curPos() const
|
||||
{
|
||||
return stream.tellg();
|
||||
}
|
||||
|
||||
unsigned int StdInputStream::readBytes( XMLByte* const toFill, const unsigned int maxToRead )
|
||||
{
|
||||
//
|
||||
// Read up to the maximum bytes requested. We return the number
|
||||
// actually read.
|
||||
//
|
||||
|
||||
stream.read((char *)toFill,maxToRead);
|
||||
XMLSize_t len = stream.gcount();
|
||||
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
const QString text = codec->toUnicode((char *)toFill, len, &state);
|
||||
if (state.invalidChars > 0) {
|
||||
// In case invalid characters were found decode back to 'utf-8' and replace
|
||||
// them with '?'
|
||||
// First, Qt replaces invalid characters with '\0' (see ConvertInvalidToNull)
|
||||
// but Xerces doesn't like this because it handles this as termination. Thus,
|
||||
// we have to go through the array and replace '\0' with '?'.
|
||||
XMLSize_t pos = 0;
|
||||
QByteArray ba = codec->fromUnicode(text);
|
||||
for (int i=0; i<ba.length(); i++, pos++) {
|
||||
if (pos < len && ba[i] == '\0')
|
||||
toFill[i] = '?';
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
#else
|
||||
XMLFilePos StdInputStream::curPos() const
|
||||
{
|
||||
return static_cast<XMLFilePos>(stream.tellg());
|
||||
@@ -118,7 +83,6 @@ XMLSize_t StdInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxT
|
||||
|
||||
return static_cast<XMLSize_t>(len);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -50,14 +50,9 @@ public :
|
||||
// -----------------------------------------------------------------------
|
||||
// Implementation of the input stream interface
|
||||
// -----------------------------------------------------------------------
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
virtual unsigned int curPos() const;
|
||||
virtual unsigned int readBytes( XMLByte* const toFill, const unsigned int maxToRead );
|
||||
#else
|
||||
XMLFilePos curPos() const override;
|
||||
XMLSize_t readBytes( XMLByte* const toFill, const XMLSize_t maxToRead ) override;
|
||||
const XMLCh* getContentType() const override {return nullptr;}
|
||||
#endif
|
||||
|
||||
private :
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
# include <cassert>
|
||||
# include <memory>
|
||||
# include <xercesc/dom/DOM.hpp>
|
||||
# if (XERCES_VERSION_MAJOR == 2)
|
||||
# include <xercesc/dom/DOMWriter.hpp>
|
||||
# endif
|
||||
# include <xercesc/framework/LocalFileFormatTarget.hpp>
|
||||
# include <xercesc/framework/LocalFileInputSource.hpp>
|
||||
# include <xercesc/framework/MemBufFormatTarget.hpp>
|
||||
@@ -112,40 +109,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
class DOMPrintFilter : public DOMWriterFilter
|
||||
{
|
||||
public:
|
||||
|
||||
/** @name Constructors */
|
||||
DOMPrintFilter(unsigned long whatToShow = DOMNodeFilter::SHOW_ALL);
|
||||
//@{
|
||||
|
||||
/** @name Destructors */
|
||||
~DOMPrintFilter() {};
|
||||
//@{
|
||||
|
||||
/** @ interface from DOMWriterFilter */
|
||||
virtual short acceptNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode*) const;
|
||||
//@{
|
||||
|
||||
virtual unsigned long getWhatToShow() const {
|
||||
return fWhatToShow;
|
||||
};
|
||||
|
||||
virtual void setWhatToShow(unsigned long toShow) {
|
||||
fWhatToShow = toShow;
|
||||
};
|
||||
|
||||
private:
|
||||
// unimplemented copy ctor and assignment operator
|
||||
DOMPrintFilter(const DOMPrintFilter&);
|
||||
DOMPrintFilter & operator = (const DOMPrintFilter&);
|
||||
|
||||
unsigned long fWhatToShow;
|
||||
|
||||
};
|
||||
#else
|
||||
class DOMPrintFilter : public DOMLSSerializerFilter
|
||||
{
|
||||
public:
|
||||
@@ -173,7 +136,6 @@ private:
|
||||
|
||||
ShowType fWhatToShow;
|
||||
};
|
||||
#endif
|
||||
class DOMPrintErrorHandler : public DOMErrorHandler
|
||||
{
|
||||
public:
|
||||
@@ -1370,74 +1332,6 @@ void ParameterManager::SaveDocument(const char* sFileName) const
|
||||
|
||||
void ParameterManager::SaveDocument(XMLFormatTarget* pFormatTarget) const
|
||||
{
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
DOMPrintFilter *myFilter = 0;
|
||||
|
||||
try {
|
||||
// get a serializer, an instance of DOMWriter
|
||||
XMLCh tempStr[100];
|
||||
XMLString::transcode("LS", tempStr, 99);
|
||||
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
|
||||
DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
|
||||
|
||||
// set user specified end of line sequence and output encoding
|
||||
theSerializer->setNewLine(gMyEOLSequence);
|
||||
theSerializer->setEncoding(gOutputEncoding);
|
||||
|
||||
// plug in user's own filter
|
||||
if (gUseFilter) {
|
||||
// even we say to show attribute, but the DOMWriter
|
||||
// will not show attribute nodes to the filter as
|
||||
// the specs explicitly says that DOMWriter shall
|
||||
// NOT show attributes to DOMWriterFilter.
|
||||
//
|
||||
// so DOMNodeFilter::SHOW_ATTRIBUTE has no effect.
|
||||
// same DOMNodeFilter::SHOW_DOCUMENT_TYPE, no effect.
|
||||
//
|
||||
myFilter = new DOMPrintFilter(DOMNodeFilter::SHOW_ELEMENT |
|
||||
DOMNodeFilter::SHOW_ATTRIBUTE |
|
||||
DOMNodeFilter::SHOW_DOCUMENT_TYPE
|
||||
);
|
||||
theSerializer->setFilter(myFilter);
|
||||
}
|
||||
|
||||
// plug in user's own error handler
|
||||
DOMErrorHandler *myErrorHandler = new DOMPrintErrorHandler();
|
||||
theSerializer->setErrorHandler(myErrorHandler);
|
||||
|
||||
// set feature if the serializer supports the feature/mode
|
||||
if (theSerializer->canSetFeature(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections))
|
||||
theSerializer->setFeature(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections);
|
||||
|
||||
if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent))
|
||||
theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent);
|
||||
|
||||
if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint))
|
||||
theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint);
|
||||
|
||||
//
|
||||
// do the serialization through DOMWriter::writeNode();
|
||||
//
|
||||
theSerializer->writeNode(pFormatTarget, *_pDocument);
|
||||
|
||||
delete theSerializer;
|
||||
|
||||
//
|
||||
// Filter and error handler
|
||||
// are NOT owned by the serializer.
|
||||
//
|
||||
delete myErrorHandler;
|
||||
|
||||
if (gUseFilter)
|
||||
delete myFilter;
|
||||
|
||||
}
|
||||
catch (XMLException& e) {
|
||||
std::cerr << "An error occurred during creation of output transcoder. Msg is:"
|
||||
<< std::endl
|
||||
<< StrX(e.getMessage()) << std::endl;
|
||||
}
|
||||
#else
|
||||
try {
|
||||
std::unique_ptr<DOMPrintFilter> myFilter;
|
||||
std::unique_ptr<DOMErrorHandler> myErrorHandler;
|
||||
@@ -1495,7 +1389,6 @@ void ParameterManager::SaveDocument(XMLFormatTarget* pFormatTarget) const
|
||||
<< std::endl
|
||||
<< StrX(e.getMessage()) << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ParameterManager::CreateDocument()
|
||||
@@ -1613,81 +1506,6 @@ void DOMTreeErrorReporter::resetErrors()
|
||||
//**************************************************************************
|
||||
// DOMPrintFilter
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
DOMPrintFilter::DOMPrintFilter(unsigned long whatToShow)
|
||||
:fWhatToShow(whatToShow)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
short DOMPrintFilter::acceptNode(const DOMNode* node) const
|
||||
{
|
||||
//
|
||||
// The DOMWriter shall call getWhatToShow() before calling
|
||||
// acceptNode(), to show nodes which are supposed to be
|
||||
// shown to this filter.
|
||||
// TODO:
|
||||
// REVISIT: In case the DOMWriter does not follow the protocol,
|
||||
// Shall the filter honor, or NOT, what it claims
|
||||
// (when it is constructed/setWhatToShow())
|
||||
// it is interested in ?
|
||||
//
|
||||
// The DOMLS specs does not specify that acceptNode() shall do
|
||||
// this way, or not, so it is up the implementation,
|
||||
// to skip the code below for the sake of performance ...
|
||||
//
|
||||
if ((getWhatToShow() & (1 << (node->getNodeType() - 1))) == 0)
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
|
||||
switch (node->getNodeType()) {
|
||||
case DOMNode::ELEMENT_NODE: {
|
||||
// for element whose name is "person", skip it
|
||||
//if (XMLString::compareString(node->getNodeName(), element_person)==0)
|
||||
// return DOMNodeFilter::FILTER_SKIP;
|
||||
// for element whose name is "line", reject it
|
||||
//if (XMLString::compareString(node->getNodeName(), element_link)==0)
|
||||
// return DOMNodeFilter::FILTER_REJECT;
|
||||
// for rest, accept it
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
|
||||
break;
|
||||
}
|
||||
case DOMNode::COMMENT_NODE: {
|
||||
// the WhatToShow will make this no effect
|
||||
//return DOMNodeFilter::FILTER_REJECT;
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
break;
|
||||
}
|
||||
case DOMNode::TEXT_NODE: {
|
||||
// the WhatToShow will make this no effect
|
||||
//return DOMNodeFilter::FILTER_REJECT;
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
break;
|
||||
}
|
||||
case DOMNode::DOCUMENT_TYPE_NODE: {
|
||||
// even we say we are going to process document type,
|
||||
// we are not able be to see this node since
|
||||
// DOMWriterImpl (a XercesC's default implementation
|
||||
// of DOMWriter) will not pass DocumentType node to
|
||||
// this filter.
|
||||
//
|
||||
return DOMNodeFilter::FILTER_REJECT; // no effect
|
||||
break;
|
||||
}
|
||||
case DOMNode::DOCUMENT_NODE: {
|
||||
// same as DOCUMENT_NODE
|
||||
return DOMNodeFilter::FILTER_REJECT; // no effect
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
}
|
||||
#else
|
||||
DOMPrintFilter::DOMPrintFilter(ShowType whatToShow)
|
||||
: fWhatToShow(whatToShow)
|
||||
{
|
||||
@@ -1737,7 +1555,6 @@ DOMPrintFilter::FilterAction DOMPrintFilter::acceptNode(const DOMNode* node) con
|
||||
|
||||
return DOMNodeFilter::FILTER_ACCEPT;
|
||||
}
|
||||
#endif
|
||||
|
||||
//**************************************************************************
|
||||
//**************************************************************************
|
||||
|
||||
@@ -85,9 +85,6 @@
|
||||
#include <xercesc/dom/DOM.hpp>
|
||||
#include <xercesc/dom/DOMImplementation.hpp>
|
||||
#include <xercesc/dom/DOMImplementationLS.hpp>
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
#include <xercesc/dom/DOMWriter.hpp>
|
||||
#endif
|
||||
#include <xercesc/dom/DOMDocument.hpp>
|
||||
#include <xercesc/dom/DOMElement.hpp>
|
||||
#include <xercesc/dom/DOMText.hpp>
|
||||
|
||||
@@ -451,22 +451,14 @@ void Base::XMLReader::endCDATA ()
|
||||
ReadType = EndCDATA;
|
||||
}
|
||||
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
void Base::XMLReader::characters(const XMLCh* const chars, const unsigned int length)
|
||||
#else
|
||||
void Base::XMLReader::characters(const XMLCh* const chars, const XMLSize_t length)
|
||||
#endif
|
||||
{
|
||||
Characters = StrX(chars).c_str();
|
||||
ReadType = Chars;
|
||||
CharacterCount += length;
|
||||
}
|
||||
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
void Base::XMLReader::ignorableWhitespace( const XMLCh* const /*chars*/, const unsigned int /*length*/)
|
||||
#else
|
||||
void Base::XMLReader::ignorableWhitespace( const XMLCh* const /*chars*/, const XMLSize_t /*length*/)
|
||||
#endif
|
||||
{
|
||||
//fSpaceCount += length;
|
||||
}
|
||||
|
||||
@@ -227,13 +227,8 @@ protected:
|
||||
void endDocument() override;
|
||||
void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const XERCES_CPP_NAMESPACE_QUALIFIER Attributes& attrs) override;
|
||||
void endElement (const XMLCh* const uri, const XMLCh *const localname, const XMLCh *const qname) override;
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
virtual void characters (const XMLCh* const chars, const unsigned int length);
|
||||
virtual void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
|
||||
#else
|
||||
void characters (const XMLCh* const chars, const XMLSize_t length) override;
|
||||
void ignorableWhitespace(const XMLCh* const chars, const XMLSize_t length) override;
|
||||
#endif
|
||||
//@}
|
||||
|
||||
/** @name Lexical handler */
|
||||
|
||||
@@ -49,17 +49,10 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode)
|
||||
|
||||
//char outBuff[128];
|
||||
static XMLByte outBuff[128];
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
unsigned int outputLength;
|
||||
unsigned int eaten = 0;
|
||||
unsigned int offset = 0;
|
||||
unsigned int inputLength = XMLString::stringLen(toTranscode);
|
||||
#else
|
||||
XMLSize_t outputLength;
|
||||
XMLSize_t eaten = 0;
|
||||
XMLSize_t offset = 0;
|
||||
XMLSize_t inputLength = XMLString::stringLen(toTranscode);
|
||||
#endif
|
||||
|
||||
while (inputLength)
|
||||
{
|
||||
@@ -87,17 +80,10 @@ std::basic_string<XMLCh> XMLTools::toXMLString(const char* const fromTranscode)
|
||||
|
||||
static XMLCh outBuff[128];
|
||||
const XMLByte* xmlBytes = reinterpret_cast<const XMLByte*>(fromTranscode);
|
||||
#if (XERCES_VERSION_MAJOR == 2)
|
||||
unsigned int outputLength;
|
||||
unsigned int eaten = 0;
|
||||
unsigned int offset = 0;
|
||||
unsigned int inputLength = std::string(fromTranscode).size();
|
||||
#else
|
||||
XMLSize_t outputLength;
|
||||
XMLSize_t eaten = 0;
|
||||
XMLSize_t offset = 0;
|
||||
XMLSize_t inputLength = std::string(fromTranscode).size();
|
||||
#endif
|
||||
|
||||
unsigned char* charSizes = new unsigned char[inputLength];
|
||||
while (inputLength)
|
||||
|
||||
Reference in New Issue
Block a user