summaryrefslogtreecommitdiffstats
path: root/src/xmlpatterns/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlpatterns/utils')
-rw-r--r--src/xmlpatterns/utils/qxpathhelper.cpp12
-rw-r--r--src/xmlpatterns/utils/qxpathhelper_p.h5
2 files changed, 17 insertions, 0 deletions
diff --git a/src/xmlpatterns/utils/qxpathhelper.cpp b/src/xmlpatterns/utils/qxpathhelper.cpp
index 127e21f..5b32906 100644
--- a/src/xmlpatterns/utils/qxpathhelper.cpp
+++ b/src/xmlpatterns/utils/qxpathhelper.cpp
@@ -125,4 +125,16 @@ ItemType::Ptr XPathHelper::typeFromKind(const QXmlNodeModelIndex::NodeKind nodeK
}
}
+QUrl XPathHelper::normalizeQueryURI(const QUrl &uri)
+{
+ Q_ASSERT_X(uri.isEmpty() || uri.isValid(), Q_FUNC_INFO,
+ "The URI passed to QXmlQuery::setQuery() must be valid or empty.");
+ if(uri.isEmpty())
+ return QUrl::fromLocalFile(QCoreApplication::applicationFilePath());
+ else if(uri.isRelative())
+ return QUrl::fromLocalFile(QCoreApplication::applicationFilePath()).resolved(uri);
+ else
+ return uri;
+}
+
QT_END_NAMESPACE
diff --git a/src/xmlpatterns/utils/qxpathhelper_p.h b/src/xmlpatterns/utils/qxpathhelper_p.h
index 7bf33e6..e36b8cb 100644
--- a/src/xmlpatterns/utils/qxpathhelper_p.h
+++ b/src/xmlpatterns/utils/qxpathhelper_p.h
@@ -128,6 +128,11 @@ namespace QPatternist
static QPatternist::ItemTypePtr typeFromKind(const QXmlNodeModelIndex::NodeKind nodeKind);
/**
+ * Normalizes an @p uri by resolving it to the application directory if empty.
+ */
+ static QUrl normalizeQueryURI(const QUrl &uri);
+
+ /**
* @short Determines whether @p consists only of whitespace. Characters
* considered whitespace are the ones for which QChar::isSpace() returns @c true for.
*