summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Kukkonen <juha.kukkonen@nokia.com>2011-09-26 05:25:50 (GMT)
committerJuha Kukkonen <juha.kukkonen@nokia.com>2011-09-26 11:11:19 (GMT)
commit26341f6060434b6cbc08d98df34c2d2aee56a70c (patch)
tree458ff78fd5cd0070e372064a471a72ddb9832777
parentaa73a64e7997af3a029be32753c248a21e6961fb (diff)
downloadQt-26341f6060434b6cbc08d98df34c2d2aee56a70c.zip
Qt-26341f6060434b6cbc08d98df34c2d2aee56a70c.tar.gz
Qt-26341f6060434b6cbc08d98df34c2d2aee56a70c.tar.bz2
Fix QXmlQuery autotest failure.
Changed XQuery functions fn:doc() and fn:doc-available() to work with URLs without scheme when accessing files. Task-number: QT-4962 Reviewed-by: Honglei Zhang
-rw-r--r--src/xmlpatterns/functions/qsequencegeneratingfns.cpp20
-rw-r--r--tests/auto/qabstractxmlnodemodel/qabstractxmlnodemodel.pro2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/xmlpatterns/functions/qsequencegeneratingfns.cpp b/src/xmlpatterns/functions/qsequencegeneratingfns.cpp
index 6215f3d..3f3dbbb 100644
--- a/src/xmlpatterns/functions/qsequencegeneratingfns.cpp
+++ b/src/xmlpatterns/functions/qsequencegeneratingfns.cpp
@@ -41,6 +41,7 @@
#include <QStack>
#include <QStringList>
+#include <QFileInfo>
#include "qanyuri_p.h"
#include "qboolean_p.h"
@@ -207,6 +208,21 @@ Item::Iterator::Ptr IdrefFN::evaluateSequence(const DynamicContext::Ptr &context
return CommonValues::emptyIterator; /* TODO Haven't implemented further. */
}
+/*!
+ * Attemps to resolve scheme if URL does not have scheme defined.
+ */
+static QUrl resolveScheme(const QUrl &url)
+{
+ // On Windows and Symbian the drive letter is detected as the scheme.
+ if (url.scheme().isEmpty() || (url.scheme().length() == 1)) {
+ QString filename = url.toString();
+ QFileInfo file(filename);
+ if (file.exists())
+ return QUrl::fromLocalFile(filename);
+ }
+ return url;
+}
+
Item DocFN::evaluateSingleton(const DynamicContext::Ptr &context) const
{
const Item itemURI(m_operands.first()->evaluateSingleton(context));
@@ -219,7 +235,7 @@ Item DocFN::evaluateSingleton(const DynamicContext::Ptr &context) const
* as part of a workaround for solaris-cc-64. DocFN::typeCheck() is in qsequencefns.cpp
* as part of that workaround. */
const QUrl mayRela(AnyURI::toQUrl<ReportContext::FODC0005>(itemURI.stringValue(), context, this));
- const QUrl uri(context->resolveURI(mayRela, staticBaseURI()));
+ const QUrl uri(resolveScheme(context->resolveURI(mayRela, staticBaseURI())));
Q_ASSERT(uri.isValid());
Q_ASSERT(!uri.isRelative());
@@ -251,7 +267,7 @@ bool DocAvailableFN::evaluateEBV(const DynamicContext::Ptr &context) const
/* These two lines are duplicated in DocFN::evaluateSingleton(), as part
* of a workaround for solaris-cc-64. */
const QUrl mayRela(AnyURI::toQUrl<ReportContext::FODC0005>(itemURI.stringValue(), context, this));
- const QUrl uri(context->resolveURI(mayRela, staticBaseURI()));
+ const QUrl uri(resolveScheme(context->resolveURI(mayRela, staticBaseURI())));
Q_ASSERT(!uri.isRelative());
return context->resourceLoader()->isDocumentAvailable(uri);
diff --git a/tests/auto/qabstractxmlnodemodel/qabstractxmlnodemodel.pro b/tests/auto/qabstractxmlnodemodel/qabstractxmlnodemodel.pro
index b8f509d..90a99c0 100644
--- a/tests/auto/qabstractxmlnodemodel/qabstractxmlnodemodel.pro
+++ b/tests/auto/qabstractxmlnodemodel/qabstractxmlnodemodel.pro
@@ -6,7 +6,7 @@ HEADERS += TestNodeModel.h LoadingModel.h
include (../xmlpatterns.pri)
-wince*: {
+wince*|symbian: {
addFiles.files = tree.xml
addFiles.path = .