diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-11-13 15:38:28 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-12-18 17:21:52 +0100 |
commit | 0e44a69b3546f259cd01bac1a5d10e86b287eb45 (patch) | |
tree | e342f435b08937f9b0664ea9b9c9eaf8541054ba /tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp | |
parent | 159d7230d301f999633eecef25f8569f5e8831b6 (diff) | |
download | qtxmlpatterns-0e44a69b3546f259cd01bac1a5d10e86b287eb45.tar.gz |
Stop using SAX classes for reading XML files
The qtxmlpatterns' tests are using SAX classes for parsing XML files.
These classes will be deprecated.
Replaced QXmlSimpleReader by QDomDocument where applicable.
For the test suite handlers inheriting from QXmlDefaultHandler, introduced
the XmlParseHelper base class, which drives the parsing loop and allows
overriding the methods for handling different XML tokens.
Task-number: QTBUG-76177
Change-Id: Ia1a60c898a272906ede459e95ced7ec95d154fde
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp')
-rw-r--r-- | tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp index 854fef6..4e56af6 100644 --- a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp +++ b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp @@ -782,10 +782,8 @@ XSDTestSuiteHandler::XSDTestSuiteHandler(const QUrl &catalogFile) : m_ts(0) << QLatin1String("wildZ010"); } -bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &/*qName*/, - const QXmlAttributes &atts) +bool XSDTestSuiteHandler::startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef & /*qName*/, const QXmlStreamAttributes &atts) { if(namespaceURI != QString::fromLatin1("http://www.w3.org/XML/2004/xml-schema-test-suite/")) return true; @@ -793,16 +791,16 @@ bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, if (localName == QLatin1String("testSet")) { m_currentTestSet = new TestGroup(m_topLevelGroup); Q_ASSERT(m_currentTestSet); - m_currentTestSet->setTitle(atts.value("name")); + m_currentTestSet->setTitle(atts.value("name").toString()); m_topLevelGroup->appendChild(m_currentTestSet); } else if (localName == QLatin1String("testGroup")) { m_currentTestGroup = new TestGroup(m_currentTestSet); Q_ASSERT(m_currentTestGroup); - m_currentTestGroup->setTitle(atts.value("name")); + m_currentTestGroup->setTitle(atts.value("name").toString()); m_currentTestSet->appendChild(m_currentTestGroup); m_inTestGroup = true; } else if (localName == QLatin1String("schemaTest")) { - if (m_blackList.contains(atts.value("name"))) { + if (m_blackList.contains(atts.value("name").toString())) { m_currentTestCase = 0; m_schemaBlacklisted = true; return true; @@ -832,12 +830,12 @@ bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, m_inInstanceTest = true; } else if (localName == QLatin1String("schemaDocument") || localName == QLatin1String("instanceDocument")) { if (m_inSchemaTest) { - m_currentTestCase->setSchemaUri(QUrl(atts.value("xlink:href"))); + m_currentTestCase->setSchemaUri(QUrl(atts.value("xlink:href").toString())); if (m_currentSchemaLink.isEmpty()) // we only use the first schema document for validation - m_currentSchemaLink = atts.value("xlink:href"); + m_currentSchemaLink = atts.value("xlink:href").toString(); } if (m_inInstanceTest) { - m_currentTestCase->setInstanceUri(QUrl(atts.value("xlink:href"))); + m_currentTestCase->setInstanceUri(QUrl(atts.value("xlink:href").toString())); m_currentTestCase->setSchemaUri(QUrl(m_currentSchemaLink)); } } else if (localName == QLatin1String("expected") && (m_inSchemaTest || m_inInstanceTest)) { @@ -858,9 +856,9 @@ bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, return true; } -bool XSDTestSuiteHandler::endElement(const QString &/*namespaceURI*/, - const QString &localName, - const QString &/*qName*/) +bool XSDTestSuiteHandler::endElement(const QStringRef &/*namespaceURI*/, + const QStringRef &localName, + const QStringRef &/*qName*/) { if (localName == QLatin1String("testGroup")) { m_inTestGroup = false; @@ -880,7 +878,7 @@ bool XSDTestSuiteHandler::endElement(const QString &/*namespaceURI*/, return true; } -bool XSDTestSuiteHandler::characters(const QString &ch) +bool XSDTestSuiteHandler::characters(const QStringRef &ch) { if (m_inDescription) m_documentation += ch; |