summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJuha Kukkonen <juha.kukkonen@nokia.com>2011-10-10 05:36:14 (GMT)
committerJuha Kukkonen <juha.kukkonen@nokia.com>2011-10-10 07:15:23 (GMT)
commit22d475e1ef32875c4933b2bb4c2830cb1bdd3266 (patch)
tree7959bcba424f1108481e26341c4e9e35e12e152d /src
parent7e662f3727e7c3dd3c41c29ed49bc41d2b66c744 (diff)
downloadQt-22d475e1ef32875c4933b2bb4c2830cb1bdd3266.zip
Qt-22d475e1ef32875c4933b2bb4c2830cb1bdd3266.tar.gz
Qt-22d475e1ef32875c4933b2bb4c2830cb1bdd3266.tar.bz2
Fix XML schema validation failure.
Checking constraining facets for double failed if enumeration restriction had values INF or NaN. There were two issues that caused validation to fail: - wrong conversion function was used when constraining facets for double are checked, which caused values to be in lower case - case when both restriction and default value are NaN was not handled correctly Task-number: QTBUG-21375 Reviewed-by: Honglei Zhang
Diffstat (limited to 'src')
-rw-r--r--src/xmlpatterns/schema/qxsdtypechecker.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/xmlpatterns/schema/qxsdtypechecker.cpp b/src/xmlpatterns/schema/qxsdtypechecker.cpp
index fb47448..e5709ae 100644
--- a/src/xmlpatterns/schema/qxsdtypechecker.cpp
+++ b/src/xmlpatterns/schema/qxsdtypechecker.cpp
@@ -57,6 +57,7 @@
#include "qxsdschemahelper_p.h"
#include "qxsdschemamerger_p.h"
#include "qxsdstatemachine_p.h"
+#include "qabstractfloat_p.h"
#include "qxsdschemadebugger_p.h"
@@ -697,7 +698,8 @@ bool XsdTypeChecker::checkConstrainingFacetsDouble(double value, const QString &
}
if (facets.contains(XsdFacet::Enumeration)) {
const XsdFacet::Ptr facet = facets.value(XsdFacet::Enumeration);
- const DerivedString<TypeString>::Ptr valueStr = DerivedString<TypeString>::fromLexical(m_namePool, QString::number(value));
+ const Numeric::Ptr valuePtr = Double::fromValue(value);
+ const DerivedString<TypeString>::Ptr valueStr = DerivedString<TypeString>::fromLexical(m_namePool, valuePtr->stringValue());
const AtomicValue::List multiValue = facet->multiValue();
bool found = false;
@@ -706,6 +708,13 @@ bool XsdTypeChecker::checkConstrainingFacetsDouble(double value, const QString &
found = true;
break;
}
+
+ // Handle case when both facet and value are NaN separately as equals for NaN returns always false.
+ const Numeric::Ptr facetValue = ValueFactory::fromLexical(multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue(), BuiltinTypes::xsDouble, m_context, m_reflection);
+ if (facetValue->isNaN() && valuePtr->isNaN()) {
+ found = true;
+ break;
+ }
}
if (!found) {