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

xmlschema incorrectly reports validation failure for IODD1.1 schema and validated example files. Python 3.13 #434

Open
AScholan opened this issue Feb 6, 2025 · 0 comments

Comments

@AScholan
Copy link

AScholan commented Feb 6, 2025

General

IODD is an XML format hardware description file used for IO-Link process control hardware. There is a published standard, schema, and examples. The following link gives access to the publish standard: IO Device Description Specification V1.1.4 (with Schemas and Standard Definitions).

Issue

When using xmlschema with Python 3.13 to validate at least one XML example file the validate method raises a validation failure. See logs at end.

How to reproduce

Example Repo

Clone repo: AScholan/XmlSchemaError

This includes the schema files, the example xml file and the python script that demonstrates the error.

System configuration

OS: Windows 10
Python: 3.13.1
xmlschema: 3.4.3

Instructions

  1. pip install the requirements.txt file.
  2. Execute script xmlschema_error.py.

Logs

Below are logs generated from the script above.

C:\RnD\io-link\projects\XmlSchemaError\.venv\Scripts\python.exe C:\RnD\io-link\projects\XmlSchemaError\xmlschema_error.py 
Traceback (most recent call last):
  File "C:\RnD\io-link\projects\XmlSchemaError\xmlschema_error.py", line 8, in <module>
    schema.validate(EXAMPLES_DIR / 'IO-Link-01-BasicDevice-20211215-IODD1.1.xml')
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RnD\io-link\projects\XmlSchemaError\.venv\Lib\site-packages\xmlschema\validators\schemas.py", line 1707, in validate
    for error in self.iter_errors(source, path, schema_path, use_defaults,
                 ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                  namespaces, max_depth, extra_validator,
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                  validation_hook, allow_empty, use_location_hints,
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                  validation='strict'):
                                  ^^^^^^^^^^^^^^^^^^^^
  File "C:\RnD\io-link\projects\XmlSchemaError\.venv\Lib\site-packages\xmlschema\validators\schemas.py", line 1838, in iter_errors
    for result in xsd_element.iter_decode(elem, **kwargs):
                  ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "C:\RnD\io-link\projects\XmlSchemaError\.venv\Lib\site-packages\xmlschema\validators\elements.py", line 857, in iter_decode
    yield self.validation_error(validation, error, obj, **kwargs)
          ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RnD\io-link\projects\XmlSchemaError\.venv\Lib\site-packages\xmlschema\validators\xsdbase.py", line 250, in validation_error
    raise error
xmlschema.validators.exceptions.XMLSchemaValidationError: failed validating <Element '{http://www.io-link.com/IODD/2010/10}IODevice' at 0x000001FF080F9620> with XsdElement(name='iodd:IODevice', occurs=[1, 1]):

Reason: value ('ioddsample01',) not found for XsdKey(name='iodd:ProductRef_ProductId')

Schema component:

  <xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IODevice">
      <xsd:complexType>
          <xsd:sequence>
              <xsd:element name="DocumentInfo" type="DocumentInfoT" />
              <xsd:element name="ProfileHeader" type="ProfileHeaderT" />
              <xsd:element name="ProfileBody" type="ProfileBodyT" />
              <xsd:element name="CommNetworkProfile" type="CommNetworkProfileT" />
              <xsd:element name="ExternalTextCollection" type="ExternalTextCollectionT">
                  <xsd:unique name="Language">
                      <xsd:selector xpath="iodd:PrimaryLanguage|iodd:Language" />
                      <xsd:field xpath="@xml:lang" />
                  </xsd:unique>
              </xsd:element>
              <xsd:element name="Stamp" type="StampT">
                  <xsd:annotation>
                      <xsd:documentation>Filled out by the IODD Checker.</xsd:documentation>
                  </xsd:annotation>
              </xsd:element>
          </xsd:sequence>
      </xsd:complexType>
      ...
      ...
  </xsd:element>

Instance type: <class 'xml.etree.ElementTree.Element'>

Instance:

  <IODevice xmlns="http://www.io-link.com/IODD/2010/10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.io-link.com/IODD/2010/10 IODD1.1.xsd">
    <DocumentInfo version="V1.00.000" releaseDate="2021-12-15" copyright="Copyright IO-Link Community 2021" />
    <ProfileHeader>
      <ProfileIdentification>IO Device Profile</ProfileIdentification>
      <ProfileRevision>1.1</ProfileRevision>
      <ProfileName>Device Profile for IO Devices</ProfileName>
      <ProfileSource>IO-Link Consortium</ProfileSource>
      <ProfileClassID>Device</ProfileClassID>
      <ISO15745Reference>
        <ISO15745Part>1</ISO15745Part>
        <ISO15745Edition>1</ISO15745Edition>
        <ProfileTechnology>IODD</ProfileTechnology>
      </ISO15745Reference>
    </ProfileHeader>
    <ProfileBody>
      <DeviceIdentity vendorId="65535" deviceId="1" vendorName="IO-Link Community">
        <VendorText textId="T_VendorText" />
        <VendorUrl textId="T_VendorUrl" />
        <VendorLogo name="IO-Link-logo.png" />
        <DeviceName textId="T_DeviceName" />
    ...
    ...
  </IODevice>

Path: /IODevice
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

No branches or pull requests

1 participant