-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for choice from previous repeat answers #381
Conversation
c8041a0
to
21cf594
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be so useful! Few comments inline.
if depth > 2: | ||
name = path[-1] | ||
nodeset = "/".join( | ||
path[:-2] + [path[-2] + "[string-length(./" + name + ") > 0]"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that string-length(./" + name + ") > 0
is not intended to be hardcoded. It should just be whatever the contents of the choice_filter
column is.
With the following definition:
type | name | label | choice_filter |
---|---|---|---|
begin repeat | rep | ||
text | food | Enter food | |
end repeat | |||
select_one ${food} | choice | Choose |
There should be no predicate at all.
With the following definition:
type | name | label | choice_filter |
---|---|---|---|
begin repeat | rep | ||
text | food | Enter food | |
end repeat | |||
select_one ${food} | choice | Choose | starts-with(., "b") |
The predicate should be starts-with(., "b")
.
Note that the choice filter/predicate could possibly include a reference to another node (starts-with(., ${favorite_letter}
).
nodeset = "/".join( | ||
path[:-2] + [path[-2] + "[string-length(./" + name + ") > 0]"] | ||
) | ||
itemset_children = [node("value", ref=name), node("label", ref=name)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to #370 because the values will be user-generated and could contain spaces. If this turns out to be a popular feature, we may want to allow users to specify value
and label
separately. I don't think this needs to be done now but wanted to call it out in case that changes things for anyone.
self.assertPyxformXform( | ||
md=xlsform_md, | ||
xml__contains=[ | ||
'<itemset nodeset="/pyxform_autotestname/rep[string-length(./name) > 0]">' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be a predicate.
Superseded by #472 |
Fix #38