Problem with drop-down list data validation in repeating section/t

M

Mike Lansdaal

I am trying to design an InfoPath 2003 form and I am not having any
success with implementing a data validation rule on a drop-down list.

My simple test case XML looks like this:

<Example>
<Cars>
<Car maker="Ford" >
<Model name="F150" />
<Model name="Taurus" />
</Car>
<Car maker="Honda" >
<Model name="Civic" />
<Model name="Odessey" />
</Car>
<Car maker="Toyota" >
<Model name="Corolla" />
<Model name="Cellica" />
</Car>
</Cars>
<Inventory>
<vehicle maker="Ford" id="1" model="Taurus" />
<vehicle maker="Ford" id="2" model="F150" />
<vehicle maker="Honda" id="4" model="Civic" />
<vehicle maker="Toyota" id="5" model="Cellica" />
</Inventory>
</Example>

I have a repeating table for the <Inventory> section and the
maker and model columns are drop-down lists. The values for
both drop down lists are coming from another (reference) section
of the XML file (the <Car> nodes in the example). What I am trying
to do is have a validation rule on the model drop-down list
so that the control shows an error if it's value is not
listed for the maker. I can successfully filter the data values
shown in the model drop-down list based on the current maker
selection, but if the user changes the maker drop-down list
the model drop-down list to be invalidated (shows
red dashed border) as the value it has is no longer valid
(for the selected maker). Similarly, if the user edits the
<Car> reference information, the currently selected value(s) in
the model drop-down lists can be become invalidated.

When I put a data validation rule on the model drop-down list
( @name does not contain @model ), only the very first value in
the model drop-down is considered valid and legitimate values
are being declared as invalid values. I suspected that this is
a similar issue to data filtering with repeating elements and
tried to change the data validation rule to be
( @name does not contain current()/@model ). This is accepted
by InfoPath as valid, but when I go to preview the form, I get
the error that the form is invalid:


The form definition (.xsf) file contains the following error:

Illegal "expression" expression:
self::node()[not(contains(../../../Cars/Car/Model/@name, current()/@Model))]
Unknown method.

self::node()[not(contains(../../../Cars/Car/Model/@name,
-->current()<--/@Model))]

I can instead implement some managed code to do the validation,
but I'm left thinking that there should be some way to do this
within InfoPath.

TIA, Mike Lansdaal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top