def validate_structure(self, field):
    widgets = self.get_widgets(self.type.data)
    if field.data:
        try:
            transform_structure(widgets.values(), field.data)
        except XMLSyntaxError as e:
            raise ValidationError(e.msg.split(', line')[0])
def validate_structure(self, field):
    widgets = self.get_widgets(self.type.data)
    if field.data:
        try:
            transform_structure(widgets.values(), field.data)
        except XMLSyntaxError as e:
            raise ValidationError(e.msg.split(', line')[0])