[Qt-qml] XML patterns and Namespace prefix
Adrian Hornsby
hornsby.adrian at gmail.com
Tue Nov 23 09:47:07 CET 2010
Hi Bea,
Thanks for the tips, it go it to fix my problems.
have a nice day!
adrian
On Nov 23, 2010, at 8:24 AM, <bea.lam at nokia.com> wrote:
> 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