summaryrefslogtreecommitdiffstats
path: root/src/xmlpatterns
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 /src/xmlpatterns
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
Diffstat (limited to 'src/xmlpatterns')
-rw-r--r--src/xmlpatterns/functions/qsequencegeneratingfns.cpp20
1 files changed, 18 insertions, 2 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);