Menu

#31 boolean validation with whitespace

1.0
open
nobody
None
2022-05-09
2022-05-05
Pete Forman
No

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

Discussion

  • Dave Kuhlman

    Dave Kuhlman - 2022-05-05

    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

     
  • Pete Forman

    Pete Forman - 2022-05-06

    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.

            def gds_parse_boolean(self, input_data, node=None, input_name=''):
                input_data = input_data.strip()
                if input_data in ('true', '1'):
                    bval = True
                elif input_data in ('false', '0'):
                    bval = False
                else:
                    raise_parse_error(node, 'Requires boolean value')
                return bval
    
     
  • Dave Kuhlman

    Dave Kuhlman - 2022-05-09

    Great,

    That patch, including your refinement, has now been uploaded as v. 2.40.12.

    Thanks again.

    Dave

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.