[Qt-qml] XML patterns and Namespace prefix
bea.lam at nokia.com
bea.lam at nokia.com
Tue Nov 23 07:24:04 CET 2010
Hi Adrian,
On 22/11/2010, at 5:40 PM, ext adrian hornsby wrote:
> Hi all,
>
> I am trying to parse an activity-stream:
>
> <entry>
> <id>tag:photopanic.example.com,2008:photo01</id>
> <title>My Cat</title>
> <published>2008-11-02T15:29:00Z</published>
> <link rel="alternate" type="text/html"
> href="/geraldine/photos/1" />
> <activity:object-type>
> tag:atomactivity.example.com,2008:photo
> </activity:object-type>
> </entry>
>
>
> with QML XMLlistmodel and XMLrole as follows:
>
> query: "/wall/entry"
> XmlRole { name: "title"; query: "title/string()" }
> XmlRole { name: "published"; query: "published/string()" }
> XmlRole { name: "link"; query: "link/@href/string()" }
>
>
> but get this error:
> Error FODC0002 in
> tag:trolltech.com,2007:QtXmlPatterns:QIODeviceVariable:src, at line 9,
> column 25: Namespace prefix 'activity' not declared
It looks like the XML feed does not have a namespace declared for the 'activity' prefix. The root 'wall' element should look something like this:
<wall xmlns:activity="http://www.someurl.com/something">
This xmlns attribute is probably missing from your XML and so it cannot be parsed correctly.
Note that if you need to use the data within <activity:object-type> for a role, you'll need to declare the activity namespace using XmlListModel::namespaceDeclarations. For example,
XmlListModel {
source: ...
query: "/wall/entry"
namespaceDeclarations: "declare namespace activity = 'http://www.someurl.com/something';"
XmlRole { name: "objectType"; query: "activity:object-type/string()" }
}
regards,
Bea
More information about the Qt-qml
mailing list