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 |
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
>>> "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 |
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 |
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, -- 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 |
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
>>> 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, -- 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 |
Free forum by Nabble | Edit this page |