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>bb10
parent
0aaebc3378
commit
79e0374143
|
|
@ -127,7 +127,6 @@ qt_extend_target(Bootstrap
|
|||
../../corelib/tools/qsize.cpp
|
||||
../../corelib/tools/qversionnumber.cpp
|
||||
../../xml/dom/qdom.cpp
|
||||
../../xml/sax/qxml.cpp
|
||||
DEFINES
|
||||
HAVE_CONFIG_H
|
||||
PCRE2_CODE_UNIT_WIDTH=16
|
||||
|
|
|
|||
|
|
@ -112,8 +112,7 @@ SOURCES += \
|
|||
../../corelib/tools/qsize.cpp \
|
||||
../../corelib/tools/qline.cpp \
|
||||
../../corelib/tools/qversionnumber.cpp \
|
||||
../../xml/dom/qdom.cpp \
|
||||
../../xml/sax/qxml.cpp
|
||||
../../xml/dom/qdom.cpp
|
||||
|
||||
unix:SOURCES += ../../corelib/kernel/qcore_unix.cpp \
|
||||
../../corelib/kernel/qsharedmemory_posix.cpp \
|
||||
|
|
|
|||
|
|
@ -313,20 +313,6 @@ QT_CLASS_LIB(QDomNotation, QtXml, qdom.h)
|
|||
QT_CLASS_LIB(QDomEntity, QtXml, qdom.h)
|
||||
QT_CLASS_LIB(QDomEntityReference, QtXml, qdom.h)
|
||||
QT_CLASS_LIB(QDomProcessingInstruction, QtXml, qdom.h)
|
||||
QT_CLASS_LIB(QXmlNamespaceSupport, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlAttributes, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlInputSource, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlParseException, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlReader, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlSimpleReader, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlLocator, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlContentHandler, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlErrorHandler, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlDTDHandler, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlEntityResolver, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlLexicalHandler, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlDeclHandler, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlDefaultHandler, QtXml, qxml.h)
|
||||
QT_CLASS_LIB(QXmlStreamAttribute, QtXml, qxmlstream.h)
|
||||
QT_CLASS_LIB(QXmlStreamAttributes, QtXml, qxmlstream.h)
|
||||
QT_CLASS_LIB(QXmlStreamEntityDeclaration, QtXml, qxmlstream.h)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ qt_add_module(Xml
|
|||
dom/qdom.cpp dom/qdom.h dom/qdom_p.h
|
||||
dom/qdomhelpers.cpp dom/qdomhelpers_p.h
|
||||
qtxmlglobal.h
|
||||
sax/qxml.cpp sax/qxml.h sax/qxml_p.h
|
||||
DEFINES
|
||||
QT_NO_FOREACH
|
||||
QT_NO_USING_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the documentation of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** BSD License Usage
|
||||
** Alternatively, you may use this file under the terms of the BSD license
|
||||
** as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||
** contributors may be used to endorse or promote products derived
|
||||
** from this software without specific prior written permission.
|
||||
**
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qfile.h>
|
||||
#include <qxml.h>
|
||||
#include "handler.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
QFile *file = new QFile(argv[1]);
|
||||
|
||||
//! [0]
|
||||
QXmlSimpleReader xmlReader;
|
||||
QXmlInputSource *source = new QXmlInputSource(file);
|
||||
//! [0]
|
||||
|
||||
//! [1]
|
||||
Handler *handler = new Handler;
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.setErrorHandler(handler);
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
bool ok = xmlReader.parse(source);
|
||||
|
||||
if (!ok)
|
||||
std::cout << "Parsing failed." << std::endl;
|
||||
//! [2]
|
||||
else {
|
||||
QStringList names = handler->names();
|
||||
QList<int> indentations = handler->indentations();
|
||||
|
||||
int items = names.count();
|
||||
|
||||
for (int i = 0; i < items; ++i) {
|
||||
for (int j = 0; j < indentations[i]; ++j)
|
||||
std::cout << ' ';
|
||||
std::cout << names[i].toLocal8Bit().constData() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,133 +44,11 @@
|
|||
#include "qdomhelpers_p.h"
|
||||
#include "qdom_p.h"
|
||||
#include "qxmlstream.h"
|
||||
#include "private/qxml_p.h"
|
||||
|
||||
#include <stack>
|
||||
|
||||
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 ¬ationName)
|
||||
{
|
||||
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
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* QXmlDocumentLocators
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 ¬ationName) 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
|
||||
|
|
|
|||
7999
src/xml/sax/qxml.cpp
7999
src/xml/sax/qxml.cpp
File diff suppressed because it is too large
Load Diff
|
|
@ -1,469 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtXml module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QXML_H
|
||||
#define QXML_H
|
||||
|
||||
#if 0
|
||||
// This is needed because of QTBUG-80347
|
||||
#pragma qt_class(QXmlNamespaceSupport)
|
||||
#pragma qt_class(QXmlAttributes)
|
||||
#pragma qt_class(QXmlInputSource)
|
||||
#pragma qt_class(QXmlParseException)
|
||||
#pragma qt_class(QXmlReader)
|
||||
#pragma qt_class(QXmlSimpleReader)
|
||||
#pragma qt_class(QXmlLocator)
|
||||
#pragma qt_class(QXmlContentHandler)
|
||||
#pragma qt_class(QXmlErrorHandler)
|
||||
#pragma qt_class(QXmlDTDHandler)
|
||||
#pragma qt_class(QXmlEntityResolver)
|
||||
#pragma qt_class(QXmlLexicalHandler)
|
||||
#pragma qt_class(QXmlDeclHandler)
|
||||
#pragma qt_class(QXmlDefaultHandler)
|
||||
#endif
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <QtXml/qtxmlglobal.h>
|
||||
#include <QtCore/qtextstream.h>
|
||||
#include <QtCore/qfile.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
|
||||
class QXmlNamespaceSupport;
|
||||
class QXmlAttributes;
|
||||
class QXmlContentHandler;
|
||||
class QXmlDefaultHandler;
|
||||
class QXmlDTDHandler;
|
||||
class QXmlEntityResolver;
|
||||
class QXmlErrorHandler;
|
||||
class QXmlLexicalHandler;
|
||||
class QXmlDeclHandler;
|
||||
class QXmlInputSource;
|
||||
class QXmlLocator;
|
||||
class QXmlNamespaceSupport;
|
||||
class QXmlParseException;
|
||||
|
||||
class QXmlReader;
|
||||
class QXmlSimpleReader;
|
||||
|
||||
class QXmlSimpleReaderPrivate;
|
||||
class QXmlNamespaceSupportPrivate;
|
||||
class QXmlAttributesPrivate;
|
||||
class QXmlInputSourcePrivate;
|
||||
class QXmlParseExceptionPrivate;
|
||||
class QXmlLocatorPrivate;
|
||||
class QXmlDefaultHandlerPrivate;
|
||||
|
||||
//
|
||||
// SAX Namespace Support
|
||||
//
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlNamespaceSupport
|
||||
{
|
||||
public:
|
||||
QXmlNamespaceSupport();
|
||||
~QXmlNamespaceSupport();
|
||||
|
||||
void setPrefix(const QString&, const QString&);
|
||||
|
||||
QString prefix(const QString&) const;
|
||||
QString uri(const QString&) const;
|
||||
void splitName(const QString&, QString&, QString&) const;
|
||||
void processName(const QString&, bool, QString&, QString&) const;
|
||||
QStringList prefixes() const;
|
||||
QStringList prefixes(const QString&) const;
|
||||
|
||||
void pushContext();
|
||||
void popContext();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
QXmlNamespaceSupportPrivate *d;
|
||||
|
||||
friend class QXmlSimpleReaderPrivate;
|
||||
Q_DISABLE_COPY(QXmlNamespaceSupport)
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// SAX Attributes
|
||||
//
|
||||
|
||||
// Although deprecated warnings are disabled, the intel icc 18 compiler
|
||||
// still complains during the instantiation of the templated qSwap() call below
|
||||
// (with the parameter QXmlAttributes::AttributeList) when QXmlAttributes is
|
||||
// deprecated. This makes the build fail when warnings are treated as errors.
|
||||
// To workaround this, deprecated only the constructor.
|
||||
class Q_XML_EXPORT QXmlAttributes
|
||||
{
|
||||
public:
|
||||
QT_DEPRECATED_VERSION(5, 15) QXmlAttributes();
|
||||
QXmlAttributes(const QXmlAttributes &) = default;
|
||||
QXmlAttributes(QXmlAttributes &&) noexcept = default;
|
||||
QXmlAttributes &operator=(const QXmlAttributes &) = default;
|
||||
QXmlAttributes &operator=(QXmlAttributes &&) noexcept = default;
|
||||
|
||||
~QXmlAttributes();
|
||||
|
||||
void swap(QXmlAttributes &other) noexcept
|
||||
{
|
||||
qSwap(attList, other.attList);
|
||||
qSwap(d, other.d);
|
||||
}
|
||||
|
||||
int index(const QString& qName) const;
|
||||
int index(QLatin1String qName) const;
|
||||
int index(const QString& uri, const QString& localPart) const;
|
||||
int length() const;
|
||||
int count() const;
|
||||
QString localName(int index) const;
|
||||
QString qName(int index) const;
|
||||
QString uri(int index) const;
|
||||
QString type(int index) const;
|
||||
QString type(const QString& qName) const;
|
||||
QString type(const QString& uri, const QString& localName) const;
|
||||
QString value(int index) const;
|
||||
QString value(const QString& qName) const;
|
||||
QString value(QLatin1String qName) const;
|
||||
QString value(const QString& uri, const QString& localName) const;
|
||||
|
||||
void clear();
|
||||
void append(const QString &qName, const QString &uri, const QString &localPart, const QString &value);
|
||||
|
||||
private:
|
||||
struct Attribute {
|
||||
QString qname, uri, localname, value;
|
||||
};
|
||||
friend class QTypeInfo<Attribute>;
|
||||
typedef QList<Attribute> AttributeList;
|
||||
AttributeList attList;
|
||||
|
||||
QXmlAttributesPrivate *d;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(QXmlAttributes::Attribute, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_SHARED(QXmlAttributes)
|
||||
|
||||
//
|
||||
// SAX Input Source
|
||||
//
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlInputSource
|
||||
{
|
||||
public:
|
||||
QXmlInputSource();
|
||||
explicit QXmlInputSource(QIODevice *dev);
|
||||
virtual ~QXmlInputSource();
|
||||
|
||||
virtual void setData(const QString& dat);
|
||||
virtual void setData(const QByteArray& dat);
|
||||
virtual void fetchData();
|
||||
virtual QString data() const;
|
||||
virtual QChar next();
|
||||
virtual void reset();
|
||||
|
||||
static const char16_t EndOfData;
|
||||
static const char16_t EndOfDocument;
|
||||
|
||||
protected:
|
||||
virtual QString fromRawData(const QByteArray &data, bool beginning = false);
|
||||
|
||||
private:
|
||||
void init();
|
||||
QXmlInputSourcePrivate *d;
|
||||
};
|
||||
|
||||
//
|
||||
// SAX Exception Classes
|
||||
//
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlParseException
|
||||
{
|
||||
public:
|
||||
explicit QXmlParseException(const QString &name = QString(), int c = -1, int l = -1,
|
||||
const QString &p = QString(), const QString &s = QString());
|
||||
QXmlParseException(const QXmlParseException &other);
|
||||
~QXmlParseException();
|
||||
|
||||
int columnNumber() const;
|
||||
int lineNumber() const;
|
||||
QString publicId() const;
|
||||
QString systemId() const;
|
||||
QString message() const;
|
||||
|
||||
private:
|
||||
QScopedPointer<QXmlParseExceptionPrivate> d;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XML Reader
|
||||
//
|
||||
|
||||
class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlReader
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlReader() {}
|
||||
virtual bool feature(const QString& name, bool *ok = nullptr) const = 0;
|
||||
virtual void setFeature(const QString& name, bool value) = 0;
|
||||
virtual bool hasFeature(const QString& name) const = 0;
|
||||
virtual void* property(const QString& name, bool *ok = nullptr) const = 0;
|
||||
virtual void setProperty(const QString& name, void* value) = 0;
|
||||
virtual bool hasProperty(const QString& name) const = 0;
|
||||
virtual void setEntityResolver(QXmlEntityResolver* handler) = 0;
|
||||
virtual QXmlEntityResolver* entityResolver() const = 0;
|
||||
virtual void setDTDHandler(QXmlDTDHandler* handler) = 0;
|
||||
virtual QXmlDTDHandler* DTDHandler() const = 0;
|
||||
virtual void setContentHandler(QXmlContentHandler* handler) = 0;
|
||||
virtual QXmlContentHandler* contentHandler() const = 0;
|
||||
virtual void setErrorHandler(QXmlErrorHandler* handler) = 0;
|
||||
virtual QXmlErrorHandler* errorHandler() const = 0;
|
||||
virtual void setLexicalHandler(QXmlLexicalHandler* handler) = 0;
|
||||
virtual QXmlLexicalHandler* lexicalHandler() const = 0;
|
||||
virtual void setDeclHandler(QXmlDeclHandler* handler) = 0;
|
||||
virtual QXmlDeclHandler* declHandler() const = 0;
|
||||
virtual bool parse(const QXmlInputSource& input) = 0;
|
||||
virtual bool parse(const QXmlInputSource* input) = 0;
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlSimpleReader
|
||||
: public QXmlReader
|
||||
{
|
||||
public:
|
||||
QXmlSimpleReader();
|
||||
virtual ~QXmlSimpleReader();
|
||||
|
||||
bool feature(const QString& name, bool *ok = nullptr) const override;
|
||||
void setFeature(const QString& name, bool value) override;
|
||||
bool hasFeature(const QString& name) const override;
|
||||
|
||||
void* property(const QString& name, bool *ok = nullptr) const override;
|
||||
void setProperty(const QString& name, void* value) override;
|
||||
bool hasProperty(const QString& name) const override;
|
||||
|
||||
void setEntityResolver(QXmlEntityResolver* handler) override;
|
||||
QXmlEntityResolver* entityResolver() const override;
|
||||
void setDTDHandler(QXmlDTDHandler* handler) override;
|
||||
QXmlDTDHandler* DTDHandler() const override;
|
||||
void setContentHandler(QXmlContentHandler* handler) override;
|
||||
QXmlContentHandler* contentHandler() const override;
|
||||
void setErrorHandler(QXmlErrorHandler* handler) override;
|
||||
QXmlErrorHandler* errorHandler() const override;
|
||||
void setLexicalHandler(QXmlLexicalHandler* handler) override;
|
||||
QXmlLexicalHandler* lexicalHandler() const override;
|
||||
void setDeclHandler(QXmlDeclHandler* handler) override;
|
||||
QXmlDeclHandler* declHandler() const override;
|
||||
|
||||
bool parse(const QXmlInputSource& input) override;
|
||||
bool parse(const QXmlInputSource* input) override;
|
||||
virtual bool parse(const QXmlInputSource* input, bool incremental);
|
||||
virtual bool parseContinue();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QXmlSimpleReader)
|
||||
Q_DECLARE_PRIVATE(QXmlSimpleReader)
|
||||
QScopedPointer<QXmlSimpleReaderPrivate> d_ptr;
|
||||
|
||||
friend class QXmlSimpleReaderLocator;
|
||||
friend class QDomHandler;
|
||||
};
|
||||
|
||||
//
|
||||
// SAX Locator
|
||||
//
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLocator
|
||||
{
|
||||
public:
|
||||
QXmlLocator();
|
||||
virtual ~QXmlLocator();
|
||||
|
||||
virtual int columnNumber() const = 0;
|
||||
virtual int lineNumber() const = 0;
|
||||
// QString getPublicId() const
|
||||
// QString getSystemId() const
|
||||
};
|
||||
|
||||
//
|
||||
// SAX handler classes
|
||||
//
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlContentHandler
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlContentHandler() {}
|
||||
virtual void setDocumentLocator(QXmlLocator* locator) = 0;
|
||||
virtual bool startDocument() = 0;
|
||||
virtual bool endDocument() = 0;
|
||||
virtual bool startPrefixMapping(const QString& prefix, const QString& uri) = 0;
|
||||
virtual bool endPrefixMapping(const QString& prefix) = 0;
|
||||
virtual bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) = 0;
|
||||
virtual bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName) = 0;
|
||||
virtual bool characters(const QString& ch) = 0;
|
||||
virtual bool ignorableWhitespace(const QString& ch) = 0;
|
||||
virtual bool processingInstruction(const QString& target, const QString& data) = 0;
|
||||
virtual bool skippedEntity(const QString& name) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlErrorHandler
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlErrorHandler() {}
|
||||
virtual bool warning(const QXmlParseException& exception) = 0;
|
||||
virtual bool error(const QXmlParseException& exception) = 0;
|
||||
virtual bool fatalError(const QXmlParseException& exception) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDTDHandler
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlDTDHandler() {}
|
||||
virtual bool notationDecl(const QString& name, const QString& publicId, const QString& systemId) = 0;
|
||||
virtual bool unparsedEntityDecl(const QString& name, const QString& publicId, const QString& systemId, const QString& notationName) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlEntityResolver
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlEntityResolver() {}
|
||||
virtual bool resolveEntity(const QString& publicId, const QString& systemId, QXmlInputSource*& ret) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLexicalHandler
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlLexicalHandler() {}
|
||||
virtual bool startDTD(const QString& name, const QString& publicId, const QString& systemId) = 0;
|
||||
virtual bool endDTD() = 0;
|
||||
virtual bool startEntity(const QString& name) = 0;
|
||||
virtual bool endEntity(const QString& name) = 0;
|
||||
virtual bool startCDATA() = 0;
|
||||
virtual bool endCDATA() = 0;
|
||||
virtual bool comment(const QString& ch) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDeclHandler
|
||||
{
|
||||
public:
|
||||
virtual ~QXmlDeclHandler() {}
|
||||
virtual bool attributeDecl(const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value) = 0;
|
||||
virtual bool internalEntityDecl(const QString& name, const QString& value) = 0;
|
||||
virtual bool externalEntityDecl(const QString& name, const QString& publicId, const QString& systemId) = 0;
|
||||
virtual QString errorString() const = 0;
|
||||
// ### Conform to SAX by adding elementDecl
|
||||
};
|
||||
|
||||
class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler,
|
||||
public QXmlErrorHandler,
|
||||
public QXmlDTDHandler,
|
||||
public QXmlEntityResolver,
|
||||
public QXmlLexicalHandler,
|
||||
public QXmlDeclHandler
|
||||
{
|
||||
public:
|
||||
QXmlDefaultHandler();
|
||||
virtual ~QXmlDefaultHandler();
|
||||
|
||||
void setDocumentLocator(QXmlLocator* locator) override;
|
||||
bool startDocument() override;
|
||||
bool endDocument() override;
|
||||
bool startPrefixMapping(const QString& prefix, const QString& uri) override;
|
||||
bool endPrefixMapping(const QString& prefix) override;
|
||||
bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) override;
|
||||
bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName) override;
|
||||
bool characters(const QString& ch) override;
|
||||
bool ignorableWhitespace(const QString& ch) override;
|
||||
bool processingInstruction(const QString& target, const QString& data) override;
|
||||
bool skippedEntity(const QString& name) override;
|
||||
|
||||
bool warning(const QXmlParseException& exception) override;
|
||||
bool error(const QXmlParseException& exception) override;
|
||||
bool fatalError(const QXmlParseException& exception) override;
|
||||
|
||||
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;
|
||||
|
||||
bool resolveEntity(const QString& publicId, const QString& systemId, QXmlInputSource*& ret) override;
|
||||
|
||||
bool startDTD(const QString& name, const QString& publicId, const QString& systemId) override;
|
||||
bool endDTD() override;
|
||||
bool startEntity(const QString& name) override;
|
||||
bool endEntity(const QString& name) override;
|
||||
bool startCDATA() override;
|
||||
bool endCDATA() override;
|
||||
bool comment(const QString& ch) override;
|
||||
|
||||
bool attributeDecl(const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value) override;
|
||||
bool internalEntityDecl(const QString& name, const QString& value) override;
|
||||
bool externalEntityDecl(const QString& name, const QString& publicId, const QString& systemId) override;
|
||||
|
||||
QString errorString() const override;
|
||||
|
||||
private:
|
||||
QXmlDefaultHandlerPrivate *d;
|
||||
Q_DISABLE_COPY(QXmlDefaultHandler)
|
||||
};
|
||||
|
||||
// inlines
|
||||
|
||||
inline int QXmlAttributes::count() const
|
||||
{ return length(); }
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
#endif // QXML_H
|
||||
|
|
@ -1,328 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtXml module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QXML_P_H
|
||||
#define QXML_P_H
|
||||
|
||||
#include <qstack.h>
|
||||
#include <qmap.h>
|
||||
#include <qhash.h>
|
||||
#include <qxml.h>
|
||||
|
||||
#include <stack>
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience of
|
||||
// qxml.cpp and qdom.cpp. This header file may change from version to version without
|
||||
// notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
|
||||
class QXmlSimpleReaderPrivate
|
||||
{
|
||||
public:
|
||||
~QXmlSimpleReaderPrivate();
|
||||
private:
|
||||
// functions
|
||||
QXmlSimpleReaderPrivate(QXmlSimpleReader *reader);
|
||||
void initIncrementalParsing();
|
||||
|
||||
// used to determine if elements are correctly nested
|
||||
std::stack<QString, QStringList> tags;
|
||||
|
||||
// used by parseReference() and parsePEReference()
|
||||
enum EntityRecognitionContext { InContent, InAttributeValue, InEntityValue, InDTD };
|
||||
|
||||
// used for entity declarations
|
||||
struct ExternParameterEntity
|
||||
{
|
||||
ExternParameterEntity() {}
|
||||
ExternParameterEntity(const QString &p, const QString &s)
|
||||
: publicId(p), systemId(s) {}
|
||||
QString publicId;
|
||||
QString systemId;
|
||||
|
||||
Q_DUMMY_COMPARISON_OPERATOR(ExternParameterEntity)
|
||||
};
|
||||
friend class QTypeInfo<ExternParameterEntity>;
|
||||
|
||||
struct ExternEntity
|
||||
{
|
||||
ExternEntity() {}
|
||||
ExternEntity(const QString &p, const QString &s, const QString &n)
|
||||
: publicId(p), systemId(s), notation(n) {}
|
||||
QString publicId;
|
||||
QString systemId;
|
||||
QString notation;
|
||||
Q_DUMMY_COMPARISON_OPERATOR(ExternEntity)
|
||||
};
|
||||
friend class QTypeInfo<ExternEntity>;
|
||||
|
||||
QMap<QString,ExternParameterEntity> externParameterEntities;
|
||||
QMap<QString,QString> parameterEntities;
|
||||
QMap<QString,ExternEntity> externEntities;
|
||||
QMap<QString,QString> entities;
|
||||
|
||||
// used for parsing of entity references
|
||||
struct XmlRef {
|
||||
XmlRef()
|
||||
: index(0) {}
|
||||
XmlRef(const QString &_name, const QString &_value)
|
||||
: name(_name), value(_value), index(0) {}
|
||||
bool isEmpty() const { return index == value.length(); }
|
||||
QChar next() { return value.at(index++); }
|
||||
QString name;
|
||||
QString value;
|
||||
int index;
|
||||
};
|
||||
friend class QTypeInfo<XmlRef>;
|
||||
QStack<XmlRef> xmlRefStack;
|
||||
|
||||
// used for standalone declaration
|
||||
enum Standalone { Yes, No, Unknown };
|
||||
|
||||
QString doctype; // only used for the doctype
|
||||
QString xmlVersion; // only used to store the version information
|
||||
QString encoding; // only used to store the encoding
|
||||
Standalone standalone; // used to store the value of the standalone declaration
|
||||
|
||||
QString publicId; // used by parseExternalID() to store the public ID
|
||||
QString systemId; // used by parseExternalID() to store the system ID
|
||||
|
||||
// Since publicId/systemId is used as temporary variables by parseExternalID(), it
|
||||
// might overwrite the PUBLIC/SYSTEM for the document we're parsing. In effect, we would
|
||||
// possibly send off an QXmlParseException that has the PUBLIC/SYSTEM of a entity declaration
|
||||
// instead of those of the current document.
|
||||
// Hence we have these two variables for storing the document's data.
|
||||
QString thisPublicId;
|
||||
QString thisSystemId;
|
||||
|
||||
QString attDeclEName; // use by parseAttlistDecl()
|
||||
QString attDeclAName; // use by parseAttlistDecl()
|
||||
|
||||
// flags for some features support
|
||||
bool useNamespaces;
|
||||
bool useNamespacePrefixes;
|
||||
bool reportWhitespaceCharData;
|
||||
bool reportEntities;
|
||||
|
||||
// used to build the attribute list
|
||||
QXmlAttributes attList;
|
||||
|
||||
// used in QXmlSimpleReader::parseContent() to decide whether character
|
||||
// data was read
|
||||
bool contentCharDataRead;
|
||||
// Hack for letting QDom know where the skipped entity occurred
|
||||
bool skipped_entity_in_content;
|
||||
|
||||
// helper classes
|
||||
QScopedPointer<QXmlLocator> locator;
|
||||
QXmlNamespaceSupport namespaceSupport;
|
||||
|
||||
// error string
|
||||
QString error;
|
||||
|
||||
// arguments for parse functions (this is needed to allow incremental
|
||||
// parsing)
|
||||
bool parsePI_xmldecl;
|
||||
bool parseName_useRef;
|
||||
bool parseReference_charDataRead;
|
||||
EntityRecognitionContext parseReference_context;
|
||||
bool parseExternalID_allowPublicID;
|
||||
EntityRecognitionContext parsePEReference_context;
|
||||
QString parseString_s;
|
||||
|
||||
// for incremental parsing
|
||||
struct ParseState {
|
||||
typedef bool (QXmlSimpleReaderPrivate::*ParseFunction)();
|
||||
ParseFunction function;
|
||||
int state;
|
||||
};
|
||||
friend class QTypeInfo<ParseState>;
|
||||
QStack<ParseState> *parseStack;
|
||||
|
||||
// used in parseProlog()
|
||||
bool xmldecl_possible;
|
||||
bool doctype_read;
|
||||
|
||||
// used in parseDoctype()
|
||||
bool startDTDwasReported;
|
||||
|
||||
// used in parseString()
|
||||
signed char Done;
|
||||
|
||||
|
||||
// variables
|
||||
QXmlContentHandler *contentHnd;
|
||||
QXmlErrorHandler *errorHnd;
|
||||
QXmlDTDHandler *dtdHnd;
|
||||
QXmlEntityResolver *entityRes;
|
||||
QXmlLexicalHandler *lexicalHnd;
|
||||
QXmlDeclHandler *declHnd;
|
||||
|
||||
QXmlInputSource *inputSource;
|
||||
|
||||
QChar c; // the character at reading position
|
||||
int lineNr; // number of line
|
||||
int columnNr; // position in line
|
||||
|
||||
QChar nameArray[256]; // only used for names
|
||||
QString nameValue; // only used for names
|
||||
int nameArrayPos;
|
||||
int nameValueLen;
|
||||
QChar refArray[256]; // only used for references
|
||||
QString refValue; // only used for references
|
||||
int refArrayPos;
|
||||
int refValueLen;
|
||||
QChar stringArray[256]; // used for any other strings that are parsed
|
||||
QString stringValue; // used for any other strings that are parsed
|
||||
int stringArrayPos;
|
||||
int stringValueLen;
|
||||
QString emptyStr;
|
||||
|
||||
QHash<QString, int> literalEntitySizes;
|
||||
// The entity at (QMap<QString,) referenced the entities at (QMap<QString,) (int>) times.
|
||||
QHash<QString, QHash<QString, int> > referencesToOtherEntities;
|
||||
QHash<QString, int> expandedSizes;
|
||||
// The limit to the amount of times the DTD parsing functions can be called
|
||||
// for the DTD currently being parsed.
|
||||
static const int dtdRecursionLimit = 2;
|
||||
// The maximum amount of characters an entity value may contain, after expansion.
|
||||
static const int entityCharacterLimit = 4096;
|
||||
|
||||
const QString &string();
|
||||
void stringClear();
|
||||
void stringAddC(QChar);
|
||||
inline void stringAddC() { stringAddC(c); }
|
||||
const QString &name();
|
||||
void nameClear();
|
||||
void nameAddC(QChar);
|
||||
inline void nameAddC() { nameAddC(c); }
|
||||
const QString &ref();
|
||||
void refClear();
|
||||
void refAddC(QChar);
|
||||
inline void refAddC() { refAddC(c); }
|
||||
|
||||
// private functions
|
||||
bool eat_ws();
|
||||
bool next_eat_ws();
|
||||
|
||||
void QT_FASTCALL next();
|
||||
bool atEnd();
|
||||
|
||||
void init(const QXmlInputSource* i);
|
||||
void initData();
|
||||
|
||||
bool entityExist(const QString&) const;
|
||||
|
||||
bool parseBeginOrContinue(int state, bool incremental);
|
||||
|
||||
bool parseProlog();
|
||||
bool parseElement();
|
||||
bool processElementEmptyTag();
|
||||
bool processElementETagBegin2();
|
||||
bool processElementAttribute();
|
||||
bool parseMisc();
|
||||
bool parseContent();
|
||||
|
||||
bool parsePI();
|
||||
bool parseDoctype();
|
||||
bool parseComment();
|
||||
|
||||
bool parseName();
|
||||
bool parseNmtoken();
|
||||
bool parseAttribute();
|
||||
bool parseReference();
|
||||
bool processReference();
|
||||
|
||||
bool parseExternalID();
|
||||
bool parsePEReference();
|
||||
bool parseMarkupdecl();
|
||||
bool parseAttlistDecl();
|
||||
bool parseAttType();
|
||||
bool parseAttValue();
|
||||
bool parseElementDecl();
|
||||
bool parseNotationDecl();
|
||||
bool parseChoiceSeq();
|
||||
bool parseEntityDecl();
|
||||
bool parseEntityValue();
|
||||
|
||||
bool parseString();
|
||||
|
||||
bool insertXmlRef(const QString&, const QString&, bool);
|
||||
|
||||
bool reportEndEntities();
|
||||
void reportParseError(const QString& error);
|
||||
|
||||
typedef bool (QXmlSimpleReaderPrivate::*ParseFunction) ();
|
||||
void unexpectedEof(ParseFunction where, int state);
|
||||
void parseFailed(ParseFunction where, int state);
|
||||
void pushParseState(ParseFunction function, int state);
|
||||
|
||||
bool isExpandedEntityValueTooLarge(QString *errorMessage);
|
||||
|
||||
Q_DECLARE_PUBLIC(QXmlSimpleReader)
|
||||
QXmlSimpleReader *q_ptr;
|
||||
|
||||
friend class QXmlSimpleReaderLocator;
|
||||
friend class QDomHandler;
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ParseState, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::XmlRef, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternParameterEntity, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternEntity, Q_MOVABLE_TYPE);
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
#endif // QXML_P_H
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
SOURCES += $$PWD/qxml.cpp
|
||||
HEADERS += $$PWD/qxml_p.h \
|
||||
$$PWD/qxml.h
|
||||
|
|
@ -12,6 +12,5 @@ HEADERS += qtxmlglobal.h
|
|||
PRECOMPILED_HEADER =
|
||||
|
||||
include(dom/dom.pri)
|
||||
include(sax/sax.pri)
|
||||
|
||||
load(qt_module)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include <QNetworkRequest>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QUrl>
|
||||
#include <QXmlDefaultHandler>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "qc14n.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# Generated from xml.pro.
|
||||
|
||||
add_subdirectory(dom)
|
||||
add_subdirectory(sax)
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
# Generated from sax.pro.
|
||||
|
||||
add_subdirectory(qxml)
|
||||
if(TARGET Qt::Network)
|
||||
add_subdirectory(qxmlinputsource)
|
||||
add_subdirectory(qxmlsimplereader)
|
||||
endif()
|
||||
|
|
@ -1 +0,0 @@
|
|||
tst_qxml
|
||||
|
|
@ -1 +0,0 @@
|
|||
<project čreated-by="{{build_number}}"/>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# Generated from qxml.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qxml Test:
|
||||
#####################################################################
|
||||
|
||||
# Collect test data
|
||||
list(APPEND test_data "0x010D.xml")
|
||||
|
||||
qt_add_test(tst_qxml
|
||||
SOURCES
|
||||
tst_qxml.cpp
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Xml
|
||||
TESTDATA ${test_data}
|
||||
)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
CONFIG += testcase
|
||||
TARGET = tst_qxml
|
||||
|
||||
SOURCES += tst_qxml.cpp
|
||||
QT = core xml testlib
|
||||
|
||||
TESTDATA += 0x010D.xml
|
||||
|
|
@ -1,236 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
|
||||
#include <qcoreapplication.h>
|
||||
#include <qdebug.h>
|
||||
#include <qxml.h>
|
||||
|
||||
class tst_QXml : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
void getSetCheck();
|
||||
void interpretedAs0D() const;
|
||||
#ifndef QT_NO_EXCEPTIONS
|
||||
void exception();
|
||||
#endif
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
};
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
class MyXmlEntityResolver : public QXmlEntityResolver
|
||||
{
|
||||
public:
|
||||
MyXmlEntityResolver() : QXmlEntityResolver() {}
|
||||
QString errorString() const { return QString(); }
|
||||
bool resolveEntity(const QString &, const QString &, QXmlInputSource *&) { return false; }
|
||||
};
|
||||
|
||||
class MyXmlContentHandler : public QXmlContentHandler
|
||||
{
|
||||
public:
|
||||
MyXmlContentHandler() : QXmlContentHandler() {}
|
||||
bool characters(const QString &) { return false; }
|
||||
bool endDocument() { return false; }
|
||||
bool endElement(const QString &, const QString &, const QString &) { return false; }
|
||||
bool endPrefixMapping(const QString &) { return false; }
|
||||
QString errorString() const { return QString(); }
|
||||
bool ignorableWhitespace(const QString &) { return false; }
|
||||
bool processingInstruction(const QString &, const QString &) { return false; }
|
||||
void setDocumentLocator(QXmlLocator *) { }
|
||||
bool skippedEntity(const QString &) { return false; }
|
||||
bool startDocument() { return false; }
|
||||
bool startElement(const QString &, const QString &, const QString &, const QXmlAttributes &) { return false; }
|
||||
bool startPrefixMapping(const QString &, const QString &) { return false; }
|
||||
};
|
||||
|
||||
class MyXmlErrorHandler : public QXmlErrorHandler
|
||||
{
|
||||
public:
|
||||
MyXmlErrorHandler() : QXmlErrorHandler() {}
|
||||
QString errorString() const { return QString(); }
|
||||
bool error(const QXmlParseException &) { return false; }
|
||||
bool fatalError(const QXmlParseException &) { return false; }
|
||||
bool warning(const QXmlParseException &) { return false; }
|
||||
};
|
||||
|
||||
class MyXmlLexicalHandler : public QXmlLexicalHandler
|
||||
{
|
||||
public:
|
||||
MyXmlLexicalHandler() : QXmlLexicalHandler() {}
|
||||
bool comment(const QString &) { return false; }
|
||||
bool endCDATA() { return false; }
|
||||
bool endDTD() { return false; }
|
||||
bool endEntity(const QString &) { return false; }
|
||||
QString errorString() const { return QString(); }
|
||||
bool startCDATA() { return false; }
|
||||
bool startDTD(const QString &, const QString &, const QString &) { return false; }
|
||||
bool startEntity(const QString &) { return false; }
|
||||
};
|
||||
|
||||
class MyXmlDeclHandler : public QXmlDeclHandler
|
||||
{
|
||||
public:
|
||||
MyXmlDeclHandler() : QXmlDeclHandler() {}
|
||||
bool attributeDecl(const QString &, const QString &, const QString &, const QString &, const QString &) { return false; }
|
||||
QString errorString() const { return QString(); }
|
||||
bool externalEntityDecl(const QString &, const QString &, const QString &) { return false; }
|
||||
bool internalEntityDecl(const QString &, const QString &) { return false; }
|
||||
};
|
||||
|
||||
// Testing get/set functions
|
||||
void tst_QXml::getSetCheck()
|
||||
{
|
||||
QXmlSimpleReader obj1;
|
||||
// QXmlEntityResolver* QXmlSimpleReader::entityResolver()
|
||||
// void QXmlSimpleReader::setEntityResolver(QXmlEntityResolver*)
|
||||
MyXmlEntityResolver *var1 = new MyXmlEntityResolver;
|
||||
obj1.setEntityResolver(var1);
|
||||
QCOMPARE(static_cast<QXmlEntityResolver *>(var1), obj1.entityResolver());
|
||||
obj1.setEntityResolver((QXmlEntityResolver *)0);
|
||||
QCOMPARE((QXmlEntityResolver *)0, obj1.entityResolver());
|
||||
delete var1;
|
||||
|
||||
// QXmlContentHandler* QXmlSimpleReader::contentHandler()
|
||||
// void QXmlSimpleReader::setContentHandler(QXmlContentHandler*)
|
||||
MyXmlContentHandler *var2 = new MyXmlContentHandler;
|
||||
obj1.setContentHandler(var2);
|
||||
QCOMPARE(static_cast<QXmlContentHandler *>(var2), obj1.contentHandler());
|
||||
obj1.setContentHandler((QXmlContentHandler *)0);
|
||||
QCOMPARE((QXmlContentHandler *)0, obj1.contentHandler());
|
||||
delete var2;
|
||||
|
||||
// QXmlErrorHandler* QXmlSimpleReader::errorHandler()
|
||||
// void QXmlSimpleReader::setErrorHandler(QXmlErrorHandler*)
|
||||
MyXmlErrorHandler *var3 = new MyXmlErrorHandler;
|
||||
obj1.setErrorHandler(var3);
|
||||
QCOMPARE(static_cast<QXmlErrorHandler *>(var3), obj1.errorHandler());
|
||||
obj1.setErrorHandler((QXmlErrorHandler *)0);
|
||||
QCOMPARE((QXmlErrorHandler *)0, obj1.errorHandler());
|
||||
delete var3;
|
||||
|
||||
// QXmlLexicalHandler* QXmlSimpleReader::lexicalHandler()
|
||||
// void QXmlSimpleReader::setLexicalHandler(QXmlLexicalHandler*)
|
||||
MyXmlLexicalHandler *var4 = new MyXmlLexicalHandler;
|
||||
obj1.setLexicalHandler(var4);
|
||||
QCOMPARE(static_cast<QXmlLexicalHandler *>(var4), obj1.lexicalHandler());
|
||||
obj1.setLexicalHandler((QXmlLexicalHandler *)0);
|
||||
QCOMPARE((QXmlLexicalHandler *)0, obj1.lexicalHandler());
|
||||
delete var4;
|
||||
|
||||
// QXmlDeclHandler* QXmlSimpleReader::declHandler()
|
||||
// void QXmlSimpleReader::setDeclHandler(QXmlDeclHandler*)
|
||||
MyXmlDeclHandler *var5 = new MyXmlDeclHandler;
|
||||
obj1.setDeclHandler(var5);
|
||||
QCOMPARE(static_cast<QXmlDeclHandler *>(var5), obj1.declHandler());
|
||||
obj1.setDeclHandler((QXmlDeclHandler *)0);
|
||||
QCOMPARE((QXmlDeclHandler *)0, obj1.declHandler());
|
||||
delete var5;
|
||||
}
|
||||
|
||||
void tst_QXml::interpretedAs0D() const
|
||||
{
|
||||
/* See task 172632. */
|
||||
|
||||
class MyHandler : public QXmlDefaultHandler
|
||||
{
|
||||
public:
|
||||
virtual bool startElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName,
|
||||
const QXmlAttributes &atts)
|
||||
{
|
||||
Q_UNUSED(namespaceURI);
|
||||
Q_UNUSED(localName);
|
||||
Q_UNUSED(qName);
|
||||
attrName = atts.qName(0);
|
||||
attrCount = atts.count();
|
||||
return true;
|
||||
}
|
||||
|
||||
QString attrName;
|
||||
int attrCount;
|
||||
};
|
||||
|
||||
const QString document(QLatin1String("<element ") +
|
||||
QChar(0x010D) +
|
||||
QLatin1String("reated-by=\"an attr value\"/>"));
|
||||
|
||||
QString testFile = QFINDTESTDATA("0x010D.xml");
|
||||
if (testFile.isEmpty())
|
||||
QFAIL("Cannot find test file 0x010D.xml!");
|
||||
QFile f(testFile);
|
||||
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||
QXmlInputSource data(&f);
|
||||
|
||||
QXmlSimpleReader reader;
|
||||
|
||||
MyHandler myHandler;
|
||||
reader.setContentHandler(&myHandler);
|
||||
reader.setErrorHandler(&myHandler);
|
||||
|
||||
QVERIFY(reader.parse(&data));
|
||||
|
||||
QCOMPARE(myHandler.attrCount, 1);
|
||||
QCOMPARE(myHandler.attrName, QChar(0x010D) + QString::fromLatin1("reated-by"));
|
||||
}
|
||||
|
||||
#ifndef QT_NO_EXCEPTIONS
|
||||
void tst_QXml::exception()
|
||||
{
|
||||
QString message = QString::fromLatin1("message");
|
||||
int column = 3;
|
||||
int line = 2;
|
||||
QString publicId = QString::fromLatin1("publicId");
|
||||
QString systemId = QString::fromLatin1("systemId");
|
||||
|
||||
try {
|
||||
QXmlParseException e(message, column, line, publicId, systemId);
|
||||
throw e;
|
||||
}
|
||||
catch (QXmlParseException e) {
|
||||
QCOMPARE(e.message(), message);
|
||||
QCOMPARE(e.columnNumber(), column);
|
||||
QCOMPARE(e.lineNumber(), line);
|
||||
QCOMPARE(e.publicId(), publicId);
|
||||
QCOMPARE(e.systemId(), systemId);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
QTEST_MAIN(tst_QXml)
|
||||
#include "tst_qxml.moc"
|
||||
|
|
@ -1 +0,0 @@
|
|||
tst_qxmlinputsource
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# Generated from qxmlinputsource.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qxmlinputsource Test:
|
||||
#####################################################################
|
||||
|
||||
qt_add_test(tst_qxmlinputsource
|
||||
SOURCES
|
||||
tst_qxmlinputsource.cpp
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Network
|
||||
Qt::Xml
|
||||
)
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
CONFIG += testcase
|
||||
TARGET = tst_qxmlinputsource
|
||||
SOURCES += tst_qxmlinputsource.cpp
|
||||
QT = core xml network testlib
|
||||
|
|
@ -1,304 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QtDebug>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QXmlDefaultHandler>
|
||||
#include <QXmlInputSource>
|
||||
#include <QXmlSimpleReader>
|
||||
|
||||
class tst_QXmlInputSource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
private slots:
|
||||
void reset() const;
|
||||
void resetSimplified() const;
|
||||
void waitForReadyIODevice() const;
|
||||
void inputFromSlowDevice() const;
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
};
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
/*!
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
See task 166278.
|
||||
*/
|
||||
void tst_QXmlInputSource::reset() const
|
||||
{
|
||||
const QString input(QString::fromLatin1("<element attribute1='value1' attribute2='value2'/>"));
|
||||
|
||||
QXmlSimpleReader reader;
|
||||
QXmlDefaultHandler handler;
|
||||
reader.setContentHandler(&handler);
|
||||
|
||||
QXmlInputSource source;
|
||||
source.setData(input);
|
||||
|
||||
QCOMPARE(source.data(), input);
|
||||
|
||||
source.reset();
|
||||
QCOMPARE(source.data(), input);
|
||||
|
||||
source.reset();
|
||||
QVERIFY(reader.parse(source));
|
||||
source.reset();
|
||||
QCOMPARE(source.data(), input);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
See task 166278.
|
||||
*/
|
||||
void tst_QXmlInputSource::resetSimplified() const
|
||||
{
|
||||
const QString input(QString::fromLatin1("<element/>"));
|
||||
|
||||
QXmlSimpleReader reader;
|
||||
|
||||
QXmlInputSource source;
|
||||
source.setData(input);
|
||||
|
||||
QVERIFY(reader.parse(source));
|
||||
source.reset();
|
||||
QCOMPARE(source.data(), input);
|
||||
}
|
||||
|
||||
class ServerAndClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ServerAndClient(QEventLoop &ev) : success(false)
|
||||
, eventLoop(ev)
|
||||
, bodyBytesRead(0)
|
||||
, bodyLength(-1)
|
||||
, isBody(false)
|
||||
{
|
||||
setObjectName("serverAndClient");
|
||||
tcpServer = new QTcpServer(this);
|
||||
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
|
||||
tcpServer->listen(QHostAddress::LocalHost, 1088);
|
||||
httpClient = new QNetworkAccessManager(this);
|
||||
connect(httpClient, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
bool success;
|
||||
QEventLoop &eventLoop;
|
||||
|
||||
public slots:
|
||||
void doIt()
|
||||
{
|
||||
QUrl url("http://127.0.0.1:1088");
|
||||
QNetworkRequest req(url);
|
||||
req.setRawHeader("POST", url.path().toLatin1());
|
||||
req.setRawHeader("user-agent", "xml-test");
|
||||
req.setRawHeader("keep-alive", "false");
|
||||
req.setRawHeader("host", url.host().toLatin1());
|
||||
|
||||
QByteArray xmlrpc("<methodCall>\r\n\
|
||||
<methodName>SFD.GetVersion</methodName>\r\n\
|
||||
<params/>\r\n\
|
||||
</methodCall>");
|
||||
req.setHeader(QNetworkRequest::ContentLengthHeader, xmlrpc.size());
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, "text/xml");
|
||||
|
||||
httpClient->post(req, xmlrpc);
|
||||
}
|
||||
|
||||
void requestFinished(QNetworkReply *reply)
|
||||
{
|
||||
QCOMPARE(reply->error(), QNetworkReply::NoError);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void newConnection()
|
||||
{
|
||||
QTcpSocket *const s = tcpServer->nextPendingConnection();
|
||||
|
||||
if(s)
|
||||
connect(s, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
}
|
||||
|
||||
void readyRead()
|
||||
{
|
||||
QTcpSocket *const s = static_cast<QTcpSocket *>(sender());
|
||||
|
||||
while (s->bytesAvailable())
|
||||
{
|
||||
const QString line(s->readLine());
|
||||
|
||||
if (line.startsWith("Content-Length:"))
|
||||
bodyLength = line.mid(15).toInt();
|
||||
|
||||
if (isBody)
|
||||
{
|
||||
body.append(line.toUtf8());
|
||||
bodyBytesRead += line.length();
|
||||
}
|
||||
else if (line == "\r\n")
|
||||
{
|
||||
isBody = true;
|
||||
if (bodyLength == -1)
|
||||
{
|
||||
qFatal("No length was specified in the header.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bodyBytesRead == bodyLength)
|
||||
{
|
||||
QDomDocument domDoc;
|
||||
success = domDoc.setContent(body);
|
||||
eventLoop.exit();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QByteArray body;
|
||||
int bodyBytesRead, bodyLength;
|
||||
bool isBody;
|
||||
QTcpServer *tcpServer;
|
||||
QNetworkAccessManager* httpClient;
|
||||
};
|
||||
|
||||
void tst_QXmlInputSource::waitForReadyIODevice() const
|
||||
{
|
||||
QEventLoop el;
|
||||
ServerAndClient sv(el);
|
||||
QTimer::singleShot(1, &sv, SLOT(doIt()));
|
||||
|
||||
el.exec();
|
||||
QVERIFY(sv.success);
|
||||
}
|
||||
|
||||
// This class is used to emulate a case where less than 4 bytes are sent in
|
||||
// a single packet to ensure it is still parsed correctly
|
||||
class SlowIODevice : public QIODevice
|
||||
{
|
||||
public:
|
||||
SlowIODevice(const QString &expectedData, QObject *parent = 0)
|
||||
: QIODevice(parent), currentPos(0), readyToSend(true)
|
||||
{
|
||||
stringData = expectedData.toUtf8();
|
||||
dataTimer = new QTimer(this);
|
||||
connect(dataTimer, &QTimer::timeout, [=]() {
|
||||
readyToSend = true;
|
||||
emit readyRead();
|
||||
dataTimer->stop();
|
||||
});
|
||||
dataTimer->start(1000);
|
||||
}
|
||||
bool open(SlowIODevice::OpenMode) override
|
||||
{
|
||||
setOpenMode(ReadOnly);
|
||||
return true;
|
||||
}
|
||||
bool isSequential() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
qint64 bytesAvailable() const override
|
||||
{
|
||||
if (readyToSend && stringData.size() != currentPos)
|
||||
return qMax(3, stringData.size() - currentPos);
|
||||
return 0;
|
||||
}
|
||||
qint64 readData(char *data, qint64 maxSize) override
|
||||
{
|
||||
if (!readyToSend)
|
||||
return 0;
|
||||
const qint64 readSize = qMin(qMin((qint64)3, maxSize), (qint64)(stringData.size() - currentPos));
|
||||
if (readSize > 0)
|
||||
memcpy(data, &stringData.constData()[currentPos], readSize);
|
||||
currentPos += readSize;
|
||||
readyToSend = false;
|
||||
if (currentPos != stringData.size())
|
||||
dataTimer->start(1000);
|
||||
return readSize;
|
||||
}
|
||||
qint64 writeData(const char *, qint64) override { return 0; }
|
||||
bool waitForReadyRead(int msecs) override
|
||||
{
|
||||
// Delibrately wait a maximum of 10 seconds for the sake
|
||||
// of the test, so it doesn't unduly hang
|
||||
const int waitTime = qMax(10000, msecs);
|
||||
QElapsedTimer t;
|
||||
t.start();
|
||||
while (t.elapsed() < waitTime) {
|
||||
QCoreApplication::processEvents();
|
||||
if (readyToSend)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
QByteArray stringData;
|
||||
int currentPos;
|
||||
bool readyToSend;
|
||||
QTimer *dataTimer;
|
||||
};
|
||||
|
||||
void tst_QXmlInputSource::inputFromSlowDevice() const
|
||||
{
|
||||
QString expectedData = QStringLiteral("<foo><bar>kake</bar><bar>ja</bar></foo>");
|
||||
SlowIODevice slowDevice(expectedData);
|
||||
QXmlInputSource source(&slowDevice);
|
||||
QString data;
|
||||
while (true) {
|
||||
const QChar nextChar = source.next();
|
||||
if (nextChar == QXmlInputSource::EndOfDocument)
|
||||
break;
|
||||
else if (nextChar != QXmlInputSource::EndOfData)
|
||||
data += nextChar;
|
||||
}
|
||||
QCOMPARE(data, expectedData);
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
QTEST_MAIN(tst_QXmlInputSource)
|
||||
#include "tst_qxmlinputsource.moc"
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
encodings/doc_euc-jp.xml -crlf
|
||||
encodings/doc_utf-8.xml -crlf
|
||||
xmldocs/* -crlf
|
||||
xmldocs/*/* -crlf
|
||||
xmldocs/*/*/* -crlf
|
||||
xmldocs/*/*/*/* -crlf
|
||||
xmldocs/*/*/*/*/* -crlf
|
||||
xmldocs/*/*/*/*/*/* -crlf
|
||||
|
|
@ -1 +0,0 @@
|
|||
tst_qxmlsimplereader
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# Generated from qxmlsimplereader.pro.
|
||||
|
||||
#####################################################################
|
||||
## tst_qxmlsimplereader Test:
|
||||
#####################################################################
|
||||
|
||||
# Collect test data
|
||||
file(GLOB_RECURSE test_data_glob
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
encodings/*)
|
||||
list(APPEND test_data ${test_data_glob})
|
||||
file(GLOB_RECURSE test_data_glob
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
xmldocs/*)
|
||||
list(APPEND test_data ${test_data_glob})
|
||||
|
||||
qt_add_test(tst_qxmlsimplereader
|
||||
SOURCES
|
||||
parser/parser.cpp parser/parser.h
|
||||
tst_qxmlsimplereader.cpp
|
||||
INCLUDE_DIRECTORIES
|
||||
parser
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::Network
|
||||
Qt::Xml
|
||||
TESTDATA ${test_data}
|
||||
)
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,77 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- 週報サンプル -->
|
||||
<週報>
|
||||
<年月週>
|
||||
<年度>1997</年度>
|
||||
<月度>1</月度>
|
||||
<週>1</週>
|
||||
</年月週>
|
||||
|
||||
<氏名>
|
||||
<氏>山田</氏>
|
||||
<名>太郎</名>
|
||||
</氏名>
|
||||
|
||||
<業務報告リスト>
|
||||
<業務報告>
|
||||
<業務名>XMLエディターの作成</業務名>
|
||||
<業務コード>X3355-23</業務コード>
|
||||
<工数管理>
|
||||
<見積もり工数>1600</見積もり工数>
|
||||
<実績工数>320</実績工数>
|
||||
<当月見積もり工数>160</当月見積もり工数>
|
||||
<当月実績工数>24</当月実績工数>
|
||||
</工数管理>
|
||||
<予定項目リスト>
|
||||
<予定項目>
|
||||
<P>XMLエディターの基本仕様の作成</P>
|
||||
</予定項目>
|
||||
</予定項目リスト>
|
||||
<実施事項リスト>
|
||||
<実施事項>
|
||||
<P>XMLエディターの基本仕様の作成</P>
|
||||
</実施事項>
|
||||
<実施事項>
|
||||
<P>競合他社製品の機能調査</P>
|
||||
</実施事項>
|
||||
</実施事項リスト>
|
||||
<上長への要請事項リスト>
|
||||
<上長への要請事項>
|
||||
<P>特になし</P>
|
||||
</上長への要請事項>
|
||||
</上長への要請事項リスト>
|
||||
<問題点対策>
|
||||
<P>XMLとは何かわからない。</P>
|
||||
</問題点対策>
|
||||
</業務報告>
|
||||
|
||||
<業務報告>
|
||||
<業務名>検索エンジンの開発</業務名>
|
||||
<業務コード>S8821-76</業務コード>
|
||||
<工数管理>
|
||||
<見積もり工数>120</見積もり工数>
|
||||
<実績工数>6</実績工数>
|
||||
<当月見積もり工数>32</当月見積もり工数>
|
||||
<当月実績工数>2</当月実績工数>
|
||||
</工数管理>
|
||||
<予定項目リスト>
|
||||
<予定項目>
|
||||
<P><A href="http://www.goo.ne.jp">goo</A>の機能を調べてみる</P>
|
||||
</予定項目>
|
||||
</予定項目リスト>
|
||||
<実施事項リスト>
|
||||
<実施事項>
|
||||
<P>更に、どういう検索エンジンがあるか調査する</P>
|
||||
</実施事項>
|
||||
</実施事項リスト>
|
||||
<上長への要請事項リスト>
|
||||
<上長への要請事項>
|
||||
<P>開発をするのはめんどうなので、Yahoo!を買収して下さい。</P>
|
||||
</上長への要請事項>
|
||||
</上長への要請事項リスト>
|
||||
<問題点対策>
|
||||
<P>検索エンジンで車を走らせることができない。(要調査)</P>
|
||||
</問題点対策>
|
||||
</業務報告>
|
||||
</業務報告リスト>
|
||||
</週報>
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
#############################################################################
|
||||
##
|
||||
## Copyright (C) 2016 The Qt Company Ltd.
|
||||
## Contact: https://www.qt.io/licensing/
|
||||
##
|
||||
## This file is the build configuration utility of the Qt Toolkit.
|
||||
##
|
||||
## $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
## Commercial License Usage
|
||||
## Licensees holding valid commercial Qt licenses may use this file in
|
||||
## accordance with the commercial license agreement provided with the
|
||||
## Software or, alternatively, in accordance with the terms contained in
|
||||
## a written agreement between you and The Qt Company. For licensing terms
|
||||
## and conditions see https://www.qt.io/terms-conditions. For further
|
||||
## information use the contact form at https://www.qt.io/contact-us.
|
||||
##
|
||||
## GNU General Public License Usage
|
||||
## Alternatively, this file may be used under the terms of the GNU
|
||||
## General Public License version 3 as published by the Free Software
|
||||
## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
## included in the packaging of this file. Please review the following
|
||||
## information to ensure the GNU General Public License requirements will
|
||||
## be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
##
|
||||
## $QT_END_LICENSE$
|
||||
##
|
||||
#############################################################################
|
||||
|
||||
for k in `find xmldocs -name \*.xml`; do echo $k...; ./parser/parser $k; done
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# special case skip regeneration
|
||||
|
||||
cmake_minimum_required(VERSION 3.14.0)
|
||||
|
||||
project(Parser CXX)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Xml)
|
||||
|
||||
add_executable(parser)
|
||||
|
||||
target_sources(parser PRIVATE
|
||||
main.cpp
|
||||
parser.cpp
|
||||
parser.h
|
||||
)
|
||||
|
||||
target_link_libraries(parser PRIVATE
|
||||
Qt::Gui
|
||||
Qt::Xml
|
||||
)
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qfile.h>
|
||||
#include <qstring.h>
|
||||
#include <qtextstream.h>
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
static QTextStream qerr(stderr, QIODevice::WriteOnly);
|
||||
|
||||
static void usage()
|
||||
{
|
||||
qerr << "Usage: parse [-report-whitespace-only-chardata] [-report-start-end-entity] <in-file> [<out-file>]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
QString file_name;
|
||||
QString out_file_name;
|
||||
bool report_start_end_entity = false;
|
||||
bool report_whitespace_only_chardata = false;
|
||||
|
||||
for (int i = 1 ; i < argc; ++i) {
|
||||
QString arg = QString::fromLocal8Bit(argv[i]);
|
||||
if (arg == QLatin1String("-report-whitespace-only-chardata"))
|
||||
report_whitespace_only_chardata = true;
|
||||
else if (arg == QLatin1String("-report-start-end-entity"))
|
||||
report_start_end_entity = true;
|
||||
else if (file_name.isEmpty())
|
||||
file_name = arg;
|
||||
else if (out_file_name.isEmpty())
|
||||
out_file_name = arg;
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
||||
if (file_name.isEmpty())
|
||||
usage();
|
||||
|
||||
QFile in_file(file_name);
|
||||
if (!in_file.open(QIODevice::ReadOnly)) {
|
||||
qerr << "Could not open " << file_name << ": " << strerror(errno) << Qt::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (out_file_name.isEmpty())
|
||||
out_file_name = file_name + ".ref";
|
||||
|
||||
QFile out_file;
|
||||
if (out_file_name == "-") {
|
||||
out_file.open(stdout, QFile::WriteOnly);
|
||||
} else {
|
||||
out_file.setFileName(out_file_name);
|
||||
if (!out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
qerr << "Could not open " << out_file_name << ": " << strerror(errno) << Qt::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Parser parser;
|
||||
if (report_start_end_entity)
|
||||
parser.setFeature("http://trolltech.com/xml/features/report-start-end-entity", true);
|
||||
if (report_whitespace_only_chardata)
|
||||
parser.setFeature("http://trolltech.com/xml/features/report-whitespace-only-CharData", true);
|
||||
|
||||
parser.parseFile(&in_file);
|
||||
|
||||
out_file.write(parser.result().toUtf8());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,449 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
#include <qxml.h>
|
||||
#include <qregularexpression.h>
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
class ContentHandler : public QXmlDefaultHandler
|
||||
{
|
||||
public:
|
||||
ContentHandler();
|
||||
|
||||
// QXmlContentHandler methods
|
||||
bool startDocument();
|
||||
bool endDocument();
|
||||
bool startElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName,
|
||||
const QXmlAttributes &atts);
|
||||
bool endElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName);
|
||||
bool characters(const QString &ch);
|
||||
void setDocumentLocator(QXmlLocator *locator);
|
||||
bool startPrefixMapping(const QString &prefix, const QString &uri);
|
||||
bool endPrefixMapping(const QString &prefix);
|
||||
bool ignorableWhitespace(const QString &ch);
|
||||
bool processingInstruction(const QString &target, const QString &data);
|
||||
bool skippedEntity(const QString &name);
|
||||
|
||||
// QXmlErrorHandler methods
|
||||
bool warning(const QXmlParseException &exception);
|
||||
bool error(const QXmlParseException &exception);
|
||||
bool fatalError(const QXmlParseException &exception);
|
||||
|
||||
// QXmlDTDHandler methods
|
||||
bool notationDecl(const QString &name, const QString &publicId,
|
||||
const QString &systemId);
|
||||
bool unparsedEntityDecl(const QString &name,
|
||||
const QString &publicId,
|
||||
const QString &systemId,
|
||||
const QString ¬ationName);
|
||||
|
||||
// QXmlEntityResolver methods
|
||||
bool resolveEntity(const QString &publicId,
|
||||
const QString &systemId,
|
||||
QXmlInputSource *&);
|
||||
|
||||
// QXmlLexicalHandler methods
|
||||
bool startDTD (const QString &name, const QString &publicId, const QString &systemId);
|
||||
bool endDTD();
|
||||
bool startEntity(const QString &name);
|
||||
bool endEntity(const QString &name);
|
||||
bool startCDATA();
|
||||
bool endCDATA();
|
||||
bool comment(const QString &ch);
|
||||
|
||||
// QXmlDeclHandler methods
|
||||
bool attributeDecl(const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value);
|
||||
bool internalEntityDecl(const QString &name, const QString &value);
|
||||
bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId);
|
||||
|
||||
|
||||
const QString &result() const { return m_result; }
|
||||
const QString &errorMsg() const { return m_error_msg; }
|
||||
|
||||
private:
|
||||
QString nestPrefix() const { return QString().fill(' ', 3*m_nest); }
|
||||
QString formatAttributes(const QXmlAttributes & atts);
|
||||
QString escapeStr(const QString &s);
|
||||
|
||||
unsigned m_nest;
|
||||
QString m_result, m_error_msg;
|
||||
};
|
||||
|
||||
ContentHandler::ContentHandler()
|
||||
{
|
||||
m_nest = 0;
|
||||
}
|
||||
|
||||
|
||||
bool ContentHandler::startDocument()
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "startDocument()\n";
|
||||
++m_nest;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::endDocument()
|
||||
{
|
||||
--m_nest;
|
||||
m_result += nestPrefix();
|
||||
m_result += "endDocument()\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::startElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName,
|
||||
const QXmlAttributes &atts)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "startElement(namespaceURI=\"" + escapeStr(namespaceURI)
|
||||
+ "\", localName=\"" + escapeStr(localName)
|
||||
+ "\", qName=\"" + escapeStr(qName)
|
||||
+ "\", atts=[" + formatAttributes(atts) + "])\n";
|
||||
++m_nest;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString ContentHandler::escapeStr(const QString &s)
|
||||
{
|
||||
QString result = s;
|
||||
result.replace(QChar(0), "\\0");
|
||||
result.replace("\\", "\\\\");
|
||||
result.replace("\"", "\\\"");
|
||||
result.replace("\n", "\\n");
|
||||
result.replace("\r", "\\r");
|
||||
result.replace("\t", "\\t");
|
||||
return result;
|
||||
}
|
||||
|
||||
QString ContentHandler::formatAttributes(const QXmlAttributes &atts)
|
||||
{
|
||||
QString result;
|
||||
for (int i = 0, cnt = atts.count(); i < cnt; ++i) {
|
||||
if (i != 0) result += ", ";
|
||||
result += "{localName=\"" + escapeStr(atts.localName(i))
|
||||
+ "\", qName=\"" + escapeStr(atts.qName(i))
|
||||
+ "\", uri=\"" + escapeStr(atts.uri(i))
|
||||
+ "\", type=\"" + escapeStr(atts.type(i))
|
||||
+ "\", value=\"" + escapeStr(atts.value(i)) + "\"}";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ContentHandler::endElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName)
|
||||
{
|
||||
--m_nest;
|
||||
m_result += nestPrefix();
|
||||
m_result += "endElement(namespaceURI=\"" + escapeStr(namespaceURI)
|
||||
+ "\", localName=\"" + escapeStr(localName)
|
||||
+ "\", qName=\"" + escapeStr(qName) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::characters(const QString &ch)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "characters(ch=\"" + escapeStr(ch) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
void ContentHandler::setDocumentLocator(QXmlLocator *locator)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "setDocumentLocator(locator={columnNumber="
|
||||
+ QString::number(locator->columnNumber())
|
||||
+ ", lineNumber=" + QString::number(locator->lineNumber())
|
||||
+ "})\n";
|
||||
}
|
||||
|
||||
bool ContentHandler::startPrefixMapping (const QString &prefix, const QString & uri)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "startPrefixMapping(prefix=\"" + escapeStr(prefix)
|
||||
+ "\", uri=\"" + escapeStr(uri) + "\")\n";
|
||||
++m_nest;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::endPrefixMapping(const QString &prefix)
|
||||
{
|
||||
--m_nest;
|
||||
m_result += nestPrefix();
|
||||
m_result += "endPrefixMapping(prefix=\"" + escapeStr(prefix) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::ignorableWhitespace(const QString & ch)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "ignorableWhitespace(ch=\"" + escapeStr(ch) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::processingInstruction(const QString &target, const QString &data)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "processingInstruction(target=\"" + escapeStr(target)
|
||||
+ "\", data=\"" + escapeStr(data) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::skippedEntity (const QString & name)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "skippedEntity(name=\"" + escapeStr(name) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::warning(const QXmlParseException & exception)
|
||||
{
|
||||
m_error_msg = QString("Warning %1:%2: %3")
|
||||
.arg(exception.columnNumber())
|
||||
.arg(exception.lineNumber())
|
||||
.arg(exception.message());
|
||||
m_result += nestPrefix();
|
||||
m_result += "warning(exception={columnNumber="
|
||||
+ QString::number(exception.columnNumber())
|
||||
+ ", lineNumber="
|
||||
+ QString::number(exception.lineNumber())
|
||||
+ ", publicId=\"" + escapeStr(exception.publicId())
|
||||
+ "\", systemId=\"" + escapeStr(exception.systemId())
|
||||
+ "\", message=\"" + escapeStr(exception.message())
|
||||
+ "\"})\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::error(const QXmlParseException & exception)
|
||||
{
|
||||
m_error_msg = QString("Error %1:%2: %3")
|
||||
.arg(exception.columnNumber())
|
||||
.arg(exception.lineNumber())
|
||||
.arg(exception.message());
|
||||
m_result += nestPrefix();
|
||||
m_result += "error(exception={columnNumber="
|
||||
+ QString::number(exception.columnNumber())
|
||||
+ ", lineNumber="
|
||||
+ QString::number(exception.lineNumber())
|
||||
+ ", publicId=\"" + escapeStr(exception.publicId())
|
||||
+ "\", systemId=\"" + escapeStr(exception.systemId())
|
||||
+ "\", message=\"" + escapeStr(exception.message())
|
||||
+ "\"})\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::fatalError(const QXmlParseException & exception)
|
||||
{
|
||||
m_error_msg = QString("Fatal error %1:%2: %3")
|
||||
.arg(exception.columnNumber())
|
||||
.arg(exception.lineNumber())
|
||||
.arg(exception.message());
|
||||
m_result += nestPrefix();
|
||||
m_result += "fatalError(exception={columnNumber="
|
||||
+ QString::number(exception.columnNumber())
|
||||
+ ", lineNumber="
|
||||
+ QString::number(exception.lineNumber())
|
||||
+ ", publicId=\"" + escapeStr(exception.publicId())
|
||||
+ "\", systemId=\"" + escapeStr(exception.systemId())
|
||||
+ "\", message=\"" + escapeStr(exception.message())
|
||||
+ "\"})\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::notationDecl(const QString &name,
|
||||
const QString &publicId,
|
||||
const QString &systemId )
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "notationDecl(name=\"" + escapeStr(name) + "\", publicId=\""
|
||||
+ escapeStr(publicId) + "\", systemId=\""
|
||||
+ escapeStr(systemId) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::unparsedEntityDecl(const QString &name,
|
||||
const QString &publicId,
|
||||
const QString &systemId,
|
||||
const QString ¬ationName )
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "unparsedEntityDecl(name=\"" + escapeStr(name)
|
||||
+ "\", publicId=\"" + escapeStr(publicId)
|
||||
+ "\", systemId=\"" + escapeStr(systemId)
|
||||
+ "\", notationName=\"" + escapeStr(notationName)
|
||||
+ "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::resolveEntity(const QString &publicId,
|
||||
const QString &systemId,
|
||||
QXmlInputSource *&)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "resolveEntity(publicId=\"" + escapeStr(publicId)
|
||||
+ "\", systemId=\"" + escapeStr(systemId)
|
||||
+ "\", ret={})\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::startDTD ( const QString & name, const QString & publicId, const QString & systemId )
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "startDTD(name=\"" + escapeStr(name)
|
||||
+ "\", publicId=\"" + escapeStr(publicId)
|
||||
+ "\", systemId=\"" + escapeStr(systemId) + "\")\n";
|
||||
++m_nest;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::endDTD ()
|
||||
{
|
||||
--m_nest;
|
||||
m_result += nestPrefix();
|
||||
m_result += "endDTD()\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::startEntity ( const QString & name )
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "startEntity(name=\"" + escapeStr(name) + "\")\n";
|
||||
++m_nest;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::endEntity ( const QString & name )
|
||||
{
|
||||
--m_nest;
|
||||
m_result += nestPrefix();
|
||||
m_result += "endEntity(name=\"" + escapeStr(name) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::startCDATA ()
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "startCDATA()\n";
|
||||
++m_nest;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::endCDATA ()
|
||||
{
|
||||
--m_nest;
|
||||
m_result += nestPrefix();
|
||||
m_result += "endCDATA()\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::comment ( const QString & ch )
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "comment(ch=\"" + escapeStr(ch) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::attributeDecl(const QString &eName,
|
||||
const QString &aName,
|
||||
const QString &type,
|
||||
const QString &valueDefault,
|
||||
const QString &value)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "attributeDecl(eName=\"" + escapeStr(eName) + "\", aName=\""
|
||||
+ escapeStr(aName) + "\", type=\"" + escapeStr(type)
|
||||
+ "\", valueDefault=\"" + escapeStr(valueDefault)
|
||||
+ "\", value=\"" + escapeStr(value) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::internalEntityDecl(const QString &name,
|
||||
const QString &value)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "internatlEntityDecl(name=\"" + escapeStr(name)
|
||||
+ "\", value=\"" + escapeStr(value) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContentHandler::externalEntityDecl(const QString &name,
|
||||
const QString &publicId,
|
||||
const QString &systemId)
|
||||
{
|
||||
m_result += nestPrefix();
|
||||
m_result += "externalEntityDecl(name=\"" + escapeStr(name)
|
||||
+ "\", publicId=\"" + escapeStr(publicId)
|
||||
+ "\", systemId=\"" + escapeStr(systemId) + "\")\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
Parser::Parser()
|
||||
{
|
||||
handler = new ContentHandler;
|
||||
setContentHandler(handler);
|
||||
setDTDHandler(handler);
|
||||
setDeclHandler(handler);
|
||||
setEntityResolver(handler);
|
||||
setErrorHandler(handler);
|
||||
setLexicalHandler(handler);
|
||||
}
|
||||
|
||||
Parser::~Parser()
|
||||
{
|
||||
delete handler;
|
||||
}
|
||||
|
||||
bool Parser::parseFile(QFile *file)
|
||||
{
|
||||
QXmlInputSource source(file);
|
||||
return parse(source);
|
||||
}
|
||||
|
||||
QString Parser::result() const
|
||||
{
|
||||
return handler->result();
|
||||
}
|
||||
|
||||
QString Parser::errorMsg() const
|
||||
{
|
||||
return handler->errorMsg();
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
#include <qfile.h>
|
||||
#include <qstring.h>
|
||||
#include <qxml.h>
|
||||
|
||||
class ContentHandler;
|
||||
|
||||
class Parser : public QXmlSimpleReader
|
||||
{
|
||||
public:
|
||||
Parser();
|
||||
~Parser();
|
||||
|
||||
bool parseFile(QFile *file);
|
||||
QString result() const;
|
||||
QString errorMsg() const;
|
||||
|
||||
private:
|
||||
ContentHandler *handler;
|
||||
};
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
QT += xml
|
||||
|
||||
HEADERS += parser.h
|
||||
SOURCES += main.cpp parser.cpp
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
CONFIG += testcase
|
||||
TARGET = tst_qxmlsimplereader
|
||||
INCLUDEPATH += parser
|
||||
|
||||
HEADERS += parser/parser.h
|
||||
SOURCES += tst_qxmlsimplereader.cpp parser/parser.cpp
|
||||
|
||||
CONFIG += no_batch
|
||||
QT = core network xml testlib
|
||||
|
||||
TESTDATA += encodings/* xmldocs/*
|
||||
|
|
@ -1,824 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <qthread.h>
|
||||
#include <qtcpserver.h>
|
||||
#include <qtcpsocket.h>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/qatomic.h>
|
||||
#include <QtCore/qsemaphore.h>
|
||||
#include <qfile.h>
|
||||
#include <qstring.h>
|
||||
#include <qdir.h>
|
||||
#include <qbuffer.h>
|
||||
#include "parser/parser.h"
|
||||
|
||||
static const char *const inputString = "<!DOCTYPE inferno [<!ELEMENT inferno (circle+)><!ELEMENT circle (#PCDATA)>]><inferno><circle /><circle /></inferno>";
|
||||
static const char *const refString = "setDocumentLocator(locator={columnNumber=1, lineNumber=1})\nstartDocument()\nstartDTD(name=\"inferno\", publicId=\"\", systemId=\"\")\nendDTD()\nstartElement(namespaceURI=\"\", localName=\"inferno\", qName=\"inferno\", atts=[])\nstartElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\", atts=[])\nendElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\")\nstartElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\", atts=[])\nendElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\")\nendElement(namespaceURI=\"\", localName=\"inferno\", qName=\"inferno\")\nendDocument()\n";
|
||||
|
||||
#define TEST_PORT 1088
|
||||
|
||||
class XmlServer : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
XmlServer(QObject *parent = 0) : QThread(parent) {}
|
||||
|
||||
QSemaphore threadStarted;
|
||||
bool listening = false;
|
||||
QAtomicInt quitSoon;
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
};
|
||||
|
||||
#define CHUNK_SIZE 2048
|
||||
|
||||
void XmlServer::run()
|
||||
{
|
||||
QTcpServer srv;
|
||||
|
||||
listening = srv.listen(QHostAddress::Any, TEST_PORT);
|
||||
threadStarted.release();
|
||||
|
||||
if (!listening) {
|
||||
qWarning() << "Failed to listen on" << TEST_PORT << srv.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
srv.waitForNewConnection(100);
|
||||
|
||||
if (QTcpSocket *sock = srv.nextPendingConnection()) {
|
||||
QByteArray fileName;
|
||||
for (;;) {
|
||||
char c;
|
||||
if (sock->getChar(&c)) {
|
||||
if (c == '\n')
|
||||
break;
|
||||
fileName.append(c);
|
||||
} else {
|
||||
if (!sock->waitForReadyRead(-1))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QFile file(QString::fromLocal8Bit(fileName));
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "XmlServer::run(): could not open" << fileName;
|
||||
sock->abort();
|
||||
delete sock;
|
||||
continue;
|
||||
}
|
||||
|
||||
QByteArray data = file.readAll();
|
||||
for (int i = 0; i < data.size();) {
|
||||
int cnt = qMin(CHUNK_SIZE, data.size() - i);
|
||||
sock->write(data.constData() + i, cnt);
|
||||
i += cnt;
|
||||
sock->flush();
|
||||
QTest::qSleep(1);
|
||||
|
||||
if (quitSoon.loadAcquire()) {
|
||||
sock->abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sock->disconnectFromHost();
|
||||
delete sock;
|
||||
}
|
||||
|
||||
if (quitSoon.loadAcquire())
|
||||
break;
|
||||
}
|
||||
|
||||
srv.close();
|
||||
}
|
||||
|
||||
class tst_QXmlSimpleReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
public:
|
||||
tst_QXmlSimpleReader();
|
||||
~tst_QXmlSimpleReader();
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testGoodXmlFile();
|
||||
void testGoodXmlFile_data();
|
||||
void testBadXmlFile();
|
||||
void testBadXmlFile_data();
|
||||
void testIncrementalParsing();
|
||||
void testIncrementalParsing_data();
|
||||
void setDataQString();
|
||||
void inputFromQIODevice();
|
||||
void inputFromString();
|
||||
void inputFromSocket_data();
|
||||
void inputFromSocket();
|
||||
|
||||
void idsInParseException1();
|
||||
void idsInParseException2();
|
||||
void preserveCharacterReferences() const;
|
||||
void reportNamespace() const;
|
||||
void reportNamespace_data() const;
|
||||
void roundtripWithNamespaces() const;
|
||||
void dtdRecursionLimit();
|
||||
|
||||
private:
|
||||
static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok);
|
||||
XmlServer *server;
|
||||
QString prefix;
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
};
|
||||
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
|
||||
tst_QXmlSimpleReader::tst_QXmlSimpleReader() : server(new XmlServer(this))
|
||||
{
|
||||
server->start();
|
||||
}
|
||||
|
||||
tst_QXmlSimpleReader::~tst_QXmlSimpleReader()
|
||||
{
|
||||
server->quitSoon.storeRelease(1);
|
||||
server->wait();
|
||||
}
|
||||
|
||||
class MyErrorHandler : public QXmlErrorHandler
|
||||
{
|
||||
public:
|
||||
QString publicId;
|
||||
QString systemId;
|
||||
|
||||
virtual bool error(const QXmlParseException &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual QString errorString() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
virtual bool fatalError(const QXmlParseException &exception)
|
||||
{
|
||||
publicId = exception.publicId();
|
||||
systemId = exception.systemId();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool warning(const QXmlParseException &)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void tst_QXmlSimpleReader::initTestCase()
|
||||
{
|
||||
prefix = QFileInfo(QFINDTESTDATA("xmldocs")).absolutePath();
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("Cannot find xmldocs testdata!");
|
||||
QDir::setCurrent(prefix);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::idsInParseException1()
|
||||
{
|
||||
MyErrorHandler handler;
|
||||
QXmlSimpleReader reader;
|
||||
|
||||
reader.setErrorHandler(&handler);
|
||||
|
||||
/* A non-wellformed XML document with PUBLIC and SYSTEM. */
|
||||
QByteArray input("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
|
||||
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
||||
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"
|
||||
"<head>"
|
||||
"<a/><a/><a/>"
|
||||
"<head/>");
|
||||
|
||||
QBuffer buff(&input);
|
||||
QXmlInputSource source(&buff);
|
||||
|
||||
/* Yes, parsing should be reported as a failure. */
|
||||
QVERIFY(!reader.parse(source));
|
||||
|
||||
QCOMPARE(handler.publicId, QString::fromLatin1("-//W3C//DTD XHTML 1.0 Strict//EN"));
|
||||
QCOMPARE(handler.systemId, QString::fromLatin1("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::idsInParseException2()
|
||||
{
|
||||
MyErrorHandler handler;
|
||||
QXmlSimpleReader reader;
|
||||
|
||||
reader.setErrorHandler(&handler);
|
||||
|
||||
/* A non-wellformed XML document with only SYSTEM. */
|
||||
QByteArray input("<!DOCTYPE html SYSTEM \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
|
||||
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"
|
||||
"<head>"
|
||||
"<a/><a/><a/>"
|
||||
"<head/>");
|
||||
|
||||
QBuffer buff(&input);
|
||||
QXmlInputSource source(&buff);
|
||||
|
||||
/* Yes, parsing should be reported as a failure. */
|
||||
QVERIFY(!reader.parse(source));
|
||||
|
||||
QCOMPARE(handler.publicId, QString());
|
||||
QCOMPARE(handler.systemId, QString::fromLatin1("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
|
||||
}
|
||||
|
||||
static QStringList findXmlFiles(QString dir_name)
|
||||
{
|
||||
QStringList result;
|
||||
|
||||
dir_name = QFINDTESTDATA(dir_name);
|
||||
QDir dir(dir_name);
|
||||
QFileInfoList file_list = dir.entryInfoList(QStringList("*.xml"), QDir::Files, QDir::Name);
|
||||
|
||||
QFileInfoList::const_iterator it = file_list.begin();
|
||||
for (; it != file_list.end(); ++it) {
|
||||
const QFileInfo &file_info = *it;
|
||||
result.append(file_info.filePath());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void tst_QXmlSimpleReader::testGoodXmlFile_data()
|
||||
{
|
||||
const char * const good_data_dirs[] = {
|
||||
"xmldocs/valid/sa",
|
||||
"xmldocs/valid/not-sa",
|
||||
"xmldocs/valid/ext-sa",
|
||||
0
|
||||
};
|
||||
const char * const *d = good_data_dirs;
|
||||
|
||||
QStringList good_file_list;
|
||||
for (; *d != 0; ++d)
|
||||
good_file_list += findXmlFiles(*d);
|
||||
|
||||
QTest::addColumn<QString>("file_name");
|
||||
QStringList::const_iterator it = good_file_list.begin();
|
||||
for (; it != good_file_list.end(); ++it)
|
||||
QTest::newRow((*it).toLatin1()) << *it;
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::testGoodXmlFile()
|
||||
{
|
||||
QFETCH(QString, file_name);
|
||||
QFile file(file_name);
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QString content = file.readAll();
|
||||
file.close();
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
Parser parser;
|
||||
|
||||
QVERIFY(parser.parseFile(&file));
|
||||
|
||||
QFile ref_file(file_name + ".ref");
|
||||
QVERIFY(ref_file.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||
QByteArray data = ref_file.readAll();
|
||||
QString ref_file_contents = QString::fromUtf8(data.constData(), data.size());
|
||||
|
||||
QCOMPARE(parser.result(), ref_file_contents);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::testBadXmlFile_data()
|
||||
{
|
||||
const char * const bad_data_dirs[] = {
|
||||
"xmldocs/not-wf/sa",
|
||||
0
|
||||
};
|
||||
const char * const *d = bad_data_dirs;
|
||||
|
||||
QStringList bad_file_list;
|
||||
for (; *d != 0; ++d)
|
||||
bad_file_list += findXmlFiles(*d);
|
||||
|
||||
QTest::addColumn<QString>("file_name");
|
||||
QStringList::const_iterator it = bad_file_list.begin();
|
||||
for (; it != bad_file_list.end(); ++it)
|
||||
QTest::newRow((*it).toLatin1()) << *it;
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::testBadXmlFile()
|
||||
{
|
||||
QFETCH(QString, file_name);
|
||||
QFile file(file_name);
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
Parser parser;
|
||||
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/030.xml").toLocal8Bit().constData(), "a form feed character is not accepted in XML", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/031.xml").toLocal8Bit().constData(), "a form feed character is not accepted in a processing instruction", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/032.xml").toLocal8Bit().constData(), "a form feed character is not accepted in a comment", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/033.xml").toLocal8Bit().constData(), "overlong sequence - small latin letter d should be rejected", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/038.xml").toLocal8Bit().constData(), "attribute x redefined; should be rejected", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/072.xml").toLocal8Bit().constData(), "entity foo not defined", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/073.xml").toLocal8Bit().constData(), "entity f not defined", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/074.xml").toLocal8Bit().constData(), "entity e is not well-formed (</foo><foo>)", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/076.xml").toLocal8Bit().constData(), "entity foo is not defined", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/077.xml").toLocal8Bit().constData(), "entity bar is not defined within the definition of entity foo", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/078.xml").toLocal8Bit().constData(), "entity foo not defined", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/085.xml").toLocal8Bit().constData(), "Unfinished Public or System Id", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/086.xml").toLocal8Bit().constData(), "Unfinished Public or System Id", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/087.xml").toLocal8Bit().constData(), "Unfinished Public or System Id", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/101.xml").toLocal8Bit().constData(), "Invalid XML encoding name (space before utf-8)", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/102.xml").toLocal8Bit().constData(), "Invalid version specification (1.0 followed by space)", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/104.xml").toLocal8Bit().constData(), "Premature end of data in tag foo", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/116.xml").toLocal8Bit().constData(), "Invalid decimal value", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/117.xml").toLocal8Bit().constData(), "No name", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/119.xml").toLocal8Bit().constData(), "No name", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/122.xml").toLocal8Bit().constData(), "; expected in declaration of element", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/132.xml").toLocal8Bit().constData(), "; expected in declaration of element", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/142.xml").toLocal8Bit().constData(), "Invalid value '0'", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/143.xml").toLocal8Bit().constData(), "Invalid value '31'", Continue);
|
||||
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/144.xml").toLocal8Bit().constData(), "noncharacter code 0xFFFF should be rejected", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/145.xml").toLocal8Bit().constData(), "surrogate code point 0xD800 should be rejected", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/146.xml").toLocal8Bit().constData(), "code point out-of-range 0x110000 (must be < 0x10FFFE)", Abort);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/160.xml").toLocal8Bit().constData(), "Parameter references forbidden in internal subset", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/162.xml").toLocal8Bit().constData(), "Parameter references forbidden in internal subset", Continue);
|
||||
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/168.xml").toLocal8Bit().constData(), "Surrogate code point 0xEDA080 should be rejected", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/169.xml").toLocal8Bit().constData(), "Surrogate code point 0xEDB080 should be rejected", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/170.xml").toLocal8Bit().constData(), "Code point 0xF7808080 should be rejected", Continue);
|
||||
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/180.xml").toLocal8Bit().constData(), "Entity e is not defined", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/181.xml").toLocal8Bit().constData(), "Unregistered error message", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/182.xml").toLocal8Bit().constData(), "Comment not terminated", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/185.xml").toLocal8Bit().constData(), "Entity e not defined", Continue);
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/186.xml").toLocal8Bit().constData(), "Attributes constructs error", Continue);
|
||||
|
||||
QVERIFY(!parser.parseFile(&file));
|
||||
|
||||
QFile ref_file(file_name + ".ref");
|
||||
QVERIFY(ref_file.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||
QString ref_file_contents = QString::fromUtf8(ref_file.readAll());
|
||||
|
||||
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/145.xml").toLocal8Bit().constData(), "Surrogate code point 0xD800 should be rejected", Continue);
|
||||
|
||||
QCOMPARE(parser.result(), ref_file_contents);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::testIncrementalParsing_data()
|
||||
{
|
||||
QTest::addColumn<QString>("file_name");
|
||||
QTest::addColumn<int>("chunkSize");
|
||||
|
||||
const char * const good_data_dirs[] = {
|
||||
"xmldocs/valid/sa",
|
||||
"xmldocs/valid/not-sa",
|
||||
"xmldocs/valid/ext-sa",
|
||||
0
|
||||
};
|
||||
const char * const *d = good_data_dirs;
|
||||
|
||||
QStringList good_file_list;
|
||||
for (; *d != 0; ++d)
|
||||
good_file_list += findXmlFiles(*d);
|
||||
|
||||
for (int i=1; i<10; ++i) {
|
||||
QStringList::const_iterator it = good_file_list.begin();
|
||||
const QString skip49 = QFINDTESTDATA("xmldocs/valid/sa/049.xml");
|
||||
const QString skip50 = QFINDTESTDATA("xmldocs/valid/sa/050.xml");
|
||||
const QString skip51 = QFINDTESTDATA("xmldocs/valid/sa/051.xml");
|
||||
const QString skip52 = QFINDTESTDATA("xmldocs/valid/sa/052.xml");
|
||||
const QString skip89 = QFINDTESTDATA("xmldocs/valid/sa/089.xml");
|
||||
|
||||
for (; it != good_file_list.end(); ++it) {
|
||||
if ( *it == skip89 )
|
||||
continue;// TODO: fails at the moment -- don't bother
|
||||
if ( i==1 && (
|
||||
*it == skip49 ||
|
||||
*it == skip50 ||
|
||||
*it == skip51 ||
|
||||
*it == skip52 ) ) {
|
||||
continue; // TODO: fails at the moment -- don't bother
|
||||
}
|
||||
QTest::newRow(QString("%1 %2").arg(*it).arg(i).toLatin1()) << *it << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::testIncrementalParsing()
|
||||
{
|
||||
QFETCH(QString, file_name);
|
||||
QFETCH(int, chunkSize);
|
||||
|
||||
QFile file(file_name);
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
|
||||
Parser parser;
|
||||
QXmlInputSource source;
|
||||
bool first = true;
|
||||
while (!file.atEnd()) {
|
||||
source.setData(file.read(chunkSize));
|
||||
if(first) {
|
||||
QVERIFY(parser.parse(&source, true));
|
||||
first = false;
|
||||
} else {
|
||||
QVERIFY(parser.parseContinue());
|
||||
}
|
||||
}
|
||||
// detect end of document
|
||||
QVERIFY(parser.parseContinue());
|
||||
// parsing should fail after the end of the document was reached
|
||||
QVERIFY(!parser.parseContinue());
|
||||
|
||||
QFile ref_file(file_name + ".ref");
|
||||
QVERIFY(ref_file.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||
QString ref_file_contents = QString::fromUtf8(ref_file.readAll());
|
||||
|
||||
QCOMPARE(parser.result(), ref_file_contents);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::setDataQString()
|
||||
{
|
||||
QString input = inputString;
|
||||
QString ref = refString;
|
||||
|
||||
QXmlInputSource source;
|
||||
Parser parser;
|
||||
|
||||
source.setData(input);
|
||||
QVERIFY(parser.parse(&source,false));
|
||||
|
||||
QBuffer resultBuffer;
|
||||
resultBuffer.setData(parser.result().toLatin1());
|
||||
|
||||
QBuffer refBuffer;
|
||||
refBuffer.setData(ref.toLatin1());
|
||||
|
||||
resultBuffer.open(QIODevice::ReadOnly);
|
||||
refBuffer.open(QIODevice::ReadOnly);
|
||||
|
||||
bool success = true;
|
||||
while (resultBuffer.canReadLine()) {
|
||||
if (!refBuffer.canReadLine()) {
|
||||
success = false; break ;
|
||||
}
|
||||
if (resultBuffer.readLine().simplified() != refBuffer.readLine().simplified()) {
|
||||
success = false; break ;
|
||||
}
|
||||
}
|
||||
QVERIFY(success);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::inputFromQIODevice()
|
||||
{
|
||||
QBuffer inputBuffer;
|
||||
inputBuffer.setData(inputString);
|
||||
|
||||
QXmlInputSource source(&inputBuffer);
|
||||
Parser parser;
|
||||
|
||||
QVERIFY(parser.parse(&source,false));
|
||||
|
||||
QBuffer resultBuffer;
|
||||
resultBuffer.setData(parser.result().toLatin1());
|
||||
|
||||
QBuffer refBuffer;
|
||||
refBuffer.setData(refString);
|
||||
|
||||
resultBuffer.open(QIODevice::ReadOnly);
|
||||
refBuffer.open(QIODevice::ReadOnly);
|
||||
|
||||
bool success = true;
|
||||
while (resultBuffer.canReadLine()) {
|
||||
if (!refBuffer.canReadLine()) {
|
||||
success = false; break ;
|
||||
}
|
||||
if (resultBuffer.readLine().simplified() != refBuffer.readLine().simplified()) {
|
||||
success = false; break ;
|
||||
}
|
||||
}
|
||||
QVERIFY(success);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::inputFromString()
|
||||
{
|
||||
QString str = "<foo><bar>kake</bar><bar>ja</bar></foo>";
|
||||
QBuffer buff;
|
||||
buff.setData((char*)str.utf16(), str.size()*sizeof(ushort));
|
||||
|
||||
QXmlInputSource input(&buff);
|
||||
|
||||
QXmlSimpleReader reader;
|
||||
QXmlDefaultHandler handler;
|
||||
reader.setContentHandler(&handler);
|
||||
|
||||
QVERIFY(reader.parse(&input));
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::inputFromSocket_data()
|
||||
{
|
||||
QStringList files = findXmlFiles(QLatin1String("encodings"));
|
||||
QVERIFY(files.count() > 0);
|
||||
|
||||
QTest::addColumn<QString>("file_name");
|
||||
|
||||
foreach (const QString &file_name, files)
|
||||
QTest::newRow(file_name.toLatin1()) << file_name;
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::inputFromSocket()
|
||||
{
|
||||
QFETCH(QString, file_name);
|
||||
|
||||
if (!server->threadStarted.tryAcquire(1, 15000)) {
|
||||
// If something is wrong with QThreads, it's not a reason to fail
|
||||
// XML-test, we are not testing QThread here after all!
|
||||
QSKIP("XmlServer/thread has not started yet");
|
||||
}
|
||||
|
||||
// Subsequent runs should be able to acquire the semaphore.
|
||||
server->threadStarted.release(1);
|
||||
|
||||
if (!server->listening) {
|
||||
// Again, QTcpServer is not the subject of this test!
|
||||
QSKIP("QTcpServer::listen failed, bailing out");
|
||||
}
|
||||
|
||||
QTcpSocket sock;
|
||||
sock.connectToHost(QHostAddress::LocalHost, TEST_PORT);
|
||||
QVERIFY2(sock.waitForConnected(),
|
||||
qPrintable(QStringLiteral("Cannot connect on port ") + QString::number(TEST_PORT)
|
||||
+ QStringLiteral(": ") + sock.errorString()));
|
||||
|
||||
sock.write(file_name.toLocal8Bit() + "\n");
|
||||
QVERIFY(sock.waitForBytesWritten());
|
||||
|
||||
QXmlInputSource input(&sock);
|
||||
|
||||
QXmlSimpleReader reader;
|
||||
QXmlDefaultHandler handler;
|
||||
reader.setContentHandler(&handler);
|
||||
|
||||
QVERIFY(reader.parse(&input));
|
||||
|
||||
// qDebug() << "tst_QXmlSimpleReader::inputFromSocket(): success" << file_name;
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::preserveCharacterReferences() const
|
||||
{
|
||||
class Handler : public QXmlDefaultHandler
|
||||
{
|
||||
public:
|
||||
virtual bool characters(const QString &chars)
|
||||
{
|
||||
received = chars;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString received;
|
||||
};
|
||||
|
||||
{
|
||||
QByteArray input("<e>A    A</e>");
|
||||
|
||||
QBuffer buff(&input);
|
||||
QXmlInputSource source(&buff);
|
||||
|
||||
Handler h;
|
||||
QXmlSimpleReader reader;
|
||||
reader.setContentHandler(&h);
|
||||
QVERIFY(reader.parse(&source, false));
|
||||
|
||||
QCOMPARE(h.received, QLatin1Char('A') + QString(4, QChar(160)) + QLatin1Char('A'));
|
||||
}
|
||||
|
||||
{
|
||||
QByteArray input("<e>    </e>");
|
||||
|
||||
QBuffer buff(&input);
|
||||
QXmlInputSource source(&buff);
|
||||
|
||||
Handler h;
|
||||
QXmlSimpleReader reader;
|
||||
reader.setContentHandler(&h);
|
||||
QVERIFY(reader.parse(&source, false));
|
||||
|
||||
QCOMPARE(h.received, QString(4, QChar(160)));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::reportNamespace() const
|
||||
{
|
||||
class Handler : public QXmlDefaultHandler
|
||||
{
|
||||
public:
|
||||
virtual bool startElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName,
|
||||
const QXmlAttributes &)
|
||||
{
|
||||
startNamespaceURI = namespaceURI;
|
||||
startLocalName = localName;
|
||||
startQName = qName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool endElement(const QString &namespaceURI,
|
||||
const QString &localName,
|
||||
const QString &qName)
|
||||
{
|
||||
endNamespaceURI = namespaceURI;
|
||||
endLocalName = localName;
|
||||
endQName = qName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString startLocalName;
|
||||
QString startQName;
|
||||
QString startNamespaceURI;
|
||||
QString endLocalName;
|
||||
QString endQName;
|
||||
QString endNamespaceURI;
|
||||
};
|
||||
|
||||
QXmlSimpleReader reader;
|
||||
Handler handler;
|
||||
reader.setContentHandler(&handler);
|
||||
|
||||
QFETCH(QByteArray, input);
|
||||
|
||||
QBuffer buffer(&input);
|
||||
QVERIFY(buffer.open(QIODevice::ReadOnly));
|
||||
|
||||
QXmlInputSource source(&buffer);
|
||||
QVERIFY(reader.parse(source));
|
||||
|
||||
QFETCH(QString, expectedQName);
|
||||
QFETCH(QString, expectedLocalName);
|
||||
QFETCH(QString, expectedNamespace);
|
||||
|
||||
QCOMPARE(handler.startNamespaceURI, expectedNamespace);
|
||||
QCOMPARE(handler.startLocalName, expectedLocalName);
|
||||
QCOMPARE(handler.startQName, expectedQName);
|
||||
|
||||
QCOMPARE(handler.endNamespaceURI, expectedNamespace);
|
||||
QCOMPARE(handler.endLocalName, expectedLocalName);
|
||||
QCOMPARE(handler.endQName, expectedQName);
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::reportNamespace_data() const
|
||||
{
|
||||
QTest::addColumn<QByteArray>("input");
|
||||
QTest::addColumn<QString>("expectedQName");
|
||||
QTest::addColumn<QString>("expectedLocalName");
|
||||
QTest::addColumn<QString>("expectedNamespace");
|
||||
|
||||
QTest::newRow("default ns") << QByteArray("<element xmlns='http://example.com/'/>")
|
||||
<< QString("element")
|
||||
<< QString("element")
|
||||
<< QString("http://example.com/");
|
||||
|
||||
QTest::newRow("with prefix") << QByteArray("<p:element xmlns:p='http://example.com/'/>")
|
||||
<< QString("p:element")
|
||||
<< QString("element")
|
||||
<< QString("http://example.com/");
|
||||
}
|
||||
|
||||
QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba, bool *ok)
|
||||
{
|
||||
QDomDocument doc(title);
|
||||
*ok = doc.setContent(ba, true);
|
||||
return doc;
|
||||
}
|
||||
|
||||
void tst_QXmlSimpleReader::roundtripWithNamespaces() const
|
||||
{
|
||||
const char *const expected = "<element b:attr=\"value\" xmlns:a=\"http://www.example.com/A\" xmlns:b=\"http://www.example.com/B\" />\n";
|
||||
bool ok;
|
||||
|
||||
{
|
||||
const char *const xml = "<element xmlns:b=\"http://www.example.com/B\" b:attr=\"value\" xmlns:a=\"http://www.example.com/A\"/>";
|
||||
|
||||
const QDomDocument one(fromByteArray("document", xml, &ok));
|
||||
QVERIFY(ok);
|
||||
const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok));
|
||||
QVERIFY(ok);
|
||||
|
||||
QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort);
|
||||
|
||||
QCOMPARE(expected, one.toByteArray().constData());
|
||||
QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData());
|
||||
QCOMPARE(two.toByteArray(2).constData(), two.toByteArray(2).constData());
|
||||
}
|
||||
|
||||
{
|
||||
const char *const xml = "<element b:attr=\"value\" xmlns:b=\"http://www.example.com/B\" xmlns:a=\"http://www.example.com/A\"/>";
|
||||
|
||||
const QDomDocument one(fromByteArray("document", xml, &ok));
|
||||
QVERIFY(ok);
|
||||
const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok));
|
||||
QVERIFY(ok);
|
||||
|
||||
QCOMPARE(expected, one.toByteArray().constData());
|
||||
QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData());
|
||||
QCOMPARE(two.toByteArray(2).constData(), two.toByteArray(2).constData());
|
||||
}
|
||||
}
|
||||
|
||||
class TestHandler : public QXmlDefaultHandler
|
||||
{
|
||||
public:
|
||||
TestHandler() :
|
||||
recursionCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool internalEntityDecl(const QString &name, const QString &value)
|
||||
{
|
||||
++recursionCount;
|
||||
return QXmlDefaultHandler::internalEntityDecl(name, value);
|
||||
}
|
||||
|
||||
int recursionCount;
|
||||
};
|
||||
|
||||
void tst_QXmlSimpleReader::dtdRecursionLimit()
|
||||
{
|
||||
QFile file(QFINDTESTDATA("xmldocs/2-levels-nested-dtd.xml"));
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
QXmlSimpleReader xmlReader;
|
||||
{
|
||||
QXmlInputSource source(&file);
|
||||
TestHandler handler;
|
||||
xmlReader.setDeclHandler(&handler);
|
||||
xmlReader.setErrorHandler(&handler);
|
||||
QVERIFY(!xmlReader.parse(&source));
|
||||
}
|
||||
|
||||
file.close();
|
||||
file.setFileName(QFINDTESTDATA("xmldocs/1-levels-nested-dtd.xml"));
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
{
|
||||
QXmlInputSource source(&file);
|
||||
TestHandler handler;
|
||||
xmlReader.setDeclHandler(&handler);
|
||||
xmlReader.setErrorHandler(&handler);
|
||||
QVERIFY(!xmlReader.parse(&source));
|
||||
// The error wasn't because of the recursion limit being reached,
|
||||
// it was because the document is not valid.
|
||||
QVERIFY(handler.recursionCount < 2);
|
||||
}
|
||||
|
||||
file.close();
|
||||
file.setFileName(QFINDTESTDATA("xmldocs/internal-entity-polynomial-attribute.xml"));
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
{
|
||||
QXmlInputSource source(&file);
|
||||
TestHandler handler;
|
||||
xmlReader.setDeclHandler(&handler);
|
||||
xmlReader.setErrorHandler(&handler);
|
||||
QVERIFY(!xmlReader.parse(&source));
|
||||
QCOMPARE(handler.recursionCount, 2);
|
||||
}
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
QTEST_MAIN(tst_QXmlSimpleReader)
|
||||
#include "tst_qxmlsimplereader.moc"
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- Test non-deterministic content model matching.
|
||||
|
||||
Entity references are not part of the internal DTD subset (for good reason).
|
||||
|
||||
-->
|
||||
<!DOCTYPE root [
|
||||
<!ELEMENT e0 EMPTY>
|
||||
<!ENTITY % e1 "(e0,e0)">
|
||||
<!ELEMENT root (%e1;)?>
|
||||
]>
|
||||
<root/>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- Test non-deterministic content model matching.
|
||||
|
||||
Entity references are not part of the internal DTD subset (for good reason).
|
||||
|
||||
-->
|
||||
<!DOCTYPE root [
|
||||
<!ELEMENT e0 EMPTY>
|
||||
<!ENTITY % e1 "(e0,e0)">
|
||||
<!ENTITY % e2 "(%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;,%e1;)">
|
||||
<!ELEMENT root (%e2;)?>
|
||||
]>
|
||||
<root/>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- Test polynomial growth of expanded XML.
|
||||
Expansion happens in an attribute. -->
|
||||
<!DOCTYPE root [
|
||||
<!ELEMENT root EMPTY>
|
||||
<!ATTLIST root id CDATA #IMPLIED>
|
||||
<!ENTITY e1 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
|
||||
<!ENTITY e2 "&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;&e1;">
|
||||
<!ENTITY e3 "&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;&e2;">
|
||||
<!ENTITY e4 "&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;&e3;">
|
||||
]>
|
||||
<root id="&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;&e4;"/>
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<doc>
|
||||
<doc
|
||||
?
|
||||
<a</a>
|
||||
</doc>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
characters(ch="\r\n")
|
||||
fatalError(exception={columnNumber=1, lineNumber=3, publicId="", systemId="", message="error occurred while parsing element"})
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<doc>
|
||||
<.doc></.doc>
|
||||
</doc>
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
characters(ch="\r\n")
|
||||
fatalError(exception={columnNumber=2, lineNumber=2, publicId="", systemId="", message="error occurred while parsing element"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc><? ?></doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=8, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc><?target some data></doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=1, lineNumber=2, publicId="", systemId="", message="unexpected end of file"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc><?target some data?</doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=1, lineNumber=2, publicId="", systemId="", message="unexpected end of file"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc><!-- a comment -- another --></doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=23, lineNumber=1, publicId="", systemId="", message="error occurred while parsing comment"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>& no refc</doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=10, lineNumber=1, publicId="", systemId="", message="error occurred while parsing reference"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>&.entity;</doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=7, lineNumber=1, publicId="", systemId="", message="letter is expected"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>&#RE;</doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=8, lineNumber=1, publicId="", systemId="", message="error occurred while parsing reference"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>A & B</doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=9, lineNumber=1, publicId="", systemId="", message="letter is expected"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=8, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1=v1></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=9, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1="v1'></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=14, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1="<foo>"></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=10, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1=></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=9, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1="v1" "v2"></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=14, lineNumber=1, publicId="", systemId="", message="error occurred while parsing element"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc><![CDATA[</doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=1, lineNumber=2, publicId="", systemId="", message="unexpected end of file"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc><![CDATA [ stuff]]></doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=14, lineNumber=1, publicId="", systemId="", message="unexpected character"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc></>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=8, lineNumber=1, publicId="", systemId="", message="error occurred while parsing element"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1="A & B"></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=13, lineNumber=1, publicId="", systemId="", message="letter is expected"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1="a&b"></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=13, lineNumber=1, publicId="", systemId="", message="error occurred while parsing reference"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc a1="{:"></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=15, lineNumber=1, publicId="", systemId="", message="error occurred while parsing reference"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc 12="34"></doc>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
fatalError(exception={columnNumber=6, lineNumber=1, publicId="", systemId="", message="error occurred while parsing element"})
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<doc>
|
||||
<123></123>
|
||||
</doc>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
characters(ch="\r\n")
|
||||
fatalError(exception={columnNumber=2, lineNumber=2, publicId="", systemId="", message="error occurred while parsing element"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>]]></doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=8, lineNumber=1, publicId="", systemId="", message="error occurred while parsing content"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>]]]></doc>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
fatalError(exception={columnNumber=9, lineNumber=1, publicId="", systemId="", message="error occurred while parsing content"})
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<doc>
|
||||
<!-- abc
|
||||
</doc>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
characters(ch="\r\n")
|
||||
fatalError(exception={columnNumber=1, lineNumber=4, publicId="", systemId="", message="unexpected end of file"})
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<doc>
|
||||
<?a pi that is not closed
|
||||
</doc>
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
setDocumentLocator(locator={columnNumber=1, lineNumber=1})
|
||||
startDocument()
|
||||
startElement(namespaceURI="", localName="doc", qName="doc", atts=[])
|
||||
characters(ch="\r\n")
|
||||
fatalError(exception={columnNumber=1, lineNumber=5, publicId="", systemId="", message="unexpected end of file"})
|
||||
|
|
@ -1 +0,0 @@
|
|||
<doc>abc]]]>def</doc>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue