boolean validation with whitespace
Brought to you by:
dkuhlman
XML Schema boolean datatype should be normalized during validation with a whiteSpace facet of collapse. In other words leading and trailing whitespace should be ignored.
My input XML failed to validate after prettifying it. Hacking the single boolean element in it to remove whitespace allowed the validation to complete.
I was also able to use an alternative solution of hacking the Python generated generated by generateDS.py. This change looks to be equally applicable to generateDS.py itself.
def gds_parse_boolean(self, input_data, node=None, input_name=''):
if input_data.strip() in ('true', '1'):
bval = True
elif input_data.strip() in ('false', '0'):
bval = False
else:
raise_parse_error(node, 'Requires boolean value')
return bval
Pete,
Thanks for reporting this.
Attached is a patch -- actually, it's just the change that you suggest above.
If it looks good to you, let me know, and it will be in the next release.
Dave
That works but I did a small refinement to my fix. Your patch also includes the second iteration of fix for ticket #29. So here is what I am using for this ticket alone rather than a patch.
Great,
That patch, including your refinement, has now been uploaded as v. 2.40.12.
Thanks again.
Dave