b.open(QIODevice::ReadOnly);
QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces;
- QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/')));
+ QString prefix = QLatin1String("doc($inputDocument)/dummy:items/*");
//figure out how many items we are dealing with
int count = -1;
--- /dev/null
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ source: "groups.xml"
+ query: "//animal[@name='Garfield']/parent::group"
+
+ XmlRole { name: "id"; query: "@id/string()" }
+ XmlRole { name: "name"; query: "@name/string()" }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<groups version="2.0">
+ <group id="1" name="Animals" type="root">
+ <group id="11" name="dogs">
+ <animal id="111" name="Lassie"/>
+ <animal id="112" name="Laika"/>
+ <animal id="113" name="Wile E. Coyote" type="fictional"/>
+ </group>
+ <group id="12" name="cats">
+ <animal id="121" name="Garfield" type="fictional"/>
+ <animal id="122" name="Sylvester" type="fictional"/>
+ </group>
+ <group id="13" name="birds">
+ <animal id="131" name="Donald Duck" type="fictional"/>
+ <animal id="132" name="Phoenix" type="fictional"/>
+ </group>
+ </group>
+</groups>
QT += core-private gui-private v8-private qml-private network testlib xmlpatterns
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+OTHER_FILES += \
+ data/groups.qml
void threading();
void threading_data();
void propertyChanges();
+ void selectAncestor();
void roleCrash();
delete model;
}
+void tst_qquickxmllistmodel::selectAncestor()
+{
+ QQmlComponent component(&engine, testFileUrl("groups.qml"));
+ QAbstractItemModel *model = qobject_cast<QAbstractItemModel *>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->rowCount(), 1);
+
+ QModelIndex index = model->index(0, 0);
+ QCOMPARE(model->data(index, Qt::UserRole).toInt(), 12);
+ QCOMPARE(model->data(index, Qt::UserRole+1).toString(), QLatin1String("cats"));
+}
+
void tst_qquickxmllistmodel::roleCrash()
{
// don't crash