Incorrect regex from xs:pattern
Brought to you by:
dkuhlman
I have the following element definition:
<xs:simpleType name="ID_String">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z0-9-]{16}-(ELXP|NGET)-RMT-[0-9]{8}"/>
<xs:maxLength value="34" />
</xs:restriction>
</xs:simpleType>
And in the generated Python code I receive the following regex:
validate_ID_String_patterns_ = [['^[A-Z0-9-]{16}-(ELXP$|NGET)-RMT-[0-9]{8}$']]
Which is definitely incorrect because "ELXP" should not contain end tag.
Example string received in XML: 48X0000000003024-ELXP-RMT-99005821
As a result I have warning:
myfilename.py:739: UserWarning: Value "b'48X0000000003024-ELXP-RMT-99005821'" does not match xsd pattern restrictions: [['^[A-Z0-9-]{16}-(ELXP$|NGET)-RMT-[0-9]{8}$']]
warnings_.warn('Value "%s" does not match xsd pattern restrictions: %s' % (value.encode('utf-8'), self.validate_ID_String_patterns_, ))```
Alexey,
Trying to diagnose this ...
I used this XML schema:
When I generate a module with
generateDS.py
I get the following pattern:I used the following XML instance document:
If I run the following, I see:
Can you think of something else I can do in order to track this down?
I'm using the following:
Are you using an earlier version of gDS, perhaps?
Or, maybe Python 2.x? I'll check that tomorrow. And, I'll look at your other ticket.
Dave
Last edit: Dave Kuhlman 2021-10-06
Dave, my apologies. It seems I mistakenly took an old file generated more than 4 years ago with version 2.26a.
I've tried again and it works fine with 2.40.3 and Python 3.8.10
You may close this ticket.
Great tool by the way, thank you for your work!