From 0b82f4a18c945093531543d84c34951e17ae8857 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 24 Jan 2020 09:24:03 +0200 Subject: [PATCH] Improve conversion error message. Instead of showing path to temp file show path to original file. --HG-- branch : develop --- src/libs/ifc/xml/vabstractconverter.cpp | 132 ++++++++++++++++++- src/libs/ifc/xml/vabstractconverter.h | 3 + src/libs/ifc/xml/vdomdocument.cpp | 125 ------------------ src/libs/ifc/xml/vdomdocument.h | 1 - src/libs/ifc/xml/vpatternconverter.cpp | 114 ++++++++-------- src/libs/ifc/xml/vvitconverter.cpp | 12 +- src/libs/ifc/xml/vvstconverter.cpp | 10 +- src/test/ValentinaTest/tst_vmeasurements.cpp | 8 +- 8 files changed, 205 insertions(+), 200 deletions(-) diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp index e0ebd5bdf..bcd4e0c45 100644 --- a/src/libs/ifc/xml/vabstractconverter.cpp +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -28,6 +28,7 @@ #include "vabstractconverter.h" +#include #include #include #include @@ -38,19 +39,81 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include #include "../exception/vexception.h" #include "../exception/vexceptionwrongid.h" #include "vdomdocument.h" +//This class need for validation pattern file using XSD shema +class MessageHandler : public QAbstractMessageHandler +{ +public: + MessageHandler() + : QAbstractMessageHandler(), + m_messageType(QtMsgType()), + m_description(), + m_sourceLocation(QSourceLocation()) + {} + + QString statusMessage() const; + qint64 line() const; + qint64 column() const; +protected: + // cppcheck-suppress unusedFunction + virtual void handleMessage(QtMsgType type, const QString &description, + const QUrl &identifier, const QSourceLocation &sourceLocation) override; +private: + QtMsgType m_messageType; + QString m_description; + QSourceLocation m_sourceLocation; +}; + +//--------------------------------------------------------------------------------------------------------------------- +QString MessageHandler::statusMessage() const +{ + QTextDocument doc; + doc.setHtml(m_description); + return doc.toPlainText(); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qint64 MessageHandler::line() const +{ + return m_sourceLocation.line(); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qint64 MessageHandler::column() const +{ + return m_sourceLocation.column(); +} + +//--------------------------------------------------------------------------------------------------------------------- +// cppcheck-suppress unusedFunction +void MessageHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, + const QSourceLocation &sourceLocation) +{ + Q_UNUSED(type) + Q_UNUSED(identifier) + + m_messageType = type; + m_description = description; + m_sourceLocation = sourceLocation; +} + //--------------------------------------------------------------------------------------------------------------------- VAbstractConverter::VAbstractConverter(const QString &fileName) : VDomDocument(), m_ver(0x0), + m_originalFileName(fileName), m_convertedFileName(fileName), m_tmpFile() { @@ -157,6 +220,71 @@ void VAbstractConverter::BiasTokens(int position, int bias, QMap & tokens = newTokens; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ValidateXML validate xml file by xsd schema. + * @param schema path to schema file. + */ +void VAbstractConverter::ValidateXML(const QString &schema) const +{ + qCDebug(vXML, "Validation xml file %s.", qUtf8Printable(m_convertedFileName)); + QFile pattern(m_convertedFileName); + // cppcheck-suppress ConfigurationNotChecked + if (pattern.open(QIODevice::ReadOnly) == false) + { + const QString errorMsg(tr("Can't open file %1:\n%2.").arg(m_convertedFileName, pattern.errorString())); + throw VException(errorMsg); + } + + QFile fileSchema(schema); + // cppcheck-suppress ConfigurationNotChecked + if (fileSchema.open(QIODevice::ReadOnly) == false) + { + pattern.close(); + const QString errorMsg(tr("Can't open schema file %1:\n%2.").arg(schema, fileSchema.errorString())); + throw VException(errorMsg); + } + + MessageHandler messageHandler; + QXmlSchema sch; + sch.setMessageHandler(&messageHandler); + if (sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()))==false) + { + pattern.close(); + fileSchema.close(); + VException e(messageHandler.statusMessage()); + e.AddMoreInformation(tr("Could not load schema file '%1'.").arg(fileSchema.fileName())); + throw e; + } + qCDebug(vXML, "Schema loaded."); + + bool errorOccurred = false; + if (sch.isValid() == false) + { + errorOccurred = true; + } + else + { + QXmlSchemaValidator validator(sch); + if (validator.validate(&pattern, QUrl::fromLocalFile(pattern.fileName())) == false) + { + errorOccurred = true; + } + } + + if (errorOccurred) + { + pattern.close(); + fileSchema.close(); + VException e(messageHandler.statusMessage()); + e.AddMoreInformation(tr("Validation error file %3 in line %1 column %2").arg(messageHandler.line()) + .arg(messageHandler.column()).arg(m_originalFileName)); + throw e; + } + pattern.close(); + fileSchema.close(); +} + //--------------------------------------------------------------------------------------------------------------------- Q_NORETURN void VAbstractConverter::InvalidVersion(int ver) const { @@ -194,7 +322,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const { // Version bigger than maximum supported version. We still have a chance to open the file. try { // Try to open like the current version. - ValidateXML(currentSchema, m_convertedFileName); + ValidateXML(currentSchema); } catch(const VException &exp) { // Nope, we can't. @@ -210,7 +338,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const return; // All is fine and we can try to convert to current max version. } - ValidateXML(schema, m_convertedFileName); + ValidateXML(schema); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h index 20f560b46..4421e62bf 100644 --- a/src/libs/ifc/xml/vabstractconverter.h +++ b/src/libs/ifc/xml/vabstractconverter.h @@ -52,6 +52,7 @@ public: protected: int m_ver; + QString m_originalFileName; QString m_convertedFileName; void ValidateInputFile(const QString ¤tSchema) const; @@ -75,6 +76,8 @@ protected: void CorrectionsPositions(int position, int bias, QMap &tokens) const; static void BiasTokens(int position, int bias, QMap &tokens); + void ValidateXML(const QString &schema) const; + private: Q_DISABLE_COPY(VAbstractConverter) diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 25dbb379c..28a884bea 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -54,8 +54,6 @@ #include #include #include -#include -#include #include #include #include @@ -236,63 +234,6 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) } } -//This class need for validation pattern file using XSD shema -class MessageHandler : public QAbstractMessageHandler -{ -public: - MessageHandler() - : QAbstractMessageHandler(), - m_messageType(QtMsgType()), - m_description(), - m_sourceLocation(QSourceLocation()) - {} - - QString statusMessage() const; - qint64 line() const; - qint64 column() const; -protected: - // cppcheck-suppress unusedFunction - virtual void handleMessage(QtMsgType type, const QString &description, - const QUrl &identifier, const QSourceLocation &sourceLocation) override; -private: - QtMsgType m_messageType; - QString m_description; - QSourceLocation m_sourceLocation; -}; - -//--------------------------------------------------------------------------------------------------------------------- -QString MessageHandler::statusMessage() const -{ - QTextDocument doc; - doc.setHtml(m_description); - return doc.toPlainText(); -} - -//--------------------------------------------------------------------------------------------------------------------- -inline qint64 MessageHandler::line() const -{ - return m_sourceLocation.line(); -} - -//--------------------------------------------------------------------------------------------------------------------- -inline qint64 MessageHandler::column() const -{ - return m_sourceLocation.column(); -} - -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -void MessageHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, - const QSourceLocation &sourceLocation) -{ - Q_UNUSED(type) - Q_UNUSED(identifier) - - m_messageType = type; - m_description = description; - m_sourceLocation = sourceLocation; -} - Q_LOGGING_CATEGORY(vXML, "v.xml") const QString VDomDocument::AttrId = QStringLiteral("id"); @@ -785,72 +726,6 @@ void VDomDocument::CacheRefreshed() m_elementIdCache = m_watcher->future().result(); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ValidateXML validate xml file by xsd schema. - * @param schema path to schema file. - * @param fileName name of xml file. - */ -void VDomDocument::ValidateXML(const QString &schema, const QString &fileName) -{ - qCDebug(vXML, "Validation xml file %s.", qUtf8Printable(fileName)); - QFile pattern(fileName); - // cppcheck-suppress ConfigurationNotChecked - if (pattern.open(QIODevice::ReadOnly) == false) - { - const QString errorMsg(tr("Can't open file %1:\n%2.").arg(fileName, pattern.errorString())); - throw VException(errorMsg); - } - - QFile fileSchema(schema); - // cppcheck-suppress ConfigurationNotChecked - if (fileSchema.open(QIODevice::ReadOnly) == false) - { - pattern.close(); - const QString errorMsg(tr("Can't open schema file %1:\n%2.").arg(schema, fileSchema.errorString())); - throw VException(errorMsg); - } - - MessageHandler messageHandler; - QXmlSchema sch; - sch.setMessageHandler(&messageHandler); - if (sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()))==false) - { - pattern.close(); - fileSchema.close(); - VException e(messageHandler.statusMessage()); - e.AddMoreInformation(tr("Could not load schema file '%1'.").arg(fileSchema.fileName())); - throw e; - } - qCDebug(vXML, "Schema loaded."); - - bool errorOccurred = false; - if (sch.isValid() == false) - { - errorOccurred = true; - } - else - { - QXmlSchemaValidator validator(sch); - if (validator.validate(&pattern, QUrl::fromLocalFile(pattern.fileName())) == false) - { - errorOccurred = true; - } - } - - if (errorOccurred) - { - pattern.close(); - fileSchema.close(); - VException e(messageHandler.statusMessage()); - e.AddMoreInformation(tr("Validation error file %3 in line %1 column %2").arg(messageHandler.line()) - .arg(messageHandler.column()).arg(fileName)); - throw e; - } - pattern.close(); - fileSchema.close(); -} - //--------------------------------------------------------------------------------------------------------------------- void VDomDocument::setXMLContent(const QString &fileName) { diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 631ded651..d7a63a329 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -120,7 +120,6 @@ public: Unit MUnit() const; - static void ValidateXML(const QString &schema, const QString &fileName); virtual void setXMLContent(const QString &fileName); static QString UnitsHelpString(); diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index abf862c57..43cd6b4b7 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -254,231 +254,231 @@ void VPatternConverter::ApplyPatches() { case (FORMAT_VERSION(0, 1, 4)): ToV0_2_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 0)): ToV0_2_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 1)): ToV0_2_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 2)): ToV0_2_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 3)): ToV0_2_4(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 4)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 4))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 4)): ToV0_2_5(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 5)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 5))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 5)): ToV0_2_6(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 6)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 6))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 6)): ToV0_2_7(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 7)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 2, 7))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 2, 7)): ToV0_3_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 0)): ToV0_3_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 1)): ToV0_3_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 2)): ToV0_3_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 3)): ToV0_3_4(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 4)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 4))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 4)): ToV0_3_5(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 5)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 5))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 5)): ToV0_3_6(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 6)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 6))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 6)): ToV0_3_7(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 7)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 7))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 7)): ToV0_3_8(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 8)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 8))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 8)): ToV0_3_9(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 9)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 9))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 9)): ToV0_4_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 0)): ToV0_4_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 1)): ToV0_4_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 2)): ToV0_4_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 3)): ToV0_4_4(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 4)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 4))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 4)): ToV0_4_5(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 5)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 5))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 5)): ToV0_4_6(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 6)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 6))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 6)): ToV0_4_7(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 7)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 7))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 7)): ToV0_4_8(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 8)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 8))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 8)): ToV0_5_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 5, 0)): ToV0_5_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 5, 1)): ToV0_6_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 0)): ToV0_6_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 1)): ToV0_6_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 2)): ToV0_6_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 3)): ToV0_6_4(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 4)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 4))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 4)): ToV0_6_5(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 5)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 5))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 5)): ToV0_6_6(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 6)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 6, 6))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 6, 6)): ToV0_7_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 0)): ToV0_7_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 1)): ToV0_7_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 2)): ToV0_7_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 3)): ToV0_7_4(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 4)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 4))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 4)): ToV0_7_5(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 5)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 5))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 5)): ToV0_7_6(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 6)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 6))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 6)): ToV0_7_7(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 7)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 7))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 7)): ToV0_7_8(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 8)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 8))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 8)): ToV0_7_9(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 9)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 9))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 9)): ToV0_7_10(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 10)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 10))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 10)): ToV0_7_11(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 11)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 11))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 11)): ToV0_7_12(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 12)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 12))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 12)): ToV0_7_13(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 13)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 7, 13))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 7, 13)): ToV0_8_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 0)): ToV0_8_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 1)): ToV0_8_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 2)): ToV0_8_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 3)): ToV0_8_4(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 4)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 4))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 4)): ToV0_8_5(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 5)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 5))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 5)): ToV0_8_6(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 6)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 6))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 6)): break; diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index 51d442650..24bb99752 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -109,27 +109,27 @@ void VVITConverter::ApplyPatches() { case (FORMAT_VERSION(0, 2, 0)): ToV0_3_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 0)): ToV0_3_1(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 1)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 1))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 1)): ToV0_3_2(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 2)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 2))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 2)): ToV0_3_3(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 3)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 3))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 3, 3)): ToV0_4_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 4, 0)): ToV0_5_0(); - ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0)), m_convertedFileName); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 5, 0)): break; diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index 5e159bf29..777462edc 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -103,23 +103,23 @@ void VVSTConverter::ApplyPatches() { case (0x000300): ToV0_4_0(); - ValidateXML(XSDSchema(0x000400), m_convertedFileName); + ValidateXML(XSDSchema(0x000400)); Q_FALLTHROUGH(); case (0x000400): ToV0_4_1(); - ValidateXML(XSDSchema(0x000401), m_convertedFileName); + ValidateXML(XSDSchema(0x000401)); Q_FALLTHROUGH(); case (0x000401): ToV0_4_2(); - ValidateXML(XSDSchema(0x000402), m_convertedFileName); + ValidateXML(XSDSchema(0x000402)); Q_FALLTHROUGH(); case (0x000402): ToV0_4_3(); - ValidateXML(XSDSchema(0x000403), m_convertedFileName); + ValidateXML(XSDSchema(0x000403)); Q_FALLTHROUGH(); case (0x000403): ToV0_4_4(); - ValidateXML(XSDSchema(0x000404), m_convertedFileName); + ValidateXML(XSDSchema(0x000404)); Q_FALLTHROUGH(); case (0x000404): break; diff --git a/src/test/ValentinaTest/tst_vmeasurements.cpp b/src/test/ValentinaTest/tst_vmeasurements.cpp index 96068026e..2da03470c 100644 --- a/src/test/ValentinaTest/tst_vmeasurements.cpp +++ b/src/test/ValentinaTest/tst_vmeasurements.cpp @@ -81,7 +81,7 @@ void TST_VMeasurements::CreateEmptyMultisizeFile() try { - VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, fileName); + VVSTConverter converter(fileName); } catch (VException &e) { @@ -122,7 +122,7 @@ void TST_VMeasurements::CreateEmptyIndividualFile() try { - VDomDocument::ValidateXML(VVITConverter::CurrentSchema, fileName); + VVITConverter converter(fileName); } catch (VException &e) { @@ -176,7 +176,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() try { - VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, fileName); + VVSTConverter converter(fileName); } catch (VException &e) { @@ -228,7 +228,7 @@ void TST_VMeasurements::ValidPMCodesIndividualFile() try { - VDomDocument::ValidateXML(VVITConverter::CurrentSchema, fileName); + VVITConverter converter(fileName); } catch (VException &e) {