Skip to content
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

Output empty <label/> instead of omitting it. #439

Closed
MartijnR opened this issue Mar 16, 2020 · 4 comments · Fixed by #543
Closed

Output empty <label/> instead of omitting it. #439

MartijnR opened this issue Mar 16, 2020 · 4 comments · Fixed by #543

Comments

@MartijnR
Copy link
Contributor

MartijnR commented Mar 16, 2020

Currently pyxform requires either a value in the "label" column or in the "hint" column for form controls (ie. questions in the body). This validation rule can remain unchanged.

However, as @tiritea discovered, a <label> element is actually required according to the XForms spec. Therefore, we should include an empty <label/> (or <label></label>) element in the body output. This is currently not the case.

Test 1

type name label hint
text a a hint
text b A label
<input ref="/data/a">
    <label/>
    <hint>a hint</hint>
</input>
<input ref="/data/b">
    <label>A label</label>
</input>
@lindsay-stevens
Copy link
Contributor

@lognaturel / @MartijnR it looks like the error for no hint comes from ODK Validate rather than pyxform. Should pyxform warn / error about no hint, or just emit a label to comply with the spec and ODK Validate?

It doesn't seem like an error is necessary, since adding the empty label XML node shouldn't affect how the survey works. But maybe it does for some tools?

@MartijnR
Copy link
Contributor Author

Hi @lindsay-stevens. Welcome back!

Should pyxform warn / error about no hint, or just emit a label to comply with the spec and ODK Validate?

If ODK Validate does not get fooled by an empty label (and still requires either a label or hint text content), then I think outputting an empty label in pyxform is all that is required.

@KeynesYouDigIt
Copy link
Contributor

@lindsay-stevens Are you already working on this? If not I might be able to take a swing at it! let me know either way

@lindsay-stevens
Copy link
Contributor

@MartijnR thanks!
@KeynesYouDigIt yes I have a draft that I'll create a PR for this week.

lindsay-stevens added a commit to lindsay-stevens/pyxform that referenced this issue Jul 5, 2021
- as per pyxform/XLSForm#439, should always output a label node even if there
  is no label specified.
- pyxform had a warning for no label but this is removed since there is
  no requirement for a label.
- add tests to verify that a label is output and no warning raised
- fix existing tests that either expected a warning or no label
lindsay-stevens added a commit to lindsay-stevens/pyxform that referenced this issue Jul 28, 2021
- label check block applies to questions and other item types such as
  groups and repeats, so may be valid in other scenarios
- for example this block is referenced in XLSForm#542
- will require further changes to exclude question items from the check
  since that is the intent in XLSForm#439
yanokwa pushed a commit to yanokwa/pyxform that referenced this issue Jul 28, 2021
- as per pyxform/XLSForm#439, should always output a label node even if there
  is no label specified.
- pyxform had a warning for no label but this is removed since there is
  no requirement for a label.
- add tests to verify that a label is output and no warning raised
- fix existing tests that either expected a warning or no label
yanokwa pushed a commit to yanokwa/pyxform that referenced this issue Jul 28, 2021
- label check block applies to questions and other item types such as
  groups and repeats, so may be valid in other scenarios
- for example this block is referenced in XLSForm#542
- will require further changes to exclude question items from the check
  since that is the intent in XLSForm#439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants