Validation in Loop

3 messages Options
Embed this post
Permalink
Vinith Gowda

Validation in Loop

Reply Threaded More More options
Print post
Permalink
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.
               
Erik Bruchez-3

Re: Validation in Loop

Reply Threaded More More options
Print post
Permalink
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
Vinith Gowda

RE: [ops-users] Validation in Loop

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
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