W3C home > Mailing lists > Public > www-forms@w3.org > July 2006

Re: set value for more than one element in select1?

From: Andrew S. Townley <andrew.townley@bearingpoint.com>
Date: Mon, 24 Jul 2006 16:07:16 +0100
To: Erik Bruchez <ebruchez@orbeon.com>
Cc: www-forms@w3.org
Message-Id: <1153753636.3170.13.camel@macross>

Hi Erik,

That looks the business.  I'll do some playing around and see what
happens.  Looks like the idea is a workable solution though.  When I get
a chance, there's clearly a lot more I need to learn about XForms--I
wouldn't have thought of the intermediate instance.

One thing in looking at it that I don't understand, however, is that
even though it isn't in what you included, you're still basing the list
contents off of the 'items' instance using an itemset, right?  If this
is true, isn't this going to cause problems in OPS?  I know this is
getting into ops-specific territory, but won't the behavior I observed
the other day with losing attribute values from copy bite me here as
well?  If not, I'll do some more reading so that I really understand
what's happening in your fragment.  I haven't really done much with
insert/setvalue yet.

Thanks for the help.  I'll also check out the latest DMV example you
mentioned as well for the i18n stuff.

Cheers,

ast

On Mon, 2006-07-24 at 15:45, Erik Bruchez wrote:
> Andrew S. Townley wrote:
> 
>  >>> However, once the value is selected from the select1, I need to include
>  >>> it in the following XML instance document:
>  >>>
>  >>> <Element>
>  >>>   <ItemName/>
>  >>>   <ItemCode/>
>  >>>   ...
>  >>>   <OtherElement/>
>  >>> </Element>
>  >> The above is not clear: what do you mean by "include it"?
>  >
>  > Apologies.  It seemed perfectly clear when I wrote it yesterday. :)
>  >
>  > The root of the problem is that I need to convert a single element with
>  > attributes into two elements within my model based on whatever the
>  > current selection happens to be.
>  >
>  > So, if in the above, I have selected the following in the select1
>  >
>  > <Item Code="Fred">Yellow</Item>
>  >
>  > I need this to end up in the instance document as:
>  >
>  > <Element>
>  >   <ItemName>Yellow</ItemName>
>  >   <ItemCode>Fred</ItemCode>
>  >   ...
>  >   <OtherFormElements/>
>  > </Element>
>  >
>  > I realize that ideally the value from the select could be used "as
>  > is" in the final instance document
> 
> No, that's ok, you don't always have control over the format of your
> document, and XForms should provide you with enough flexibility to
> address such cases.
> 
>  > but I'm trying to populate an instance with what might as well be an
>  > external schema.
> 
> As I said ;-)
> 
>  > As I said, I suspect the only viable option is to create a new,
>  > intermediate instance that allows me to embed the original <Item>
>  > element as is, and the post-process the resulting instance to
>  > generate the instance that I eventually need to create, but I wanted
>  > to make sure there wasn't a better way.
> 
> If you use xforms:select1, you are right, you have to bind that
> control to a node in an instance, where the selected value remains as
> text.
> 
> Once you are there, you can post-process, but you should be able to do
> that with XForms.
> 
> <xforms:instance id="selected-values">
>    <selected-values>
>      <colors/>
>    </selected-values>
> </xforms:instance>
> 
> <xforms:instance id="items">
>    <Items>
>      <Item Code="Fred">Yellow</Item>
>      ...
>    </Items>
> </xforms:instance>
> 
> <xforms:instance id="insert-template">
>    <Element>
>      <ItemName/>
>      <ItemCode/>
>    </Element>
> </xforms:instance>
> 
> <xforms:select1 ref="instance('selected-values')/colors">
>    <xforms:action ev:event="xforms-value-changed">
>      <!-- Insert element if not present -->
>      <xforms:insert context="/where/you/want/to/insert"
>                     if="not(Element)"
>                     origin="instance('insert-template')"/>
>      <!-- Set item name -->
>      <xforms:setvalue ref="/where/you/want/to/insert/Element/ItemName"
>                       value="instance('items')/Item[. = 
> instance('selected-values')/colors]/@Code"/>
>      <!-- Set item code -->
>      <xforms:setvalue ref="/where/you/want/to/insert/Element/ItemCode"
>                       value="instance('selected-values')/colors"/>
>    </xforms:action>
> </xforms:select1>
> 
> I did not check the above code, but you get the idea. Note that this
> uses some XForms 1.1 features (supported by current OPS nightly
> builds).
> 
> -Erik
***************************************************************************************************
The information in this email is confidential and may be legally privileged Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.
***************************************************************************************************
Received on Monday, 24 July 2006 15:07:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:05 GMT