Validation in Loop

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

Validation in Loop

Vinith Gowda
Hi,

The problem here might be simple but an immediate response is expected from here,

Consider i have 2 instances,

<xforms:instance id="credentials-instance">
   <instance>
     <Ids>
     <Id>IDENTITY1</Id>
     <Id>IDENTITY2</Id>
     <Id>IDENTITY3</Id>
     <Id>IDENTITY4</Id>
     <Id>IDENTITY5</Id>
     <Id>IDENTITY6</Id>
     </Ids>
 </instance>
</xforms:instance>

<xforms:instance id="create-credential-instance">       
   <instance>
        <newID/>
   </instance>
</xforms:instance>

Now I have a text input field for

<xforms:input ref="instance('create-credential-instance')//newID" />

I have to validate such that the entered value should not match for any of the Id in credentials-instance

I have written a Bind but is not working please help

<xforms:bind nodeset="instance('create-credential-instance')//newID" required="true()" constraint="if (.!='') then (. != instance('credentials-instance')//Ids/Id) else true()"/>


Thanks,
Vinith Gowda.
               
Reply | Threaded
Open this post in threaded view
|

Re: Validation in Loop

Erik Bruchez-3
Vinith,

I think that something like this should work:

<xforms:bind nodeset="instance('create-credential-instance')/newID"
required="true()"
  constraint=". = '' or not(. = instance('credentials-instance')/Ids/Id))"/>

The "=" in XPath is interesting: here it compares (after so-called
atomization) an atomic value (the string value in newID) with a
sequence of values (the string values in Id). The comparison returns
true() if at least one of the Id values is equal to the newId value.

When you use the != operator, the same goes: the comparison returns
true() if at least one of the Id values is *different* from the newId
value.

So instead of using !=, you want here to use not(... = ...).

-Erik

On Wed, Oct 28, 2009 at 11:54 PM, Vinith Gowda <[hidden email]> wrote:

>
> Hi,
>
> The problem here might be simple but an immediate response is expected from
> here,
>
> Consider i have 2 instances,
>
> <xforms:instance id="credentials-instance">
>   <instance>
>     <Ids>
>     <Id>IDENTITY1</Id>
>     <Id>IDENTITY2</Id>
>     <Id>IDENTITY3</Id>
>     <Id>IDENTITY4</Id>
>     <Id>IDENTITY5</Id>
>     <Id>IDENTITY6</Id>
>     </Ids>
>  </instance>
> </xforms:instance>
>
> <xforms:instance id="create-credential-instance">
>   <instance>
>        <newID/>
>   </instance>
> </xforms:instance>
>
> Now I have a text input field for
>
> <xforms:input ref="instance('create-credential-instance')//newID" />
>
> I have to validate such that the entered value should not match for any of
> the Id in credentials-instance
>
> I have written a Bind but is not working please help
>
> <xforms:bind nodeset="instance('create-credential-instance')//newID"
> required="true()" constraint="if (.!='') then (. !=
> instance('credentials-instance')//Ids/Id) else true()"/>
>
>
> Thanks,
> Vinith Gowda.
>
> --
> View this message in context: http://n4.nabble.com/Validation-in-Loop-tp277887p277887.html
> Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.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
>
>


--
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: [ops-users] Validation in Loop

Vinith Gowda
This resolves my problem.
 
Thanks.
 
Best Regards,
Vinith Gowda.
 


From: Erik Bruchez-3 [via ObjectWeb OPS] [mailto:[hidden email]]
Sent: Saturday, October 31, 2009 6:59 AM
To: Vinith Gowda
Subject: Re: [ops-users] Validation in Loop

Vinith,

I think that something like this should work:

<xforms:bind nodeset="instance('create-credential-instance')/newID"
required="true()"
  constraint=". = '' or not(. = instance('credentials-instance')/Ids/Id))"/>

The "=" in XPath is interesting: here it compares (after so-called
atomization) an atomic value (the string value in newID) with a
sequence of values (the string values in Id). The comparison returns
true() if at least one of the Id values is equal to the newId value.

When you use the != operator, the same goes: the comparison returns
true() if at least one of the Id values is *different* from the newId
value.

So instead of using !=, you want here to use not(... = ...).

-Erik

On Wed, Oct 28, 2009 at 11:54 PM, Vinith Gowda <[hidden email]> wrote:

>
> Hi,
>
> The problem here might be simple but an immediate response is expected from
> here,
>
> Consider i have 2 instances,
>
> <xforms:instance id="credentials-instance">
>   <instance>
>     <Ids>
>     <Id>IDENTITY1</Id>
>     <Id>IDENTITY2</Id>
>     <Id>IDENTITY3</Id>
>     <Id>IDENTITY4</Id>
>     <Id>IDENTITY5</Id>
>     <Id>IDENTITY6</Id>
>     </Ids>
>  </instance>
> </xforms:instance>
>
> <xforms:instance id="create-credential-instance">
>   <instance>
>        <newID/>
>   </instance>
> </xforms:instance>
>
> Now I have a text input field for
>
> <xforms:input ref="instance('create-credential-instance')//newID" />
>
> I have to validate such that the entered value should not match for any of
> the Id in credentials-instance
>
> I have written a Bind but is not working please help
>
> <xforms:bind nodeset="instance('create-credential-instance')//newID"
> required="true()" constraint="if (.!='') then (. !=
> instance('credentials-instance')//Ids/Id) else true()"/>
>
>
> Thanks,
> Vinith Gowda.
>
> --
> View this message in context: http://n4.nabble.com/Validation-in-Loop-tp277887p277887.html
> Sent from the ObjectWeb OPS - Users mailing list archive at Nabble.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
>
>

--
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



View message @ http://n4.nabble.com/Validation-in-Loop-tp277887p305309.html
To unsubscribe from Validation in Loop, click here.