Reverse cascading choice - #2 by LN and Loop over pre-established list - #6 by LN have more about the general strategy.
The first issue with your form is that you're not forcing pyxform to create instances. This is needed for this approach (more here). One simple way to do this in your form is to add true()
to the choice_filter
column of the stock-item
question.
Then you're taking label in item
and trying to compare it with name
in the following two lookups. I'd recommend using the index for all three expressions.
You're also running into a bug which I've documented at https://github.com/XLSForm/pyxform/issues/490 which means you won't be able to mix and match XPath and ${}
notation in this case. You'll have to expand your three queries to:
instance('item')/root/item[itemindex=current()/../item-counter]/label
instance('item')/root/item[itemindex=current()/../item-counter]/quality
instance('item')/root/item[itemindex=current()/../item-counter]/unit