xforms if/else equivalent

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

xforms if/else equivalent

Jeremiah Jahn-4
what is the right way to do this? you don't support avt on the
selected. I tried a group, but couldn't figure out how to do the
negative. There has to be a way to make a choice, based on the
non-existence of something. Is there a way to include xsl in the
.xhtml files. should I try and make a simple xbl else if tag?

                                   <xforms:switch>
                                        <xforms:case
selected="instance('labels')/label[@labelID = ./name()]">
                                            <xforms:output
value="instance('labels')/label[@labelID = ./name()]/@value"/>:
                                        </xforms:case>
                                        <xforms:case
selected="not(instance('labels')/label[@labelID = ./name()])">
                                            <xforms:output ref="."
value="name()"/>:
                                        </xforms:case>
                                    </xforms:switch>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xforms if/else equivalent

Jeremiah Jahn-4
this seems to work, but seems like a hack.

<xforms:group ref="instance('labels')/label[@labelID = ./name()]">
     <xforms:output  value="instance('labels')/label[@labelID =
./name()]/@value"/>:
</xforms:group>
<xforms:group ref=".[not(instance('labels')/label[@labelID = ./name()])]">
     <xforms:output ref="." value="name()"/>:
</xforms:group>


On Tue, Sep 22, 2009 at 12:33 AM, Jeremiah Jahn <[hidden email]> wrote:

> what is the right way to do this? you don't support avt on the
> selected. I tried a group, but couldn't figure out how to do the
> negative. There has to be a way to make a choice, based on the
> non-existence of something. Is there a way to include xsl in the
> .xhtml files. should I try and make a simple xbl else if tag?
>
>                                   <xforms:switch>
>                                        <xforms:case
> selected="instance('labels')/label[@labelID = ./name()]">
>                                            <xforms:output
> value="instance('labels')/label[@labelID = ./name()]/@value"/>:
>                                        </xforms:case>
>                                        <xforms:case
> selected="not(instance('labels')/label[@labelID = ./name()])">
>                                            <xforms:output ref="."
> value="name()"/>:
>                                        </xforms:case>
>                                    </xforms:switch>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xforms if/else equivalent

Jeremiah Jahn-4
Not to kick a dead horse here, but it really seems like avts on the
selected in a case would bring a heck of a lot of power with them. I'm
curious why they aren't there?

On Tue, Sep 22, 2009 at 12:40 AM, Jeremiah Jahn <[hidden email]> wrote:

> this seems to work, but seems like a hack.
>
> <xforms:group ref="instance('labels')/label[@labelID = ./name()]">
>     <xforms:output  value="instance('labels')/label[@labelID =
> ./name()]/@value"/>:
> </xforms:group>
> <xforms:group ref=".[not(instance('labels')/label[@labelID = ./name()])]">
>     <xforms:output ref="." value="name()"/>:
> </xforms:group>
>
>
> On Tue, Sep 22, 2009 at 12:33 AM, Jeremiah Jahn <[hidden email]> wrote:
>> what is the right way to do this? you don't support avt on the
>> selected. I tried a group, but couldn't figure out how to do the
>> negative. There has to be a way to make a choice, based on the
>> non-existence of something. Is there a way to include xsl in the
>> .xhtml files. should I try and make a simple xbl else if tag?
>>
>>                                   <xforms:switch>
>>                                        <xforms:case
>> selected="instance('labels')/label[@labelID = ./name()]">
>>                                            <xforms:output
>> value="instance('labels')/label[@labelID = ./name()]/@value"/>:
>>                                        </xforms:case>
>>                                        <xforms:case
>> selected="not(instance('labels')/label[@labelID = ./name()])">
>>                                            <xforms:output ref="."
>> value="name()"/>:
>>                                        </xforms:case>
>>                                    </xforms:switch>
>>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: xforms if/else equivalent

David McIntyre
In reply to this post by Jeremiah Jahn-4
Unless there's more that you want to include in your switch, you could do something simpler along the lines of

<xforms:output value="if (instance('labels')/label[@labelID = ./name()]) then instance('labels')/label[@labelID = ./name()] else ./name()"/>

Having said that, I suspect that you will have problems with [hidden email] because, within the predicate, the expression "./name()" will be evaluated in the context of the label node rather than the "outer" node you are probably expecting.

To get round this, there's a trick (or language feature, if you prefer) which is useful to use, which is to use a for loop with only one step to create a local variable.  So you would use something more like

<xforms:output value="for $name in ./name() return if (instance('labels')/label[@labelID = $name]) then instance('labels')/label[@labelID = $name] else $name"/>

Hope this helps,

Dave Mc



Jeremiah Jahn wrote:
this seems to work, but seems like a hack.

<xforms:group ref=[hidden email]>
     <xforms:output  value=[hidden email]/>:
</xforms:group>
<xforms:group ref=[hidden email]>
     <xforms:output ref="." value="name()"/>:
</xforms:group>


On Tue, Sep 22, 2009 at 12:33 AM, Jeremiah Jahn [hidden email] wrote:
  
what is the right way to do this? you don't support avt on the
selected. I tried a group, but couldn't figure out how to do the
negative. There has to be a way to make a choice, based on the
non-existence of something. Is there a way to include xsl in the
.xhtml files. should I try and make a simple xbl else if tag?

                                  <xforms:switch>
                                       <xforms:case
selected=[hidden email]>
                                           <xforms:output
value=[hidden email]/>:
                                       </xforms:case>
                                       <xforms:case
selected=[hidden email]>
                                           <xforms:output ref="."
value="name()"/>:
                                       </xforms:case>
                                   </xforms:switch>

    

--
Orion Signature

Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com


This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4448 (20090922) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: xforms if/else equivalent

Jeremiah Jahn-4
Indeed I did run into that problem, and had fixed as you mentioned. Thanks though. 
The output isn't really the issue. I was just taking the simplest case first. The reason that this is an issue is because I'm attempting to do some dynamic binding where if the item is bound to a simple type aka xs:boolean the xforms will do its thing, but Some of my inputs will be bound to complex data types with persisted data behind it. So I need to switch to a select instead of a straight input, as far as I know.  I'm trying to build support for the full LHHA plus binding, which makes things a little weird at at times.  esp. when it's all dynamic. 

thanks again,
-jj-

On Sep 22, 2009, at 4:45 PM, Dave McIntyre wrote:

Unless there's more that you want to include in your switch, you could do something simpler along the lines of

<xforms:output value="if (instance('labels')/label[@labelID = ./name()]) then instance('labels')/label[@labelID = ./name()] else ./name()"/>

Having said that, I suspect that you will have problems with [hidden email] because, within the predicate, the expression "./name()" will be evaluated in the context of the label node rather than the "outer" node you are probably expecting.

To get round this, there's a trick (or language feature, if you prefer) which is useful to use, which is to use a for loop with only one step to create a local variable.  So you would use something more like

<xforms:output value="for $name in ./name() return if (instance('labels')/label[@labelID = $name]) then instance('labels')/label[@labelID = $name] else $name"/>

Hope this helps,

Dave Mc



Jeremiah Jahn wrote:
this seems to work, but seems like a hack.

<xforms:group ref=[hidden email]>
     <xforms:output  value=[hidden email]/>:
</xforms:group>
<xforms:group ref=[hidden email]>
     <xforms:output ref="." value="name()"/>:
</xforms:group>


On Tue, Sep 22, 2009 at 12:33 AM, Jeremiah Jahn [hidden email] wrote:
  
what is the right way to do this? you don't support avt on the
selected. I tried a group, but couldn't figure out how to do the
negative. There has to be a way to make a choice, based on the
non-existence of something. Is there a way to include xsl in the
.xhtml files. should I try and make a simple xbl else if tag?

                                  <xforms:switch>
                                       <xforms:case
selected=[hidden email]>
                                           <xforms:output
value=[hidden email]/>:
                                       </xforms:case>
                                       <xforms:case
selected=[hidden email]>
                                           <xforms:output ref="."
value="name()"/>:
                                       </xforms:case>
                                   </xforms:switch>

    

--


Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com


This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4448 (20090922) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: xforms if/else equivalent

Erik Bruchez
Administrator
In reply to this post by Jeremiah Jahn-4
You could also use a variable:

<xxforms:variable name="my-condition"
select="exists(instance('labels')/label[@labelID = ./name()])"
as="xs:boolean"/>
<xforms:group ref=".[$my-condition]>
...
<xforms:group ref=".[not($my-condition)]>
...

Still not ideal, but at least you don't duplicate the code expression condition.

-Erik

On Mon, Sep 21, 2009 at 10:40 PM, Jeremiah Jahn <[hidden email]> wrote:

> this seems to work, but seems like a hack.
>
> <xforms:group ref="instance('labels')/label[@labelID = ./name()]">
>     <xforms:output  value="instance('labels')/label[@labelID =
> ./name()]/@value"/>:
> </xforms:group>
> <xforms:group ref=".[not(instance('labels')/label[@labelID = ./name()])]">
>     <xforms:output ref="." value="name()"/>:
> </xforms:group>
>
>
> On Tue, Sep 22, 2009 at 12:33 AM, Jeremiah Jahn <[hidden email]> wrote:
>> what is the right way to do this? you don't support avt on the
>> selected. I tried a group, but couldn't figure out how to do the
>> negative. There has to be a way to make a choice, based on the
>> non-existence of something. Is there a way to include xsl in the
>> .xhtml files. should I try and make a simple xbl else if tag?
>>
>>                                   <xforms:switch>
>>                                        <xforms:case
>> selected="instance('labels')/label[@labelID = ./name()]">
>>                                            <xforms:output
>> value="instance('labels')/label[@labelID = ./name()]/@value"/>:
>>                                        </xforms:case>
>>                                        <xforms:case
>> selected="not(instance('labels')/label[@labelID = ./name()])">
>>                                            <xforms:output ref="."
>> value="name()"/>:
>>                                        </xforms:case>
>>                                    </xforms:switch>
>>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws