'select' element on XForms

Discussion in 'XML' started by Jonathan, Jan 23, 2004.

  1. Jonathan

    Jonathan Guest

    Does anyone know if it's possible to force a 'select' element (or
    select1) to bind each selected value to a seperate element when
    written to a file, instead of just putting all the values in one
    space-seperated element?

    For example if you had a select (radio) form control for film genres
    and you selected 'Thriller' and 'Action'; when you write this to an
    XML file I would like to get:
    <genre>Thriller</genre><genre>Action</genre>
    instead of <genre>Thriller Action</genre>

    I would appreciate any help at all

    Thanks

    JH
    Jonathan, Jan 23, 2004
    #1
    1. Advertising

  2. Jonathan wrote:

    > Does anyone know if it's possible to force a 'select' element (or
    > select1) to bind each selected value to a seperate element when
    > written to a file, instead of just putting all the values in one
    > space-seperated element?
    >
    > For example if you had a select (radio) form control for film genres
    > and you selected 'Thriller' and 'Action'; when you write this to an
    > XML file I would like to get:
    > <genre>Thriller</genre><genre>Action</genre>
    > instead of <genre>Thriller Action</genre>


    I think to achieve that you need an itemset as in the following example:

    <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xf="http://www.w3.org/2002/xforms">
    <head>
    <title>a select element with an itemset</title>
    <xf:model id="main">
    <xf:instance>
    <form-data xmlns="">
    <gods />
    </form-data>
    </xf:instance>
    <xf:submission method="POST"
    action="http://sinex.hut.mediapoli.com:8080/xforms/request" />
    </xf:model>
    <xf:model id="gods">
    <xf:instance>
    <gods xmlns="">
    <god>
    <name>Kibo</name>
    <description>He who greps</description>
    </god>
    <god>
    <name>Xibo</name>
    <description>He who xgreps</description>
    </god>
    <god>
    <name>Lance</name>
    <description>He who bikes</description>
    </god>
    </gods>
    </xf:instance>
    </xf:model>
    </head>
    <body>
    <p>
    <xf:select model="main" ref="gods">
    <xf:label>Favorite gods</xf:label>
    <xf:itemset model="gods" nodeset="god">
    <xf:label ref="description" />
    <xf:copy ref="name" />
    </xf:itemset>
    </xf:select>
    <xf:submit>
    <xf:label>submit data</xf:label>
    </xf:submit>
    </p>
    </body>
    </html>

    When I submit that with XSmiles I get for instance the following data
    submitted:

    <form-data xmlns="" xmlns:xf="http://www.w3.org/2002/xforms">
    <gods><name>Kibo</name><name>Xibo</name></gods>
    </form-data>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 24, 2004
    #2
    1. Advertising

  3. Why have you used <xf:copy ref> instead of <xf:value ref>?


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Jonathan Harris, Jan 25, 2004
    #3
  4. Jonathan Harris wrote:

    > Why have you used <xf:copy ref> instead of <xf:value ref>?


    Because that is necessary in my understanding to have the element nodes
    posted when the form is submitted:
    http://www.w3.org/TR/xforms/slice9.html#ui-adv-copy
    which says

    Structurally, this element is similar to 8.2.3 The value Element. It
    differs in that it can only be used within itemset, and that it works
    with subtrees of instance data rather than simple values.

    As you asked not for single values but for elements to be submitted I
    think <xf:copy> is needed and the proper way.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 25, 2004
    #4
  5. OK, so I need to use copy.
    Problem is, I have never been able to use this as I always get a
    'doesn't conform to DTD\Schema' error message when submitting: when as
    far as I can see it is.
    It might be something to do with the fact that I am using the
    'Formsplayer' plugin instead of XSmiles - which doesn't seem to work at
    all for me. (doesn't render any of the form controls, just puts it all
    in as text)


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Jonathan Harris, Jan 26, 2004
    #5
  6. No problem - I have found the solution to my problem.
    Thanks for your help Martin.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Jonathan Harris, Jan 29, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kiran
    Replies:
    1
    Views:
    2,393
    Patrice
    Nov 26, 2004
  2. Herr Fuchs
    Replies:
    2
    Views:
    828
  3. Roedy Green

    XFORMS

    Roedy Green, May 17, 2004, in forum: Java
    Replies:
    4
    Views:
    666
    Virgil Green
    May 17, 2004
  4. Lucjan

    XForms: dynamic select

    Lucjan, Apr 5, 2004, in forum: XML
    Replies:
    0
    Views:
    393
    Lucjan
    Apr 5, 2004
  5. palmiere
    Replies:
    1
    Views:
    387
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page