nested setvalue in repeat

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

nested setvalue in repeat

Mark Waschkowski
Hi,

Basically this is about context within a repeat, and how setvalue
doesn't respect the context, but other xforms elements do. I'm
actually not sure about which elements respect the repeat context, and
which that don't, and this is part of the darn problem!

It seems very odd to me that I can do:

<xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
  <xf:output ref="property[@name='email']/value"/>
</xf:repeat>

but I can't do:

<xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
  <xf:action ev:event="DOMActivate">
    <xf:setvalue model="contacts" ref="instance('contact-instance')/
uuid" value="instance('contacts-instance')/property[@name='email']/
value"/>
     <xf:toggle case="displayContact"/>
  </xf:action>
</xf:repeat>

Please note the attempted (and non-functioning) use of a repeat
contextual reference 'property[@name='email']/value' in both the
xf:output and xf:setvalue elements.

That I'm forced to do it this way:

<xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
  <xf:action ev:event="DOMActivate">
    <xf:setvalue model="contacts" ref="instance('contact-instance')/
uuid" value="instance('contacts-instance')/node[index('contacts-
repeat')]/property[@name='email']/value"/>
     <xf:toggle case="displayContact"/>
  </xf:action>
</xf:repeat>

kinda makes me want to pull my hair out.

How do other people feel about this?

Thanks,

Mark

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Aaron Reed
Hi Mark,

Can you simplify this down to a small, free-standing testcase and put it
here where we can try it?

I also don't get how you think that this should pick up a context from
the repeat.  The context for any setvalue element's @value expression
comes from the @ref on the setvalue element if it has one.  If it
doesn't or the @ref expression is relative, it will figure out the
context using an ancestor xforms control, like the repeat.

  <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
    <xf:action ev:event="DOMActivate">
      <xf:setvalue model="contacts" ref="instance('contact-instance')/
  uuid" value="instance('contacts-instance')/property[@name='email']/
  value"/>
       <xf:toggle case="displayContact"/>
    </xf:action>
  </xf:repeat>

However, in your specific example above, both the @value
("instance('contacts-instance')/property[@name='email']/
  value") and the @ref value ("instance('contact-instance')/
  uuid") are fully qualified.  I don't see how they could be influenced
by the repeat since the @ref isn't relative.

--Aaron

mwaschkowski wrote:

> Hi,
>
> Basically this is about context within a repeat, and how setvalue
> doesn't respect the context, but other xforms elements do. I'm
> actually not sure about which elements respect the repeat context, and
> which that don't, and this is part of the darn problem!
>
> It seems very odd to me that I can do:
>
> <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>   <xf:output ref="property[@name='email']/value"/>
> </xf:repeat>
>
> but I can't do:
>
> <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>   <xf:action ev:event="DOMActivate">
>     <xf:setvalue model="contacts" ref="instance('contact-instance')/
> uuid" value="instance('contacts-instance')/property[@name='email']/
> value"/>
>      <xf:toggle case="displayContact"/>
>   </xf:action>
> </xf:repeat>
>
> Please note the attempted (and non-functioning) use of a repeat
> contextual reference 'property[@name='email']/value' in both the
> xf:output and xf:setvalue elements.
>
> That I'm forced to do it this way:
>
> <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>   <xf:action ev:event="DOMActivate">
>     <xf:setvalue model="contacts" ref="instance('contact-instance')/
> uuid" value="instance('contacts-instance')/node[index('contacts-
> repeat')]/property[@name='email']/value"/>
>      <xf:toggle case="displayContact"/>
>   </xf:action>
> </xf:repeat>
>
> kinda makes me want to pull my hair out.
>
> How do other people feel about this?
>
> Thanks,
>
> Mark
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Mark Waschkowski
Hi Aaron,

Well, I can put a test case together on Monday, not enough time
today...

Thats somewhat interesting about how the setvalue currently works. Why
couldn't the developer choose to indicate if s/he wanted to use the
context or not? I did some more research and found that there may be a
current() function coming from v1.1 which would do the trick.

Sorry, there was a typo with the first example, this is what it should
have looked like (this is how I would think it should work, not how it
works today):
<xf:repeat model="contacts" nodeset="/node/node" id='contacts-repeat'>
   <xf:action ev:event="DOMActivate">
      <xf:setvalue model="contacts" ref="instance('contact-instance')/
uuid"
         value="property[@name='email']/value"/>
      <xf:toggle case="displayContact"/>
   </xf:action>
</xf:repeat>

Mark

On Apr 5, 3:46 pm, Aaron Reed <[hidden email]> wrote:

> Hi Mark,
>
> Can you simplify this down to a small, free-standing testcase and put it
> here where we can try it?
>
> I also don't get how you think that this should pick up a context from
> the repeat.  The context for any setvalue element's @value expression
> comes from the @ref on the setvalue element if it has one.  If it
> doesn't or the @ref expression is relative, it will figure out the
> context using an ancestor xforms control, like the repeat.
>
>   <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>     <xf:action ev:event="DOMActivate">
>       <xf:setvalue model="contacts" ref="instance('contact-instance')/
>   uuid" value="instance('contacts-instance')/property[@name='email']/
>   value"/>
>        <xf:toggle case="displayContact"/>
>     </xf:action>
>   </xf:repeat>
>
> However, in your specific example above, both the @value
> ("instance('contacts-instance')/property[@name='email']/
>   value") and the @ref value ("instance('contact-instance')/
>   uuid") are fully qualified.  I don't see how they could be influenced
> by the repeat since the @ref isn't relative.
>
> --Aaron
>
> mwaschkowski wrote:
> > Hi,
>
> > Basically this is about context within a repeat, and how setvalue
> > doesn't respect the context, but other xforms elements do. I'm
> > actually not sure about which elements respect the repeat context, and
> > which that don't, and this is part of the darn problem!
>
> > It seems very odd to me that I can do:
>
> > <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
> >   <xf:output ref="property[@name='email']/value"/>
> > </xf:repeat>
>
> > but I can't do:
>
> > <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
> >   <xf:action ev:event="DOMActivate">
> >     <xf:setvalue model="contacts" ref="instance('contact-instance')/
> > uuid" value="instance('contacts-instance')/property[@name='email']/
> > value"/>
> >      <xf:toggle case="displayContact"/>
> >   </xf:action>
> > </xf:repeat>
>
> > Please note the attempted (and non-functioning) use of a repeat
> > contextual reference 'property[@name='email']/value' in both the
> > xf:output and xf:setvalue elements.
>
> > That I'm forced to do it this way:
>
> > <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
> >   <xf:action ev:event="DOMActivate">
> >     <xf:setvalue model="contacts" ref="instance('contact-instance')/
> > uuid" value="instance('contacts-instance')/node[index('contacts-
> > repeat')]/property[@name='email']/value"/>
> >      <xf:toggle case="displayContact"/>
> >   </xf:action>
> > </xf:repeat>
>
> > kinda makes me want to pull my hair out.
>
> > How do other people feel about this?
>
> > Thanks,
>
> > Mark


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Aaron Reed
On Apr 5, 3:46 pm, Aaron Reed <[hidden email]> wrote:
> Hi Mark,
>
> Can you simplify this down to a small, free-standing testcase and put it
> here where we can try it?
It is the problem with not honoring the scope, and it is quite bad.
I would also like to hear the answer.

I posted such example before and never get an answer on it.
Here it is:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/
2002/xforms"
  xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://
www.mytest.org">

  <head>
    <title>Repeat scope</title>

    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <root>
          <fruit>apple</fruit>
          <fruit>orange</fruit>
          <fruit>mandarine</fruit>
          <fruit>tomato</fruit>
          <bad-fruit>Unknown</bad-fruit>
        </root>
      </xf:instance>
    </xf:model>

  </head>

  <body>
    <h2>Which one of the following does not belong to the group ?</h2>

    <xf:repeat nodeset="instance('myInstance')/fruit" model="myModel"
id="fruits-repeat">
      <div style="display: table-row">
        <div style="border-bottom: 1px solid black; display: table-
cell; width: 230px">
          <xf:output ref="."/>
        </div>
        <div style="border-bottom: 1px solid black; display: table-
cell; width: 230px">
          <xf:trigger>
            <xf:label>This one (doesn't work)</xf:label>
            <xf:action ev:event="DOMActivate">
              <xf:setvalue ref="instance('myInstance')/bad-fruit"
value="."/>
            </xf:action>
          </xf:trigger>
        </div>
        <div style="border-bottom: 1px solid black; display: table-
cell; width: 130px">
          <xf:trigger>
            <xf:label>This one (works)</xf:label>
            <xf:action ev:event="DOMActivate">
              <xf:setvalue ref="instance('myInstance')/bad-fruit"
                value="instance('myInstance')/fruit[index('fruits-
repeat')]"/>
            </xf:action>
          </xf:trigger>
        </div>
      </div>
    </xf:repeat>

    <p style="font-weight: bold">
      <xf:output ref="instance('myInstance')/bad-fruit">
        <xf:label>Bad fruit: </xf:label>
      </xf:output>
    </p>

  </body>
</html>

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Aaron Reed
Also I have a funny behavior with this form, seems like XPath
evaluator doesn't work as it should.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/
2002/xforms"
  xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://
www.mytest.org">

  <head>
    <title>Repeat scope</title>

    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
          <group2>
            <color>pink</color>
            <color>orange</color>
          </group2>
          <color-index></color-index>
          <color-value></color-value>
        </colors>
      </xf:instance>
    </xf:model>

  </head>

  <body>
    <h2>Which one of the following does not belong to the group ?</h2>

    <xf:repeat nodeset="instance('myInstance')//color" model="myModel"
id="color-repeat">
      <div style="display: table-row">
        <div style="border-bottom: 1px solid black; display: table-
cell; width: 230px">
          <xf:output ref="."/>
        </div>
        <div style="border-bottom: 1px solid black; display: table-
cell; width: 130px">
          <xf:trigger>
            <xf:label>Get Color and Index </xf:label>
            <xf:action ev:event="DOMActivate">
              <xf:setvalue ref="instance('myInstance')/color-index"
                value="index('color-repeat')"/>
              <xf:setvalue ref="instance('myInstance')/color-value"
                value="instance('myInstance')//color[index('color-
repeat')]"/>
            </xf:action>
          </xf:trigger>
        </div>
      </div>
    </xf:repeat>

    <p style="font-weight: bold">
      <xf:output ref="instance('myInstance')/color-index">
        <xf:label>Color index: </xf:label>
      </xf:output>
      <xf:output ref="instance('myInstance')//color-value">
        <xf:label>Color: </xf:label>
      </xf:output>
    </p>

  </body>
</html>

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Aaron Reed
In reply to this post by Mark Waschkowski
Hi Mark,

We have current() support on the trunk.  We hope to have it in 0.8 as
well.  We are now waiting on approval for the change we'd have to make
to transformiix on the branches to make it work with FF2.  Once we have
that we can include it in our next preview.

--Aaron

mwaschkowski wrote:

> Hi Aaron,
>
> Well, I can put a test case together on Monday, not enough time
> today...
>
> Thats somewhat interesting about how the setvalue currently works. Why
> couldn't the developer choose to indicate if s/he wanted to use the
> context or not? I did some more research and found that there may be a
> current() function coming from v1.1 which would do the trick.
>
> Sorry, there was a typo with the first example, this is what it should
> have looked like (this is how I would think it should work, not how it
> works today):
> <xf:repeat model="contacts" nodeset="/node/node" id='contacts-repeat'>
>    <xf:action ev:event="DOMActivate">
>       <xf:setvalue model="contacts" ref="instance('contact-instance')/
> uuid"
>          value="property[@name='email']/value"/>
>       <xf:toggle case="displayContact"/>
>    </xf:action>
> </xf:repeat>
>
> Mark
>
> On Apr 5, 3:46 pm, Aaron Reed <[hidden email]> wrote:
>> Hi Mark,
>>
>> Can you simplify this down to a small, free-standing testcase and put it
>> here where we can try it?
>>
>> I also don't get how you think that this should pick up a context from
>> the repeat.  The context for any setvalue element's @value expression
>> comes from the @ref on the setvalue element if it has one.  If it
>> doesn't or the @ref expression is relative, it will figure out the
>> context using an ancestor xforms control, like the repeat.
>>
>>   <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>>     <xf:action ev:event="DOMActivate">
>>       <xf:setvalue model="contacts" ref="instance('contact-instance')/
>>   uuid" value="instance('contacts-instance')/property[@name='email']/
>>   value"/>
>>        <xf:toggle case="displayContact"/>
>>     </xf:action>
>>   </xf:repeat>
>>
>> However, in your specific example above, both the @value
>> ("instance('contacts-instance')/property[@name='email']/
>>   value") and the @ref value ("instance('contact-instance')/
>>   uuid") are fully qualified.  I don't see how they could be influenced
>> by the repeat since the @ref isn't relative.
>>
>> --Aaron
>>
>> mwaschkowski wrote:
>>> Hi,
>>> Basically this is about context within a repeat, and how setvalue
>>> doesn't respect the context, but other xforms elements do. I'm
>>> actually not sure about which elements respect the repeat context, and
>>> which that don't, and this is part of the darn problem!
>>> It seems very odd to me that I can do:
>>> <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>>>   <xf:output ref="property[@name='email']/value"/>
>>> </xf:repeat>
>>> but I can't do:
>>> <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>>>   <xf:action ev:event="DOMActivate">
>>>     <xf:setvalue model="contacts" ref="instance('contact-instance')/
>>> uuid" value="instance('contacts-instance')/property[@name='email']/
>>> value"/>
>>>      <xf:toggle case="displayContact"/>
>>>   </xf:action>
>>> </xf:repeat>
>>> Please note the attempted (and non-functioning) use of a repeat
>>> contextual reference 'property[@name='email']/value' in both the
>>> xf:output and xf:setvalue elements.
>>> That I'm forced to do it this way:
>>> <xf:repeat model="contacts" nodeset="/x/y" id='contacts-repeat'>
>>>   <xf:action ev:event="DOMActivate">
>>>     <xf:setvalue model="contacts" ref="instance('contact-instance')/
>>> uuid" value="instance('contacts-instance')/node[index('contacts-
>>> repeat')]/property[@name='email']/value"/>
>>>      <xf:toggle case="displayContact"/>
>>>   </xf:action>
>>> </xf:repeat>
>>> kinda makes me want to pull my hair out.
>>> How do other people feel about this?
>>> Thanks,
>>> Mark
>
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Aaron Reed
In reply to this post by Ivan Latysh-3
Hi Ivan,

As I explained to Mark, that is how the xf:setvalue is defined in the
spec...the expression in @value is evaluated with a context of @ref.

You might want to send your testcase to the W3C working group for them
to consider as a use case.  I don't know if current() will help you
since the context of your setvalue isn't the repeat's nodeset but rather
the @ref on the xf:setvalue.  But they are considering, I believe, using
the 'context' attribute from 1.1 on more elements in the future so I
think that is what you'd need to get this working the way that you want.

--Aaron

Ivan Latysh wrote:

> On Apr 5, 3:46 pm, Aaron Reed <[hidden email]> wrote:
>> Hi Mark,
>>
>> Can you simplify this down to a small, free-standing testcase and put it
>> here where we can try it?
> It is the problem with not honoring the scope, and it is quite bad.
> I would also like to hear the answer.
>
> I posted such example before and never get an answer on it.
> Here it is:
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/
> 2002/xforms"
>   xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://
> www.w3.org/2001/XMLSchema-instance"
>   xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://
> www.mytest.org">
>
>   <head>
>     <title>Repeat scope</title>
>
>     <xf:model id="myModel">
>       <xf:instance id="myInstance" xmlns="">
>         <root>
>           <fruit>apple</fruit>
>           <fruit>orange</fruit>
>           <fruit>mandarine</fruit>
>           <fruit>tomato</fruit>
>           <bad-fruit>Unknown</bad-fruit>
>         </root>
>       </xf:instance>
>     </xf:model>
>
>   </head>
>
>   <body>
>     <h2>Which one of the following does not belong to the group ?</h2>
>
>     <xf:repeat nodeset="instance('myInstance')/fruit" model="myModel"
> id="fruits-repeat">
>       <div style="display: table-row">
>         <div style="border-bottom: 1px solid black; display: table-
> cell; width: 230px">
>           <xf:output ref="."/>
>         </div>
>         <div style="border-bottom: 1px solid black; display: table-
> cell; width: 230px">
>           <xf:trigger>
>             <xf:label>This one (doesn't work)</xf:label>
>             <xf:action ev:event="DOMActivate">
>               <xf:setvalue ref="instance('myInstance')/bad-fruit"
> value="."/>
>             </xf:action>
>           </xf:trigger>
>         </div>
>         <div style="border-bottom: 1px solid black; display: table-
> cell; width: 130px">
>           <xf:trigger>
>             <xf:label>This one (works)</xf:label>
>             <xf:action ev:event="DOMActivate">
>               <xf:setvalue ref="instance('myInstance')/bad-fruit"
>                 value="instance('myInstance')/fruit[index('fruits-
> repeat')]"/>
>             </xf:action>
>           </xf:trigger>
>         </div>
>       </div>
>     </xf:repeat>
>
>     <p style="font-weight: bold">
>       <xf:output ref="instance('myInstance')/bad-fruit">
>         <xf:label>Bad fruit: </xf:label>
>       </xf:output>
>     </p>
>
>   </body>
> </html>
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Aaron Reed
In reply to this post by Ivan Latysh-3
Hi Ivan,

I'll admit that I can't see what is wrong with what you are doing in
this testcase.  However, every processor that I've tried (Novell,
formsPlayer, XSmiles and Orbeon) couldn't handle it, either.  And most
exhibit our behavior.  When I get more time I'll try to debug exactly
why it is behaving this way.  But it might be a week or so.

Can anyone else see why it misbehaves?  If I go top to bottom clicking
on the triggers in the repeat, I'll see Color index: 1  Color: blue,
then Color Index: 2   Color: red, and then the other buttons will update
the index field but not the Color: field.  The color field will be blank.

--Aaron

Ivan Latysh wrote:

> Also I have a funny behavior with this form, seems like XPath
> evaluator doesn't work as it should.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/
> 2002/xforms"
>   xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://
> www.w3.org/2001/XMLSchema-instance"
>   xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://
> www.mytest.org">
>
>   <head>
>     <title>Repeat scope</title>
>
>     <xf:model id="myModel">
>       <xf:instance id="myInstance" xmlns="">
>         <colors>
>           <group>
>             <color>blue</color>
>             <color>red</color>
>           </group>
>           <group>
>             <color>yellow</color>
>             <color>white</color>
>           </group>
>           <group2>
>             <color>pink</color>
>             <color>orange</color>
>           </group2>
>           <color-index></color-index>
>           <color-value></color-value>
>         </colors>
>       </xf:instance>
>     </xf:model>
>
>   </head>
>
>   <body>
>     <h2>Which one of the following does not belong to the group ?</h2>
>
>     <xf:repeat nodeset="instance('myInstance')//color" model="myModel"
> id="color-repeat">
>       <div style="display: table-row">
>         <div style="border-bottom: 1px solid black; display: table-
> cell; width: 230px">
>           <xf:output ref="."/>
>         </div>
>         <div style="border-bottom: 1px solid black; display: table-
> cell; width: 130px">
>           <xf:trigger>
>             <xf:label>Get Color and Index </xf:label>
>             <xf:action ev:event="DOMActivate">
>               <xf:setvalue ref="instance('myInstance')/color-index"
>                 value="index('color-repeat')"/>
>               <xf:setvalue ref="instance('myInstance')/color-value"
>                 value="instance('myInstance')//color[index('color-
> repeat')]"/>
>             </xf:action>
>           </xf:trigger>
>         </div>
>       </div>
>     </xf:repeat>
>
>     <p style="font-weight: bold">
>       <xf:output ref="instance('myInstance')/color-index">
>         <xf:label>Color index: </xf:label>
>       </xf:output>
>       <xf:output ref="instance('myInstance')//color-value">
>         <xf:label>Color: </xf:label>
>       </xf:output>
>     </p>
>
>   </body>
> </html>
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Aaron Reed
On Apr 10, 7:24 pm, Aaron Reed <[hidden email]> wrote:

> As I explained to Mark, that is how the xf:setvalue is defined in the
> spec...the expression in @value is evaluated with a context of @ref.
I went trough the specs a few times, and still can't find it.

On the other hand I can see the following:
[quote]
value - Optional XPath expression to evaluate, with the result stored
in the selected instance data node.
[/quote]
No mention that the "value" should be evaluated in the referred (via
"ref") node context !
(Also it make absolutely no sense to evaluate "value" XPath using
"ref" context.)

Taking this into consideration the following structure
<xf:repeat nodeset="instance('myInstance')/fruit" model="myModel"
id="fruits-repeat">
 <xf:setvalue ref="instance('myInstance')/bad-fruit" value="."/>
</xf:repeat>
Should set "instance('myInstance')/bad-fruit" with
"instance('myInstance')/fruit" value.

> You might want to send your testcase to the W3C working group for them
> to consider as a use case.  I don't know if current() will help you
> since the context of your setvalue isn't the repeat's nodeset but rather
> the @ref on the xf:setvalue.  But they are considering, I believe, using
> the 'context' attribute from 1.1 on more elements in the future so I
> think that is what you'd need to get this working the way that you want.
As I sad before it make absolutely no sense, I can't come up with a
single use-case that may need such functionality.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Aaron Reed
Hi Ivan,

I have no idea where you are looking for your quote.  From the XForms
1.0 (Second Edition) spec, section 10.1.9 The setvalue Element
(http://www.w3.org/TR/xforms/index-all.html#action-setvalue) it says,

value

     Optional XPath expression to evaluate, with the result stored in
the selected instance data node. The evaluation context for this XPath
expression is the result from the Single Node Binding.

I believe the whole point of that second sentence is for consistency.
It would not be consistent with the rest of the standard that @ref
provides context everywhere else but here.

The XForms 1.1 spec is going through Last Call right now, so it would be
a good time to let the W3C know of your use case and your opinion.

--Aaron


Ivan Latysh wrote:

> On Apr 10, 7:24 pm, Aaron Reed <[hidden email]> wrote:
>
>> As I explained to Mark, that is how the xf:setvalue is defined in the
>> spec...the expression in @value is evaluated with a context of @ref.
> I went trough the specs a few times, and still can't find it.
>
> On the other hand I can see the following:
> [quote]
> value - Optional XPath expression to evaluate, with the result stored
> in the selected instance data node.
> [/quote]
> No mention that the "value" should be evaluated in the referred (via
> "ref") node context !
> (Also it make absolutely no sense to evaluate "value" XPath using
> "ref" context.)
>
> Taking this into consideration the following structure
> <xf:repeat nodeset="instance('myInstance')/fruit" model="myModel"
> id="fruits-repeat">
>  <xf:setvalue ref="instance('myInstance')/bad-fruit" value="."/>
> </xf:repeat>
> Should set "instance('myInstance')/bad-fruit" with
> "instance('myInstance')/fruit" value.
>
>> You might want to send your testcase to the W3C working group for them
>> to consider as a use case.  I don't know if current() will help you
>> since the context of your setvalue isn't the repeat's nodeset but rather
>> the @ref on the xf:setvalue.  But they are considering, I believe, using
>> the 'context' attribute from 1.1 on more elements in the future so I
>> think that is what you'd need to get this working the way that you want.
> As I sad before it make absolutely no sense, I can't come up with a
> single use-case that may need such functionality.
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
On Apr 11, 2:15 pm, Aaron Reed <[hidden email]> wrote:
> Hi Ivan,
>
> I have no idea where you are looking for your quote.
http://www.w3.org/TR/2003/REC-xforms-20031014/index-all.html#action-setvalue
My bad, I was referring to the older version.

> From the XForms
> 1.0 (Second Edition) spec, section 10.1.9 The setvalue Element
> (http://www.w3.org/TR/xforms/index-all.html#action-setvalue) it says,
>
> value
>
>      Optional XPath expression to evaluate, with the result stored in
> the selected instance data node. The evaluation context for this XPath
> expression is the result from the Single Node Binding.
Indeed it make no sense ...

> I believe the whole point of that second sentence is for consistency.
No comments here ...

> It would not be consistent with the rest of the standard that @ref
> provides context everywhere else but here.
Let's just use the common sense for a second.
<xf:setvalue/> - is an operation that take something from one place
and put it in another place, in other words it has point on origin and
destination.
So in order for it to work we have to specify 2 points, as we know
destination will be set by "Single Node Binding" ref attribute(for
instance), and point of origin will be set by value attribute, but
spec's state that point of origin and destination should be evaluated
in the same context.
And as a result - <xf:setvalue/> can only copy a value between 2 nodes
that have the same context.
I am sorry, but it is lame ...

Don't get me wrong, but I can't understand how such obvious mistake
can get in the spec.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Aaron Reed
I posted the long answer, but bloody Google lost it somewhere :)
Will try to do it again.


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Aaron Reed
On Apr 10, 8:08 pm, Aaron Reed <[hidden email]> wrote:

> I'll admit that I can't see what is wrong with what you are doing in
> this testcase.
I am not doing anything wrong it is an issue that XPath evaluator
unable to handle the node-set.
As I sad it many on multiple occasions.

> However, every processor that I've tried (Novell,
> formsPlayer, XSmiles and Orbeon) couldn't handle it, either.  And most
> exhibit our behavior.
I don't see the reason to repeat or relay on mistakes of others.

> When I get more time I'll try to debug exactly
> why it is behaving this way.  But it might be a week or so.
I didn't get a chance to go trough the XPath code (from Mozilla
trunk), but from the XForms behavior I can see that XPath evaluator
instead of working with node-sets trying to work with siblings. Let me
explain what I mean, let's evaluate a simple XPath as we are XForms
XPath evaluator.

XPath: //color[3]
XML:
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
            <test><color>test-color</color></test>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
        </colors>

At the first step we will hit the first node //color[1]=blue .
Now we are walking down on it's siblings, //color[2]=red
But //color[3] doesn't exist since there are no more siblings, so no
value returned.

When the proper behavior is to list all "color" nodes and pick from
this set, this why it called node-set.

To summarize all this: Current XPath evaluator are not capable to work
with node-sets or it is not used as it's indent to or some settings
prevent it from functioning properly.

Here is a short test-case:
<?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>Repeat scope</title>

    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
            <test><color>test-color</color></test>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
        </colors>
      </xf:instance>
    </xf:model>

  </head>

  <body>
      instance('myInstance')//color[1] = <xf:output
ref="instance('myInstance')//color[1]"/><br/>
      instance('myInstance')//color[2] = <xf:output
ref="instance('myInstance')//color[2]"/><br/>
      instance('myInstance')//color[3] = <xf:output
ref="instance('myInstance')//color[3]"/><br/>
      instance('myInstance')//color[4] = <xf:output
ref="instance('myInstance')//color[4]"/><br/>
  </body>
</html>

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Ivan Latysh-3
On Apr 10, 8:08 pm, Aaron Reed <[hidden email]> wrote:

> I'll admit that I can't see what is wrong with what you are doing in
> this testcase.
I am not doing anything wrong it is an issue that XPath evaluator
unable to handle the node-set.
As I sad it many on multiple occasions.

> However, every processor that I've tried (Novell,
> formsPlayer, XSmiles and Orbeon) couldn't handle it, either.  And most
> exhibit our behavior.
I don't see the reason to repeat or relay on mistakes of others.

> When I get more time I'll try to debug exactly
> why it is behaving this way.  But it might be a week or so.
I didn't get a chance to go trough the XPath code (from Mozilla
trunk), but from the XForms behavior I can see that XPath evaluator
instead of working with node-sets trying to work with siblings. Let me
explain what I mean, let's evaluate a simple XPath as we are XForms
XPath evaluator.

XPath: //color[3]
XML:
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
            <test><color>test-color</color></test>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
        </colors>

At the first step we will hit the first node //color[1]=blue .
Now we are walking down on it's siblings, //color[2]=red
But //color[3] doesn't exist since there are no more siblings, so no
value returned.

When the proper behavior is to list all "color" nodes and pick from
this set, this why it called node-set.

To summarize all this: Current XPath evaluator are not capable to work
with node-sets or it is not used as it's indent to or some settings
prevent it from functioning properly.

Here is a short test-case:
<?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>Repeat scope</title>

    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
            <test><color>test-color</color></test>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
        </colors>
      </xf:instance>
    </xf:model>

  </head>

  <body>
      instance('myInstance')//color[1] = <xf:output
ref="instance('myInstance')//color[1]"/><br/>
      instance('myInstance')//color[2] = <xf:output
ref="instance('myInstance')//color[2]"/><br/>
      instance('myInstance')//color[3] = <xf:output
ref="instance('myInstance')//color[3]"/><br/>
      instance('myInstance')//color[4] = <xf:output
ref="instance('myInstance')//color[4]"/><br/>
  </body>
</html>

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Aaron Reed
In reply to this post by Ivan Latysh-3
Hi Ivan,

One reason might be that by limiting the context of the setvalue, it
ensures that if the value isn't hardcoded it is coming from the same
model as the target node and then the processor and the author won't
have to both juggle the states of two models during the action (because
remember some actions are deferred if they occur inside an xf:action,
some aren't).

I'm just speculating.  I have no idea why the working group did what it
did.  I'm just saying that if you approach them with your usecase,
perhaps it will be addressed in a future version of the spec.  If they
don't know of your concerns, then it will never change.

--Aaron

Ivan Latysh wrote:

> On Apr 11, 2:15 pm, Aaron Reed <[hidden email]> wrote:
>> Hi Ivan,
>>
>> I have no idea where you are looking for your quote.
> http://www.w3.org/TR/2003/REC-xforms-20031014/index-all.html#action-setvalue
> My bad, I was referring to the older version.
>
>> From the XForms
>> 1.0 (Second Edition) spec, section 10.1.9 The setvalue Element
>> (http://www.w3.org/TR/xforms/index-all.html#action-setvalue) it says,
>>
>> value
>>
>>      Optional XPath expression to evaluate, with the result stored in
>> the selected instance data node. The evaluation context for this XPath
>> expression is the result from the Single Node Binding.
> Indeed it make no sense ...
>
>> I believe the whole point of that second sentence is for consistency.
> No comments here ...
>
>> It would not be consistent with the rest of the standard that @ref
>> provides context everywhere else but here.
> Let's just use the common sense for a second.
> <xf:setvalue/> - is an operation that take something from one place
> and put it in another place, in other words it has point on origin and
> destination.
> So in order for it to work we have to specify 2 points, as we know
> destination will be set by "Single Node Binding" ref attribute(for
> instance), and point of origin will be set by value attribute, but
> spec's state that point of origin and destination should be evaluated
> in the same context.
> And as a result - <xf:setvalue/> can only copy a value between 2 nodes
> that have the same context.
> I am sorry, but it is lame ...
>
> Don't get me wrong, but I can't understand how such obvious mistake
> can get in the spec.
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
On Apr 12, 1:09 pm, Aaron Reed <[hidden email]> wrote:
> One reason might be that by limiting the context of the setvalue, it
> ensures that if the value isn't hardcoded it is coming from the same
> model as the target node and then the processor and the author won't
> have to both juggle the states of two models during the action (because
> remember some actions are deferred if they occur inside an xf:action,
> some aren't).
Either way I don't see anything wrong with it, implementation wise it
is solveable.

> I'm just speculating.  I have no idea why the working group did what it
> did.  I'm just saying that if you approach them with your usecase,
> perhaps it will be addressed in a future version of the spec.  If they
> don't know of your concerns, then it will never change.
That what I did, you can see my message on [hidden email] list.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Peter Nunn-2
In reply to this post by Ivan Latysh-3
I have done a bit of looking into this one.  And I had thought it was
a bug in transformiix but I was wrong.  The behavior is quite correct.
Let me explain.
I created a small test instance to use in XMLSpy to test my theory:
<?xml version="1.0" encoding="UTF-8"?>
<instance xmlns="">
        <x1>
                <color>red</color>
                <color>green</color>
        </x1>
        <x2>
                <color>orange</color>
                <color>blue</color>
        </x2>
        <x3>
                <x4>
                        <color>black</color>
                        <color>white</color>
                </x4>
        </x3>
</instance>

If I perform the XPath //color I get the following:

red
green
orange
blue
black
white

which is the complete nodset that a repeat would produce.
If I then perform the folowing xpath //color[1] I get:

red
orange
black

if I perform an xpath of //color[2] I get:

green
blue
white

and If I perform //color[3] I get nothing.

So what is happening here.  A XPath returns a set of nodes that are
the local name and the axis of the node.  When you perform a query
with a selector of [1] it returns the first element of each axis whose
local name is 'color'.
Since we are binding to an output control the XForms spec states that
the first node of nodeset is displayed.  So when the index of the
repeat is 1 the node is the first, when 2 the node is the second when
3 there is no node as there is no axis and local name matching that
axis.

regards
So the solution to the problem is that there is no problem, just a mis-
understanding of how xpath works.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
On Apr 14, 8:51 pm, "peter nunn" <[hidden email]> wrote:

> So the solution to the problem is that there is no problem, just a mis-
> understanding of how xpath works.
Thank you for pointing out on my mistake, indeed I was wrong.

The right form would be:
<?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>Repeat scope</title>

    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
            <test><color>test-color</color></test>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
        </colors>
      </xf:instance>
    </xf:model>

  </head>

  <body>
      instance('myInstance')//color[1] = <xf:output
ref="instance('myInstance')//descendant::color[1]"/><br/>
      instance('myInstance')//color[2] = <xf:output
ref="instance('myInstance')//descendant::color[2]"/><br/>
      instance('myInstance')//color[3] = <xf:output
ref="instance('myInstance')//descendant::color[3]"/><br/>
      instance('myInstance')//color[4] = <xf:output
ref="instance('myInstance')//descendant::color[4]"/><br/>
      instance('myInstance')//color[4] = <xf:output
ref="instance('myInstance')//descendant::color[5]"/><br/>
  </body>
</html>

P.S. Sorry that I wasted your time.
I think this form should be added to the WIKI to prevent such mistakes
in the future.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: nested setvalue in repeat

Ivan Latysh-3
In reply to this post by Ivan Latysh-3
On Apr 11, 9:48 pm, "Ivan Latysh" <[hidden email]> wrote:
> On Apr 10, 8:08 pm, Aaron Reed <[hidden email]> wrote:

> > I'll admit that I can't see what is wrong with what you are doing in
> > this testcase.
>
> I am not doing anything wrong it is an issue that XPath evaluator
> unable to handle the node-set.

My apology to all, I was wrong.

Here is the complete form that can be added to the WIKI examples
section.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xf="http://www.w3.org/2002/xforms"
  xmlns:ev="http://www.w3.org/2001/xml-events"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <head>
    <title>Pick a Color example</title>

    <xf:model id="myModel">
      <xf:instance id="myInstance" xmlns="">
        <colors>
          <group>
            <color>blue</color>
            <color>red</color>
          </group>
          <group>
            <color>yellow</color>
            <color>white</color>
          </group>
          <group2>
            <color>pink</color>
            <color>orange</color>
          </group2>
          <color-index></color-index>
          <color-value></color-value>
        </colors>
      </xf:instance>
    </xf:model>

  </head>

  <body>
    <h2>Pick a color</h2>

    <xf:repeat nodeset="instance('myInstance')//color" model="myModel"
id="color-repeat">
      <div style="display: table-row">
        <div style="border-bottom: 1px solid black; display: table-
cell; width: 100px">
          <xf:output ref="."/>
        </div>
        <div style="border-bottom: 1px solid black; display: table-
cell;">
          <xf:trigger>
            <xf:label>Pick Me</xf:label>
            <xf:action ev:event="DOMActivate">
              <xf:setvalue ref="instance('myInstance')/color-index"
value="index('color-repeat')"/>
              <xf:setvalue ref="instance('myInstance')/color-value"
value="instance('myInstance')//descendant::color[index('color-
repeat')]"/>
            </xf:action>
          </xf:trigger>
        </div>
      </div>
    </xf:repeat>

    <p style="font-weight: bold">
      Your pick:<br/>
      <xf:output ref="instance('myInstance')//color-value">
        <xf:label>&#xA0;Color: </xf:label>
      </xf:output>
      <br/>
      <xf:output ref="instance('myInstance')/color-index">
        <xf:label>&#xA0;Index: </xf:label>
      </xf:output>
      <br/>
    </p>

  </body>
</html>

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms