Xforms:bind question

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

Xforms:bind question

Henrik Pettersen
All,

I have a couple of questions on Xforms bind that I hoped one of you might be able to assist me with.

I have this instance:

  <aspic:rule xmlns:aspic=" http://www.cruk.com/aspic/editor/v1">
      <aspic:premise>
          <aspic:expression>penguin(X)</aspic:expression>
          <aspic:test>
              <aspic:parseable>true</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>

      <aspic:premise>
          <aspic:expression>penguin(X)</aspic:expression>
          <aspic:test>
              <aspic:parseable>true</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>
  </aspic:rule>


  There are 2 tests I want the instance to pass before it gets submitted.
  1. There must be at least one premise element. The premise elements can be added and removed,
      and the requirement is that there exists at least one premise at the time of submission
  2. The value at /aspic:rule/aspic:premise/aspic:test/aspic:parseable must be 'true'

  In the example above, the instance is valid. Here is an instance that violate the first rule:

  <aspic:rule xmlns:aspic=" http://www.cruk.com/aspic/editor/v1">
  </aspic:rule>

  And here is an instance that violate the second rule:

    <aspic:rule xmlns:aspic=" http://www.cruk.com/aspic/editor/v1">
      <aspic:premise>
          <aspic:expression>penguin(X)</aspic:expression>
          <aspic:test>
              <aspic:parseable>true</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>

      <aspic:premise>
          <aspic:expression>penguin(X</aspic:expression>
          <aspic:test>
              <aspic:parseable>false</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>
  </aspic:rule>

Question is, how do I enforce these restrictions using XForms bind?

Here is my current attempt, which is not doing what I want:

  <xforms:bind nodeset="instance('rule-instance')">
   <xforms:bind nodeset="aspic:premise" required="last() > 1"/> <!-- Test 1 -->
   <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable" required=". = true()"/> <!-- Test 2 -->
  </xforms:bind>


Any ideas, anyone?

Sincerely,
Henrik Pettersen
Advanced Computation Laboratory
Cancer Research UK

--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms:bind question

David McIntyre
Perhaps the constraint attribute would be more suitable than the required attribute?  Would the following work?
 
<xforms:bind nodeset="instance('rule-instance')" constraint="count(aspic:premise) gt 0"> <!-- Test 1 -->
   <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable" constraint=". = 'true'"/> <!-- Test 2 --> 
</xforms:bind>
Cheers,
 
    Dave McIntyre
 
 
Dave McIntyre
Software Developer
2nd Floor, Orion House, cnr Enfield & Mary St, Mt Eden, PO Box 8273, Auckland, New Zealand
M.+64 21 212 8087 P.+64 9 638 0600 F.+64 9 638 0699
S.<A href="callto:dave.mcintyre">dave.mcintyre E.[hidden email] W.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.


>>> "Henrik Pettersen" <[hidden email]> 22/11/2006 11:45 a.m. >>>
All,

I have a couple of questions on Xforms bind that I hoped one of you might be able to assist me with.

I have this instance:

  <aspic:rule xmlns:aspic=" http://www.cruk.com/aspic/editor/v1">
      <aspic:premise>
          <aspic:expression>penguin(X)</aspic:expression>
          <aspic:test>
              <aspic:parseable>true</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>

      <aspic:premise>
          <aspic:expression>penguin(X)</aspic:expression>
          <aspic:test>
              <aspic:parseable>true</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>
  </aspic:rule>


  There are 2 tests I want the instance to pass before it gets submitted.
  1. There must be at least one premise element. The premise elements can be added and removed,
      and the requirement is that there exists at least one premise at the time of submission
  2. The value at /aspic:rule/aspic:premise/aspic:test/aspic:parseable must be 'true'

  In the example above, the instance is valid. Here is an instance that violate the first rule:

  <aspic:rule xmlns:aspic=" http://www.cruk.com/aspic/editor/v1">
  </aspic:rule>

  And here is an instance that violate the second rule:

    <aspic:rule xmlns:aspic=" http://www.cruk.com/aspic/editor/v1">
      <aspic:premise>
          <aspic:expression>penguin(X)</aspic:expression>
          <aspic:test>
              <aspic:parseable>true</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>

      <aspic:premise>
          <aspic:expression>penguin(X</aspic:expression>
          <aspic:test>
              <aspic:parseable>false</aspic:parseable>
              <aspic:hint>Expression complete</aspic:hint>
          </aspic:test>
      </aspic:premise>
  </aspic:rule>

Question is, how do I enforce these restrictions using XForms bind?

Here is my current attempt, which is not doing what I want:

  <xforms:bind nodeset="instance('rule-instance')">
   <xforms:bind nodeset="aspic:premise" required="last() > 1"/> <!-- Test 1 -->
   <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable" required=". = true()"/> <!-- Test 2 -->
  </xforms:bind>


Any ideas, anyone?

Sincerely,
Henrik Pettersen
Advanced Computation Laboratory
Cancer Research UK


--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms:bind question

Erik Bruchez
Administrator
In reply to this post by Henrik Pettersen
Henrik,

 >   There are 2 tests I want the instance to pass before it gets submitted.
 >   1. There must be at least one premise element. The premise elements
 > can be added and removed,
 >       and the requirement is that there exists at least one premise at
 > the time of submission
 >   2. The value at /aspic:rule/aspic:premise/aspic:test/aspic:parseable
 > must be 'true'

 > Question is, how do I enforce these restrictions using XForms bind?
 >
 > Here is my current attempt, which is not doing what I want:
 >
 >   <xforms:bind nodeset="instance('rule-instance')">
 >    <xforms:bind nodeset="aspic:premise" required="last() > 1"/> <!--
 > Test 1 -->
 >    <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable"
 > required=". = true()"/> <!-- Test 2 -->
 >   </xforms:bind>

What about:

   <xforms:bind nodeset="instance('rule-instance')">
    <xforms:bind nodeset="." constraint="count(aspic:premise) > 0"/>
    <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable"
constraint=". = 'true'"/>
   </xforms:bind>

-Erik

--
Orbeon Forms - XForms Everywhere
http://www.orbeon.com/blog/




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms:bind question

Henrik Pettersen
Erik, David, et al.,

both approaches work swimmingly. Thank you!

However, fix one and find a new one. My whole approach seems to be flawed, and I'm not sure how to start again:
http://mail-archive.objectweb.org/ops-users/2006-11/msg00397.html

Does anyone out there have an idea?

Henrik

On 11/24/06, Erik Bruchez <[hidden email]> wrote:
Henrik,

>   There are 2 tests I want the instance to pass before it gets submitted.
>   1. There must be at least one premise element. The premise elements
> can be added and removed,
>       and the requirement is that there exists at least one premise at
> the time of submission
>   2. The value at /aspic:rule/aspic:premise/aspic:test/aspic:parseable
> must be 'true'

> Question is, how do I enforce these restrictions using XForms bind?
>
> Here is my current attempt, which is not doing what I want:
>
>   <xforms:bind nodeset="instance('rule-instance')">
>    <xforms:bind nodeset="aspic:premise" required="last() > 1"/> <!--
> Test 1 -->
>    <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable"
> required=". = true()"/> <!-- Test 2 -->
>   </xforms:bind>

What about:

   <xforms:bind nodeset="instance('rule-instance')">
    <xforms:bind nodeset="." constraint="count(aspic:premise) > 0"/>
    <xforms:bind nodeset="aspic:premise/aspic:test/aspic:parseable"
constraint=". = 'true'"/>
   </xforms:bind>

-Erik

--
Orbeon Forms - XForms Everywhere
http://www.orbeon.com/blog/





--
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
ObjectWeb mailing lists service home page: http://www.objectweb.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms:bind question

David McIntyre
In reply to this post by Henrik Pettersen
This is not thoroughly thought through, just an idea of what I would try.  Something along the lines of
 
<xforms:submission id="test-rule-submission"
        ref="instance('rule-instance')"
        method="post"
        action="whatever"
        replace="instance"
        instance="rule-instance"
        validate="false">
    <xforms:send submission="update-rule-submission" ev:event="xforms-submit-done"/>
</xforms:submission/>
 
<xforms:submission id="update-rule-submission"
                       ref="instance('rule-instance')"
                       method="post"
                       action="" />
 
I would expect the validate="false" to mean that the first submission will be sent even if the instance is not valid, but the second one would fail if the instance is not valid after the first one has completed.  This should at least be worth a try...
 
Cheers,
 
    Dave McIntyre
 
 
Dave McIntyre
Software Developer
2nd Floor, Orion House, cnr Enfield & Mary St, Mt Eden, PO Box 8273, Auckland, New Zealand
M.+64 21 212 8087 P.+64 9 638 0600 F.+64 9 638 0699
S.<A href="callto:dave.mcintyre">dave.mcintyre E.[hidden email] W.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.

>>> Henrik Pettersen 25/11/2006 3:39 a.m. >>>
Erik, David, et al.,

both approaches work swimmingly. Thank you!

However, fix one and find a new one. My whole approach seems to be flawed, and I'm not sure how to start again:
http://mail-archive.objectweb.org/ops-users/2006-11/msg00397.html

Does anyone out there have an idea?

Henrik

On 11/24/06, Erik Bruchez < < [hidden email]> > wrote:
Henrik,

> >   There are 2 tests I want the instance to pass before it gets submitted.
> >   1. There must be at least one premise element. The premise elements
> > can be added and removed,
> >       and the requirement is that there exists at least one premise at
> > the time of submission
> >   2. The value at /aspic:rule/aspic:premise/aspic:test/aspic:parseable
> > must be 'true'

> > Question is, how do I enforce these restrictions using XForms bind?
> >
> > Here is my current attempt, which is not doing what I want:
> >
> >   < < xforms:bind nodeset=" instance('rule-instance')" " > >
> >     < < xforms:bind nodeset=" aspic:premise" required=" last() > >1" /> > < < !--
> > Test 1 --> >
> >     < < xforms:bind nodeset=" aspic:premise/aspic:test/aspic:parseable"
> > required=" . = true()" /> > < < !-- Test 2 --> >
> >   < < /xforms:bind> >

What about:

  < < xforms:bind nodeset=" instance('rule-instance')" > >
    < < xforms:bind nodeset=" ." constraint=" count(aspic:premise) > >0" /> >
    < < xforms:bind nodeset=" aspic:premise/aspic:test/aspic:parseable"
constraint=" . = 'true'" /> >
  < < /xforms:bind> >

-Erik

--
Orbeon Forms - XForms Everywhere
http://www.orbeon.com/blog/





--
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
ObjectWeb mailing lists service home page: http://www.objectweb.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws