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

XMLSchemaParseError: wrong definition with self-reference #278

Closed
winglian opened this issue Dec 22, 2021 · 2 comments
Closed

XMLSchemaParseError: wrong definition with self-reference #278

winglian opened this issue Dec 22, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@winglian
Copy link

winglian commented Dec 22, 2021

I'm trying to load this XSD but I get the error below. I've been able to load this Schema with another library such as pyxb, so I'm not sure what I'm doing wrong here. My gut says it may be a bug where the library thinks that it's a self reference in the ERM namespace when in fact its a reference to another definition in the avs namespace. Any help is greatly appreciated. Thanks!

XMLSchemaParseError: wrong definition with self-reference:

Schema:

  <xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" name="AllTerritoryCode">
     <xs:annotation>
        <xs:documentation source="ddex:Definition">A Composite containing details of a
           TerritoryCode.</xs:documentation>
     </xs:annotation>
     <xs:simpleContent>
        <xs:extension base="avs:AllTerritoryCode">
           <xs:attribute name="IdentifierType" type="avs:TerritoryCodeTypeIncludingDeprecatedCodes">
              <xs:annotation>
                 <xs:documentation source="ddex:Definition">A standard used for the TerritoryCode.
                    This is represented in an XML schema as an XML Attribute. If this Attribute is
                    not provided, it is assumed that the code is a TerritoryCode in accordance with
                    ISO 3166-1 Alpha 2 standard (or Worldwide).</xs:documentation>
              </xs:annotation>
           </xs:attribute>
        </xs:extension>
     </xs:simpleContent>
  </xs:complexType>

Path: /xs:schema/xs:complexType[58]
@brunato brunato added the bug Something isn't working label Dec 23, 2021
@brunato
Copy link
Member

brunato commented Dec 23, 2021

Hi,

this is due to an error in XMLSchemaBase.simple_type_factory() when determine the name of the new type:

xsd_type.name = get_qname(self.target_namespace, elem.attrib['name'])

this line has to be fixed using the target namespace of the schema associated to xsd_type:

            xsd_type.name = get_qname(schema.target_namespace, elem.attrib['name'])

usually the xsd_type.name is not checked so this error has no caused problems until now, but in these schemas the other namespace has a derivation from a simple type with the same local name that raises an error.

This fix will be included in the next release. Until that you can patch on your installed package or build the schema providing validation='lax'.

Thank you

@brunato
Copy link
Member

brunato commented Dec 23, 2021

Fixed by release v1.9.2.

@brunato brunato closed this as completed Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants