[solved] XmlListModel problem



  • Hi,

    I can't get this model to work:

    @XmlListModel {
    id: xmlModel
    source: "http://gdata.youtube.com/schemas/2007/categories.cat"
    query: "/app:categories/atom:category"

        namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; \
                    declare namespace yt='http://gdata.youtube.com/schemas/2007';"
    
        XmlRole { name: "term";  query: "yt:@term/string()" }
        XmlRole { name: "label"; query: "yt:@label/string()" }
    

    }@

    the xml contains:

    @<?xml version='1.0' encoding='utf-8'?>
    <app:categories xmlns:app='http://www.w3.org/2007/app'
    xmlns:atom='http://www.w3.org/2005/Atom'
    xmlns:yt='http://gdata.youtube.com/schemas/2007' fixed='yes'
    scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>
    <atom:category term='Film' label='Film & Animation' xml:lang='en-US'>
    <yt:assignable />
    <yt:browsable regions='AR ... ZA' />
    </atom:category>
    [...]@

    I don't understand what I have to do. Any suggestions ?

    thanks a lot
    Marco



  • Hi, deimos,

    after the definition of the XmlListModel based on the XMLS file, did you created also the other components? Do you to show this file in a list ?

    It should be defined the delegate and the list...



  • Hi Alicemirror,

    thanks for the reply.
    I tried to learn XQuery all the night, but just for luck I got what I wanted ;)
    Yes I use the XmlListModel as a model in a GridView. Here the working code:

    @Rectangle {
    id: categoryButtons

    XmlListModel {
        id: xmlModel
        source: "http://gdata.youtube.com/schemas/2007/categories.cat"
        query: "/categories/atom:category"
    
        namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2007/app';"+
        "declare namespace atom='http://www.w3.org/2005/Atom';"+
        "declare namespace yt='http://gdata.youtube.com/schemas/2007';"
    
        XmlRole { name: "term";  query: "@term/string()" }
        XmlRole { name: "label"; query: "@label/string()" }
    }
    
    GridView {
        id: buttonsGridView
        model: xmlModel
        delegate: MDcomboButton {
            width: 100
            height: 50
            text: label+" - "+term
        }
    
        cellWidth: parent.width/8
        cellHeight: cellWidth/2
        width: parent.width
        height: parent.height
    }
    

    }@

    but I still don't understand the query statement: why it has not the "app:" beside "categories" ? I should learn more about these :)

    thanks again



  • Hi Deimos,

    bq. but I still don’t understand the query statement: why it has not the “app:” beside “categories” ? I should learn more about these :)

    What does it means ? I tried to understand it without results :)



  • AAaaaahhhhhh :-(

    Sorry, now I see. It is in your xml.

    Well, if it can help you, everytime I see a new "dialect" of the xml I became crazy to understand what it means.

    I think that this is a useful link to understand exactly what does means your xml file: http://www.w3.org/standards/xml/

    Advice: keep it in your bookmarks :)



  • bq. everytime I see a new “dialect” of the xml I became crazy to understand what it means.

    Exactly my feeling :)
    thanks for that link... bookmarked



  • Yep. It maybe a good idea to post a wiki page with a simplified but useful version of the most frequent cases of how the xml can be expressed...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.