summaryrefslogtreecommitdiffstats
path: root/src/xml/dom
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-07 14:01:20 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-15 08:12:20 +0200
commit79e0374143ab385cb12a17443e91c8eb9d2f3a4b (patch)
tree821f3b5d1111b4f6b2de72e6f94995c67d0635d0 /src/xml/dom
parent0aaebc3378c9264e5b5ac0facbd0d8961fd57a9f (diff)
Remove the SAX parser from QtXml
It has been deprecated and will live in qt5compat from now on. Fixes: QTBUG-86480 Change-Id: I3744c7cee058d51d0fce633a174ab1a0f9235d2c Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Diffstat (limited to 'src/xml/dom')
-rw-r--r--src/xml/dom/qdom.cpp111
-rw-r--r--src/xml/dom/qdom_p.h10
-rw-r--r--src/xml/dom/qdomhelpers.cpp194
-rw-r--r--src/xml/dom/qdomhelpers_p.h92
4 files changed, 2 insertions, 405 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 0856a83a52..571e7fb0ac 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -53,7 +53,6 @@
#include <qregularexpression.h>
#endif
#include <qtextstream.h>
-#include <qxml.h>
#include <qvariant.h>
#include <qshareddata.h>
#include <qdebug.h>
@@ -5683,57 +5682,6 @@ void QDomDocumentPrivate::clear()
QDomNodePrivate::clear();
}
-#if QT_DEPRECATED_SINCE(5, 15)
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing)
-{
- reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing);
- reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), !namespaceProcessing);
- reader.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), false); // Shouldn't change in Qt 4
-}
-
-bool QDomDocumentPrivate::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
-{
- QXmlSimpleReader reader;
- initializeReader(reader, namespaceProcessing);
- return setContent(source, &reader, &reader, errorMsg, errorLine, errorColumn);
-}
-
-bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader, QString *errorMsg, int *errorLine, int *errorColumn)
-{
- clear();
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
- type->ref.deref();
-
- bool namespaceProcessing = reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))
- && !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"));
-
- QDomHandler hnd(this, simpleReader, namespaceProcessing);
- reader->setContentHandler(&hnd);
- reader->setErrorHandler(&hnd);
- reader->setLexicalHandler(&hnd);
- reader->setDeclHandler(&hnd);
- reader->setDTDHandler(&hnd);
-
- if (!reader->parse(source)) {
- if (errorMsg)
- *errorMsg = std::get<0>(hnd.errorInfo());
- if (errorLine)
- *errorLine = std::get<1>(hnd.errorInfo());
- if (errorColumn)
- *errorColumn = std::get<2>(hnd.errorInfo());
- return false;
- }
-
- return true;
-}
-QT_WARNING_POP
-
-#endif // QT_DEPRECATED_SINCE(5, 15)
-
bool QDomDocumentPrivate::setContent(QXmlStreamReader *reader, bool namespaceProcessing,
QString *errorMsg, int *errorLine, int *errorColumn)
{
@@ -6273,43 +6221,11 @@ bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString
if (!impl)
impl = new QDomDocumentPrivate();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- QXmlInputSource source(dev);
-QT_WARNING_POP
- return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);
-#else
QXmlStreamReader streamReader(dev);
streamReader.setNamespaceProcessing(namespaceProcessing);
return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn);
-#endif
}
-#if QT_DEPRECATED_SINCE(5, 15)
-/*!
- \overload
- \obsolete
- \since 4.5
-
- This function reads the XML document from the QXmlInputSource \a source,
- returning true if the content was successfully parsed; otherwise returns \c false.
-
-*/
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn )
-{
- if (!impl)
- impl = new QDomDocumentPrivate();
- QXmlSimpleReader reader;
- initializeReader(reader, namespaceProcessing);
- return IMPL->setContent(source, &reader, &reader, errorMsg, errorLine, errorColumn);
-}
-QT_WARNING_POP
-
-#endif
-
/*!
\overload
@@ -6353,33 +6269,6 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine,
return setContent(dev, false, errorMsg, errorLine, errorColumn);
}
-#if QT_DEPRECATED_SINCE(5, 15)
-/*!
- \overload
- \obsolete
-
- This function reads the XML document from the QXmlInputSource \a source and
- parses it with the QXmlReader \a reader, returning true if the content was
- successfully parsed; otherwise returns \c false.
-
- This function doesn't change the features of the \a reader. If you want to
- use certain features for parsing you can use this function to set up the
- reader appropriately.
-
- \sa QXmlSimpleReader
-*/
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn )
-{
- if (!impl)
- impl = new QDomDocumentPrivate();
- return IMPL->setContent(source, reader, nullptr, errorMsg, errorLine, errorColumn);
-}
-QT_WARNING_POP
-
-#endif
-
/*!
\overload
\since 5.15
diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h
index 8ab81aa083..82c533b141 100644
--- a/src/xml/dom/qdom_p.h
+++ b/src/xml/dom/qdom_p.h
@@ -45,7 +45,6 @@
#include <qhash.h>
#include <qstring.h>
#include <qlist.h>
-#include <qxml.h>
#include <qshareddata.h>
QT_BEGIN_NAMESPACE
@@ -462,15 +461,6 @@ public:
QDomDocumentPrivate(QDomDocumentPrivate *n, bool deep);
~QDomDocumentPrivate();
-#if QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg,
- int *errorLine, int *errorColumn);
- bool setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader,
- QString *errorMsg, int *errorLine, int *errorColumn);
-QT_WARNING_POP
-#endif
bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg,
int *errorLine, int *errorColumn);
diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp
index 69fb99715d..75d4c2c2b7 100644
--- a/src/xml/dom/qdomhelpers.cpp
+++ b/src/xml/dom/qdomhelpers.cpp
@@ -44,132 +44,10 @@
#include "qdomhelpers_p.h"
#include "qdom_p.h"
#include "qxmlstream.h"
-#include "private/qxml_p.h"
-QT_BEGIN_NAMESPACE
-
-#if QT_DEPRECATED_SINCE(5, 15)
-
-/**************************************************************
- *
- * QDomHandler
- *
- **************************************************************/
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-QDomHandler::QDomHandler(QDomDocumentPrivate *adoc, QXmlSimpleReader *areader,
- bool namespaceProcessing)
- : cdata(false), reader(areader), domBuilder(adoc, &locator, namespaceProcessing)
-{
-}
-
-QDomHandler::~QDomHandler() {}
-
-bool QDomHandler::endDocument()
-{
- return domBuilder.endDocument();
-}
-
-bool QDomHandler::startDTD(const QString &name, const QString &publicId, const QString &systemId)
-{
- return domBuilder.startDTD(name, publicId, systemId);
-}
-
-bool QDomHandler::startElement(const QString &nsURI, const QString &, const QString &qName,
- const QXmlAttributes &atts)
-{
- return domBuilder.startElement(nsURI, qName, atts);
-}
-
-bool QDomHandler::endElement(const QString &, const QString &, const QString &)
-{
- return domBuilder.endElement();
-}
-
-bool QDomHandler::characters(const QString &ch)
-{
- return domBuilder.characters(ch, cdata);
-}
-
-bool QDomHandler::processingInstruction(const QString &target, const QString &data)
-{
- return domBuilder.processingInstruction(target, data);
-}
-
-bool QDomHandler::skippedEntity(const QString &name)
-{
- // we can only handle inserting entity references into content
- if (reader && !reader->d_ptr->skipped_entity_in_content)
- return true;
-
- return domBuilder.skippedEntity(name);
-}
-
-bool QDomHandler::fatalError(const QXmlParseException &exception)
-{
- domBuilder.errorMsg = exception.message();
- domBuilder.errorLine = exception.lineNumber();
- domBuilder.errorColumn = exception.columnNumber();
- return QXmlDefaultHandler::fatalError(exception);
-}
-
-bool QDomHandler::startCDATA()
-{
- cdata = true;
- return true;
-}
-
-bool QDomHandler::endCDATA()
-{
- cdata = false;
- return true;
-}
-
-bool QDomHandler::startEntity(const QString &name)
-{
- return domBuilder.startEntity(name);
-}
-
-bool QDomHandler::endEntity(const QString &)
-{
- return domBuilder.endEntity();
-}
-
-bool QDomHandler::comment(const QString &ch)
-{
- return domBuilder.comment(ch);
-}
-
-bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId,
- const QString &systemId, const QString &notationName)
-{
- return domBuilder.unparsedEntityDecl(name, publicId, systemId, notationName);
-}
-
-bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicId,
- const QString &systemId)
-{
- return unparsedEntityDecl(name, publicId, systemId, QString());
-}
-
-bool QDomHandler::notationDecl(const QString &name, const QString &publicId,
- const QString &systemId)
-{
- return domBuilder.notationDecl(name, publicId, systemId);
-}
-
-void QDomHandler::setDocumentLocator(QXmlLocator *locator)
-{
- this->locator.setLocator(locator);
-}
-
-QDomBuilder::ErrorInfo QDomHandler::errorInfo() const
-{
- return domBuilder.error();
-}
-QT_WARNING_POP
+#include <stack>
-#endif // QT_DEPRECATED_SINCE(5, 15)
+QT_BEGIN_NAMESPACE
/**************************************************************
*
@@ -189,36 +67,6 @@ int QDomDocumentLocator::line() const
return static_cast<int>(reader->lineNumber());
}
-#if QT_DEPRECATED_SINCE(5, 15)
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-void QSAXDocumentLocator::setLocator(QXmlLocator *l)
-{
- locator = l;
-}
-
-int QSAXDocumentLocator::column() const
-{
- if (!locator)
- return 0;
-
- return static_cast<int>(locator->columnNumber());
-}
-
-int QSAXDocumentLocator::line() const
-{
- if (!locator)
- return 0;
-
- return static_cast<int>(locator->lineNumber());
-}
-
-QT_WARNING_POP
-
-#endif // QT_DEPRECATED_SINCE(5, 15)
-
/**************************************************************
*
* QDomBuilder
@@ -253,44 +101,6 @@ bool QDomBuilder::startDTD(const QString &name, const QString &publicId, const Q
return true;
}
-#if QT_DEPRECATED_SINCE(5, 15)
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
- const QXmlAttributes &atts)
-{
- // tag name
- QDomNodePrivate *n;
- if (nsProcessing) {
- n = doc->createElementNS(nsURI, qName);
- } else {
- n = doc->createElement(qName);
- }
-
- if (!n)
- return false;
-
- n->setLocation(locator->line(), locator->column());
-
- node->appendChild(n);
- node = n;
-
- // attributes
- for (int i = 0; i < atts.length(); i++) {
- auto domElement = static_cast<QDomElementPrivate *>(node);
- if (nsProcessing)
- domElement->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i));
- else
- domElement->setAttribute(atts.qName(i), atts.value(i));
- }
-
- return true;
-}
-QT_WARNING_POP
-
-#endif // QT_DEPRECATED_SINCE(5, 15)
-
bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
const QXmlStreamAttributes &atts)
{
diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h
index 4de18f7d4d..f7264daf4b 100644
--- a/src/xml/dom/qdomhelpers_p.h
+++ b/src/xml/dom/qdomhelpers_p.h
@@ -41,7 +41,6 @@
#include <qcoreapplication.h>
#include <qglobal.h>
-#include <qxml.h>
QT_BEGIN_NAMESPACE
@@ -93,29 +92,6 @@ private:
QXmlStreamReader *reader;
};
-#if QT_DEPRECATED_SINCE(5, 15)
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-class QSAXDocumentLocator : public QXmlDocumentLocator
-{
-public:
- ~QSAXDocumentLocator() override = default;
-
- int column() const override;
- int line() const override;
-
- void setLocator(QXmlLocator *l);
-
-private:
- QXmlLocator *locator = nullptr;
-};
-
-QT_WARNING_POP
-
-#endif
-
/**************************************************************
*
* QDomBuilder
@@ -129,12 +105,6 @@ public:
~QDomBuilder();
bool endDocument();
-#if QT_DEPRECATED_SINCE(5, 15)
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- bool startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts);
-QT_WARNING_POP
-#endif
bool startElement(const QString &nsURI, const QString &qName, const QXmlStreamAttributes &atts);
bool endElement();
bool characters(const QString &characters, bool cdata = false);
@@ -166,68 +136,6 @@ private:
bool nsProcessing;
};
-#if QT_DEPRECATED_SINCE(5, 15)
-
-/**************************************************************
- *
- * QDomHandler
- *
- **************************************************************/
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-class QDomHandler : public QXmlDefaultHandler
-{
-public:
- QDomHandler(QDomDocumentPrivate *d, QXmlSimpleReader *reader, bool namespaceProcessing);
- ~QDomHandler() override;
-
- // content handler
- bool endDocument() override;
- bool startElement(const QString &nsURI, const QString &localName, const QString &qName,
- const QXmlAttributes &atts) override;
- bool endElement(const QString &nsURI, const QString &localName, const QString &qName) override;
- bool characters(const QString &ch) override;
- bool processingInstruction(const QString &target, const QString &data) override;
- bool skippedEntity(const QString &name) override;
-
- // error handler
- bool fatalError(const QXmlParseException &exception) override;
-
- // lexical handler
- bool startCDATA() override;
- bool endCDATA() override;
- bool startEntity(const QString &) override;
- bool endEntity(const QString &) override;
- bool startDTD(const QString &name, const QString &publicId, const QString &systemId) override;
- bool comment(const QString &ch) override;
-
- // decl handler
- bool externalEntityDecl(const QString &name, const QString &publicId,
- const QString &systemId) override;
-
- // DTD handler
- bool notationDecl(const QString &name, const QString &publicId,
- const QString &systemId) override;
- bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId,
- const QString &notationName) override;
-
- void setDocumentLocator(QXmlLocator *locator) override;
-
- QDomBuilder::ErrorInfo errorInfo() const;
-
-private:
- bool cdata;
- QXmlSimpleReader *reader;
- QSAXDocumentLocator locator;
- QDomBuilder domBuilder;
-};
-
-QT_WARNING_POP
-
-#endif // QT_DEPRECATED_SINCE(5, 15)
-
/**************************************************************
*
* QDomParser