'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:
    instead of <genre>Thriller Action</genre>

    I would appreciate any help at all


    Jonathan, Jan 23, 2004
    1. Advertisements

  2. 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"
    <title>a select element with an itemset</title>
    <xf:model id="main">
    <form-data xmlns="">
    <gods />
    <xf:submission method="POST"
    action="http://sinex.hut.mediapoli.com:8080/xforms/request" />
    <xf:model id="gods">
    <gods xmlns="">
    <description>He who greps</description>
    <description>He who xgreps</description>
    <description>He who bikes</description>
    <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:label>submit data</xf:label>

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

    <form-data xmlns="" xmlns:xf="http://www.w3.org/2002/xforms">
    Martin Honnen, Jan 24, 2004
    1. Advertisements

  3. Why have you used <xf:copy ref> instead of <xf:value ref>?
    Jonathan Harris, Jan 25, 2004
  4. Because that is necessary in my understanding to have the element nodes
    posted when the form is submitted:
    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, Jan 25, 2004
  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)
    Jonathan Harris, Jan 26, 2004
  6. No problem - I have found the solution to my problem.
    Thanks for your help Martin.
    Jonathan Harris, Jan 29, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.