summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/auto/xmlpatternssdk/TestBaseLine.cpp16
-rw-r--r--tests/auto/xmlpatternssdk/TestCase.cpp20
-rw-r--r--tests/auto/xmlpatternssdk/TestResult.cpp8
-rw-r--r--tests/auto/xmlpatternssdk/TestSuite.cpp32
-rw-r--r--tests/auto/xmlpatternssdk/TestSuiteResult.cpp31
-rw-r--r--tests/auto/xmlpatternssdk/XMLWriter.cpp47
-rw-r--r--tests/auto/xmlpatternssdk/XMLWriter.h84
7 files changed, 54 insertions, 184 deletions
diff --git a/tests/auto/xmlpatternssdk/TestBaseLine.cpp b/tests/auto/xmlpatternssdk/TestBaseLine.cpp
index 78232cd..f8ad128 100644
--- a/tests/auto/xmlpatternssdk/TestBaseLine.cpp
+++ b/tests/auto/xmlpatternssdk/TestBaseLine.cpp
@@ -127,11 +127,9 @@ void TestBaseLine::toXML(XMLWriter &receiver) const
case SchemaIsValid: /* Fallthrough. */
case Text:
{
- QXmlAttributes inspectAtts;
- inspectAtts.append(QLatin1String("role"), QString(),
- QLatin1String("role"), QLatin1String("principal"));
- inspectAtts.append(QLatin1String("compare"), QString(),
- QLatin1String("compare"), displayName(m_type));
+ QXmlStreamAttributes inspectAtts;
+ inspectAtts.append(QLatin1String("role"), QLatin1String("principal"));
+ inspectAtts.append(QLatin1String("compare"), displayName(m_type));
receiver.startElement(QLatin1String("output-file"), inspectAtts);
receiver.characters(m_details);
receiver.endElement(QLatin1String("output-file"));
@@ -144,11 +142,9 @@ void TestBaseLine::toXML(XMLWriter &receiver) const
}
case Inspect:
{
- QXmlAttributes inspectAtts;
- inspectAtts.append(QLatin1String("role"), QString(),
- QLatin1String("role"), QLatin1String("principal"));
- inspectAtts.append(QLatin1String("compare"), QString(),
- QLatin1String("compare"), QLatin1String("Inspect"));
+ QXmlStreamAttributes inspectAtts;
+ inspectAtts.append(QLatin1String("role"), QLatin1String("principal"));
+ inspectAtts.append(QLatin1String("compare"), QLatin1String("Inspect"));
receiver.startElement(QLatin1String("output-file"), inspectAtts);
receiver.characters(m_details);
receiver.endElement(QLatin1String("output-file"));
diff --git a/tests/auto/xmlpatternssdk/TestCase.cpp b/tests/auto/xmlpatternssdk/TestCase.cpp
index bf9241c..6827f36 100644
--- a/tests/auto/xmlpatternssdk/TestCase.cpp
+++ b/tests/auto/xmlpatternssdk/TestCase.cpp
@@ -336,12 +336,11 @@ TestCase::Scenario TestCase::scenarioFromString(const QString &string)
void TestCase::toXML(XMLWriter &receiver) const
{
/* <test-case> */
- QXmlAttributes test_caseAtts;
- test_caseAtts.append(QLatin1String("is-XPath2"), QString(),
- QLatin1String("is-XPath2"), isXPath() ? QLatin1String("true")
+ QXmlStreamAttributes test_caseAtts;
+ test_caseAtts.append(QLatin1String("is-XPath2"), isXPath() ? QLatin1String("true")
: QLatin1String("false"));
- test_caseAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), name());
- test_caseAtts.append(QLatin1String("creator"), QString(), QLatin1String("creator"), creator());
+ test_caseAtts.append(QLatin1String("name"), name());
+ test_caseAtts.append(QLatin1String("creator"), creator());
QString scen;
switch(scenario())
{
@@ -368,9 +367,8 @@ void TestCase::toXML(XMLWriter &receiver) const
default: /* includes 'AnyError' */
Q_ASSERT(false);
}
- test_caseAtts.append(QLatin1String("scenario"), QString(), QLatin1String("scenario"), scen);
- test_caseAtts.append(QLatin1String(QLatin1String("FilePath")), QString(),
- QLatin1String("FilePath"), QString());
+ test_caseAtts.append(QLatin1String("scenario"), scen);
+ test_caseAtts.append(QLatin1String("FilePath"), QString());
receiver.startElement(QLatin1String("test-case"), test_caseAtts);
/* <description> */
@@ -381,10 +379,10 @@ void TestCase::toXML(XMLWriter &receiver) const
receiver.endElement(QLatin1String("description"));
/* <query> */
- QXmlAttributes queryAtts;
- queryAtts.append(QLatin1String("date"), QString(), QLatin1String("date"), /* This date is a dummy. */
+ QXmlStreamAttributes queryAtts;
+ queryAtts.append(QLatin1String("date"), /* This date is a dummy. */
QDate::currentDate().toString(Qt::ISODate));
- queryAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), testCasePath().toString());
+ queryAtts.append(QLatin1String("name"), testCasePath().toString());
receiver.startElement(QLatin1String("query"), queryAtts);
/* </query> */
diff --git a/tests/auto/xmlpatternssdk/TestResult.cpp b/tests/auto/xmlpatternssdk/TestResult.cpp
index 5629971..5599ab4 100644
--- a/tests/auto/xmlpatternssdk/TestResult.cpp
+++ b/tests/auto/xmlpatternssdk/TestResult.cpp
@@ -94,12 +94,12 @@ TestResult::~TestResult()
void TestResult::toXML(XMLWriter &receiver) const
{
- QXmlAttributes atts;
- atts.append(QLatin1String("name"), QString(), QLatin1String("name"), m_testName);
- atts.append(QLatin1String("result"), QString(), QLatin1String("result"), displayName(m_status));
+ QXmlStreamAttributes atts;
+ atts.append(QLatin1String("name"), m_testName);
+ atts.append(QLatin1String("result"), displayName(m_status));
if(!m_comment.isEmpty())
- atts.append(QLatin1String("comment"), QString(), QLatin1String("comment"), m_comment);
+ atts.append(QLatin1String("comment"), m_comment);
receiver.startElement(QLatin1String("test-case"), atts);
receiver.endElement(QLatin1String("test-case"));
diff --git a/tests/auto/xmlpatternssdk/TestSuite.cpp b/tests/auto/xmlpatternssdk/TestSuite.cpp
index 973fe40..c729837 100644
--- a/tests/auto/xmlpatternssdk/TestSuite.cpp
+++ b/tests/auto/xmlpatternssdk/TestSuite.cpp
@@ -164,32 +164,22 @@ void TestSuite::toXML(XMLWriter &receiver, TestCase *const tc) const
receiver.startDocument();
/* <test-suite> */
- QXmlAttributes test_suiteAtts;
- test_suiteAtts.append(QLatin1String("CatalogDesignDate"), QString(),
- QLatin1String("CatalogDesignDate"), m_designDate.toString(Qt::ISODate));
- test_suiteAtts.append(QLatin1String("version"), QString(),
- QLatin1String("version"), m_version);
- test_suiteAtts.append(QLatin1String("SourceOffsetPath"), QString(),
- QLatin1String("SourceOffsetPath"), QString());
- test_suiteAtts.append(QLatin1String("ResultOffsetPath"), QString(),
- QLatin1String("ResultOffsetPath"), QString());
- test_suiteAtts.append(QLatin1String("XQueryQueryOffsetPath"), QString(),
- QLatin1String("XQueryQueryOffsetPath"), QString());
- test_suiteAtts.append(QLatin1String("QueryXQueryOffsetPath"), QString(),
- QLatin1String("QueryXQueryOffsetPath"), QString());
- test_suiteAtts.append(QLatin1String("XQueryFileExtension"), QString(),
- QLatin1String("XQueryFileExtension"), QString());
- test_suiteAtts.append(QLatin1String("XQueryXFileExtension"), QString(),
- QLatin1String("XQueryXFileExtension"), QString());
+ QXmlStreamAttributes test_suiteAtts;
+ test_suiteAtts.append(QLatin1String("CatalogDesignDate"), m_designDate.toString(Qt::ISODate));
+ test_suiteAtts.append(QLatin1String("version"), m_version);
+ test_suiteAtts.append(QLatin1String("SourceOffsetPath"), QString());
+ test_suiteAtts.append(QLatin1String("ResultOffsetPath"), QString());
+ test_suiteAtts.append(QLatin1String("XQueryQueryOffsetPath"), QString());
+ test_suiteAtts.append(QLatin1String("QueryXQueryOffsetPath"), QString());
+ test_suiteAtts.append(QLatin1String("XQueryFileExtension"), QString());
+ test_suiteAtts.append(QLatin1String("XQueryXFileExtension"), QString());
receiver.startPrefixMapping(QString(), Global::xqtsCatalogNS);
receiver.startElement(QLatin1String("test-suite"), test_suiteAtts);
- receiver.endPrefixMapping(QString());
/* <test-group> */
- QXmlAttributes test_groupAtts;
- test_groupAtts.append(QLatin1String("GeneratedGroupByPatternistSDKRunSuite"), QString(),
- QLatin1String("GeneratedGroupByPatternistSDKRunSuite"), QString());
+ QXmlStreamAttributes test_groupAtts;
+ test_groupAtts.append(QLatin1String("GeneratedGroupByPatternistSDKRunSuite"), QString());
receiver.startElement(QLatin1String("test-group"), test_groupAtts);
/* <GroupInfo> */
diff --git a/tests/auto/xmlpatternssdk/TestSuiteResult.cpp b/tests/auto/xmlpatternssdk/TestSuiteResult.cpp
index 39508a4..b5a0ee7 100644
--- a/tests/auto/xmlpatternssdk/TestSuiteResult.cpp
+++ b/tests/auto/xmlpatternssdk/TestSuiteResult.cpp
@@ -76,31 +76,26 @@ void TestSuiteResult::toXML(XMLWriter &receiver) const
/* <test-suite-result> */
receiver.startPrefixMapping(QString(), Global::xqtsResultNS);
receiver.startElement(QLatin1String("test-suite-result"));
- receiver.endPrefixMapping(QString());
/* <implementation> */
- QXmlAttributes implementationAtts;
- implementationAtts.append(QLatin1String("name"), QString(),
- QLatin1String("name"), implementationName);
- implementationAtts.append(QLatin1String("version"), QString(),
- QLatin1String("version"), implementationVersion);
+ QXmlStreamAttributes implementationAtts;
+ implementationAtts.append(QLatin1String("name"), implementationName);
+ implementationAtts.append(QLatin1String("version"), implementationVersion);
receiver.startElement(QLatin1String("implementation"), implementationAtts);
/* <organization> */
- QXmlAttributes organizationAtts;
- organizationAtts.append(QLatin1String("name"), QString(),
- QLatin1String("name"), organizationName);
- organizationAtts.append(QLatin1String("website"), QString(),
- QLatin1String("website"), organizationWebsite);
+ QXmlStreamAttributes organizationAtts;
+ organizationAtts.append(QLatin1String("name"), organizationName);
+ organizationAtts.append(QLatin1String("website"), organizationWebsite);
receiver.startElement(QLatin1String("organization"), organizationAtts);
/* </organization> */
receiver.endElement(QLatin1String("organization"));
/* <submittor> */
- QXmlAttributes submittorAtts;
- submittorAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), submittorName);
- submittorAtts.append(QLatin1String("email"), QString(), QLatin1String("email"), submittorEmail);
+ QXmlStreamAttributes submittorAtts;
+ submittorAtts.append(QLatin1String("name"), submittorName);
+ submittorAtts.append(QLatin1String("email"), submittorEmail);
receiver.startElement(QLatin1String("submittor"), submittorAtts);
/* </submittor> */
@@ -129,13 +124,13 @@ void TestSuiteResult::toXML(XMLWriter &receiver) const
receiver.endElement(QLatin1String("syntax"));
/* <test-run> */
- QXmlAttributes test_runAtts;
- test_runAtts.append(QLatin1String("dateRun"), QString(), QLatin1String("dateRun"), m_runDate.toString(QLatin1String("yyyy-MM-dd")));
+ QXmlStreamAttributes test_runAtts;
+ test_runAtts.append(QLatin1String("dateRun"), m_runDate.toString(Qt::ISODate));
receiver.startElement(QLatin1String("test-run"), test_runAtts);
/* <test-suite> */
- QXmlAttributes test_suiteAtts;
- test_suiteAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), m_testSuiteVersion);
+ QXmlStreamAttributes test_suiteAtts;
+ test_suiteAtts.append(QLatin1String("version"), m_testSuiteVersion);
receiver.startElement(QLatin1String("test-suite"), test_suiteAtts);
/* </test-suite> */
diff --git a/tests/auto/xmlpatternssdk/XMLWriter.cpp b/tests/auto/xmlpatternssdk/XMLWriter.cpp
index 8ba5884..38a2d0d 100644
--- a/tests/auto/xmlpatternssdk/XMLWriter.cpp
+++ b/tests/auto/xmlpatternssdk/XMLWriter.cpp
@@ -328,16 +328,7 @@ bool XMLWriter::startDocument()
return true;
}
-bool XMLWriter::startElement(const QString &/*namespaceURI*/,
- const QString &/*localName*/,
- const QString &qName,
- const QXmlAttributes &atts)
-{
- return startElement(qName, atts);
-}
-
-bool XMLWriter::startElement(const QString &qName,
- const QXmlAttributes &atts)
+bool XMLWriter::startElement(const QString &qName, const QXmlStreamAttributes &atts)
{
Q_ASSERT_X(!d->insideCDATA, Q_FUNC_INFO,
"Only characters() can be received when inside CDATA.");
@@ -377,18 +368,16 @@ bool XMLWriter::startElement(const QString &qName,
}
d->namespaces.clear();
- const int c = atts.count();
+ for (const auto &attr : atts) {
+ const auto qName = attr.qualifiedName().toString();
- /* Serialize attributes. */
- for(int i = 0; i != c; ++i)
- {
- d->validateQName(atts.qName(i));
- d->verifyNS(atts.qName(i));
+ d->validateQName(qName);
+ d->verifyNS(qName);
serialize(' ');
- serialize(atts.qName(i));
+ serialize(qName);
serialize("=\"");
- serialize(d->escapeAttributeContent(atts.value(i)));
+ serialize(d->escapeAttributeContent(attr.value().toString()));
serialize('"');
}
@@ -396,13 +385,6 @@ bool XMLWriter::startElement(const QString &qName,
return true;
}
-bool XMLWriter::endElement(const QString &/*namespaceURI*/,
- const QString &/*localName*/,
- const QString &qName)
-{
- return endElement(qName);
-}
-
bool XMLWriter::endElement(const QString &qName)
{
Q_ASSERT_X(!d->insideCDATA, Q_FUNC_INFO,
@@ -611,21 +593,6 @@ bool XMLWriter::ignorableWhitespace(const QString &ch)
return characters(ch);
}
-bool XMLWriter::endPrefixMapping(const QString &)
-{
- /* Again, should we do something with this? */
- return true;
-}
-
-bool XMLWriter::skippedEntity(const QString &)
-{
- return true;
-}
-
-void XMLWriter::setDocumentLocator(QXmlLocator *)
-{
-}
-
QIODevice *XMLWriter::device() const
{
return d->dev;
diff --git a/tests/auto/xmlpatternssdk/XMLWriter.h b/tests/auto/xmlpatternssdk/XMLWriter.h
index 0051d66..3d17d50 100644
--- a/tests/auto/xmlpatternssdk/XMLWriter.h
+++ b/tests/auto/xmlpatternssdk/XMLWriter.h
@@ -31,8 +31,7 @@
#include "Global.h"
-#include <QtXml/QXmlContentHandler>
-#include <QtXml/QXmlLexicalHandler>
+#include <QXmlStreamAttributes>
QT_BEGIN_NAMESPACE
@@ -52,10 +51,6 @@ namespace QPatternistSDK
* specified in XMLWriter's constructor or via setDevice(). If writing to
* the device fails, the content functions such as startElement() returns @c false.
*
- * XMLWriter sub-classes QXmlContentHandler meaning it can serialize content
- * from any code that produces SAX events. The class can also be used manually,
- * by calling startElement(), endCDATA(), and so forth.
- *
* XMLWriter cannot be used to serialize multiple documents. One instance per
* document must be used.
*
@@ -95,8 +90,7 @@ namespace QPatternistSDK
* @author Frans Englich <frans.englich@nokia.com>
* @ingroup PatternistSDK
*/
- class XMLWriter : public QXmlContentHandler
- , public QXmlLexicalHandler
+ class XMLWriter
{
public:
/**
@@ -132,35 +126,8 @@ namespace QPatternistSDK
* To declare namespaces, don't put attributes with name <tt>xmlns:*</tt> in @p atts,
* but use startPrefixMapping().
*/
- virtual bool startElement(const QString &qName, const QXmlAttributes &atts = QXmlAttributes());
-
- /**
- *
- * Behaves essentially as startElement(const QString &qName, const QXmlAttributes &atts). This
- * function is used in conjunction with other SAX classes.
- *
- * The call:
- *
- * @code
- * startElement(QString(), QString(), qName, atts);
- * @endcode
- *
- * is equivalent to:
- *
- * @code
- * startElement(qName, atts);
- * @endcode
- *
- * @p namespaceURI and @p localName are not used. This function is
- * used in conjunction with other SAX classes.
- *
- * @returns @c false if failure occurs in writing to the QIODevice, otherwise
- * @c true
- */
- virtual bool startElement(const QString &namespaceURI,
- const QString &localName,
- const QString &qName,
- const QXmlAttributes &atts);
+ virtual bool startElement(const QString &qName,
+ const QXmlStreamAttributes &atts = QXmlStreamAttributes());
/**
* Signals the end of an element with name @p qName. @p qName must
@@ -174,31 +141,6 @@ namespace QPatternistSDK
virtual bool endElement(const QString &qName);
/**
- * Behaves essentially as endElement(const QString &qName). This function
- * is used when XMLWriter is used in SAX code.
- *
- * @p namespaceURI and @p localName are not used.
- *
- * The call:
- *
- * @code
- * endElement(QString(), QString(), qName);
- * @endcode
- *
- * is equivalent to:
- *
- * @code
- * endElement(qName);
- * @endcode
- *
- * @returns @c false if failure occurs in writing to the QIODevice, otherwise
- * @c true
- */
- virtual bool endElement(const QString &namespaceURI,
- const QString &localName,
- const QString &qName);
-
- /**
* A description of an error if it occurred. This is typically
* QIODevice::errorString(). If no error has occurred, an empty
* string is returned.
@@ -326,24 +268,6 @@ namespace QPatternistSDK
virtual bool ignorableWhitespace(const QString &ch);
/**
- * This function is not used by XMLWriter, but is implemented
- * in order to satisfy QXmlContentHandler's interface.
- */
- virtual bool endPrefixMapping(const QString &prefix);
-
- /**
- * This function is not used by XMLWriter, but is implemented
- * in order to satisfy QXmlContentHandler's interface.
- */
- virtual bool skippedEntity(const QString &name);
-
- /**
- * This function is not used by XMLWriter, but is implemented
- * in order to satisfy QXmlContentHandler's interface.
- */
- virtual void setDocumentLocator(QXmlLocator *);
-
- /**
* @returns the device XMLWriter writes its output to.
* XMLWriter does not own the device.
*/