473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

'select' element on XForms

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
Jul 20 '05 #1
5 1772


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/

Jul 20 '05 #2

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!
Jul 20 '05 #3


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/

Jul 20 '05 #4

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!
Jul 20 '05 #5
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!
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lucjan | last post by:
I was wondering if there is a way to pass dynamically created XML as instance data to XForm. What I want to achieve is a XForm select element with single options taken from a database. I have a...
2
by: Will | last post by:
I have been having problems validating an XForms document against the XForms schema located at http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd. I have reduced the XForm to its bare bones...
0
by: arti | last post by:
Hi all. I have a problem/question with XForms. I have 2 instnace in my document, instance1 and instance2. <xforms:instance xmlns="" id=instance1"> .... </xforms:instance> <xforms:instance...
2
by: sniper | last post by:
Hi all; i'm adding items to a select list like this: var insertPoint = inst.getElementsByTagName("itemlist").item(0); var itemCount = insertPoint.getElementsByTagName("item").length;...
9
by: jazzslider | last post by:
I have a headache. I've done a LOT of research lately into XForms, and I am thoroughly convinced that a good implementation of this technology would help me immensely in converting my...
7
by: ClarkePeters | last post by:
Can anyone tell me why my CSS style sheet isn't styling my xhtml (using xforms)? I'm using firefox 1.5.0.8 with the xforms extension. Here is the xhtml, it's only a single text area for input. ...
0
by: ClarkePeters | last post by:
I don't have any problems with select1 or textarea with my xforms in firefox 1.5.0.9, but I can't seem to get my "select" several choices to work. I need to select zero or more of several choices....
1
by: spark86 | last post by:
I currently have an xform where I'm trying to have the user input first and last name and then when it submits it goes to a file with the path first_last.xml. Here is what I have currently: ...
0
by: li72 | last post by:
As you can see in binding part, the node<age /> should be returned as a calendar or any form of date picker instead of an input box. In addition, none null values submission is not achieving. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.