Menu

#30 Namespace Recursion

1.0
open
nobody
None
2023-03-27
2022-04-18
No

Hi,

I'm triying to generate a class for a UBL xsd (https://docs.oasis-open.org/ubl/prd1-UBL-2.1/xsd/common/UBL-CommonBasicComponents-2.1.xsd) and I get the following error:

RuntimeError: Extension/restriction recursion detected.  Suggest you check definitions of types TextType and TextType.

The recursion is generated at this line:

<xsd:complexType name="TextType">
      <xsd:simpleContent>
         <xsd:extension base="udt:TextType"/>
      </xsd:simpleContent>
 </xsd:complexType>

The names are the same but the namespace is different.

Discussion

  • Dave Kuhlman

    Dave Kuhlman - 2022-04-19

    David,

    Thanks for the report and the link to the schemas.

    I've looked into this a bit.
    I don't think I'm going to be able to fix it.

    It looks like fixes would be needed at multiple places in the code.
    There are several other places in the code where similar
    recursion-limit-exceeded occurs. And, I don't even know the correct
    way to fix any of those places. I can patch those to skip the
    recursion error, but then the module that we generate is incomplete.

    If you have a suggestion or a patch, please let me know.

    I'll do a little more study, but I don't have that hope.

    Dave

     
  • Ameya Vikram Singh

    I hit into this issue recently while trying to convert an xsd specification to python classes using this tool.
    I am using the following repository to convert IP-XACT xsd specification:
    https://github.com/olofk/ipxact_gen

    I used the following command to generate a single file output:

    PYTHONPATH=. generateDS -f -o pyout/ipx.py --user-methods=gends_user_methods.py 2014/index.xsd
    

    Which results in successful conversion with some warnings:

    *** warning.  Removing child with duplicate name: "activeInterface"
    *** warning.  Removing child with duplicate name: "hierInterface"
    *** warning.  Removing child with duplicate name: "range"
    *** warning.  Removing child with duplicate name: "driveConstraint"
    *** warning.  Removing child with duplicate name: "loadConstraint"
    *** warning.  Removing child with duplicate name: "loadConstraint"
    *** warning.  child loadConstraint already removed
    *** warning.  Removing child with duplicate name: "externalPortReference"
    *** warning.  Removing child with duplicate name: "linkerCommandFile"
    

    But when trying to enable the --one-file-per-xsd option to have a bunch of python modules to be used to support reading IP-XACT xml files.

    PYTHONPATH=. generateDS -f --one-file-per-xsd --output-directory pyout --module-suffix="ipxact" -o ipx --user-methods=gends_user_methods.py 2014/index.xsd
    

    It fails with the error message mentioned below:

    *** warning.  Removing child with duplicate name: "range"
    *** warning.  Removing child with duplicate name: "externalPortReference"
    *** warning.  Removing child with duplicate name: "activeInterface"
    *** warning.  Removing child with duplicate name: "hierInterface"
    *** warning.  Removing child with duplicate name: "driveConstraint"
    *** warning.  Removing child with duplicate name: "loadConstraint"
    *** warning.  Removing child with duplicate name: "loadConstraint"
    *** warning.  child loadConstraint already removed
    *** warning.  Removing child with duplicate name: "linkerCommandFile"
    Traceback (most recent call last):
      File "/home/ameya/venv/bin/generateDS", line 8, in <module>
        sys.exit(main())
                 ^^^^^^
      File "/home/ameya/venv/bin/generateDS.py", line 9939, in main
        parseAndGenerate(
      File "/home/ameya/venv/bin/generateDS.py", line 9385, in parseAndGenerate
        root.annotate()
      File "/home/ameya/venv/bin/generateDS.py", line 1071, in annotate
        self.fix_dup_names(already_seen)
      File "/home/ameya/venv/bin/generateDS.py", line 1496, in fix_dup_names
        child.fix_dup_names(already_seen)
      File "/home/ameya/venv/bin/generateDS.py", line 1496, in fix_dup_names
        child.fix_dup_names(already_seen)
      File "/home/ameya/venv/bin/generateDS.py", line 1464, in fix_dup_names
        self.collectElementNames(elementNames, 0)
      File "/home/ameya/venv/bin/generateDS.py", line 1511, in collectElementNames
        parent.collectElementNames(elementNames, count)
      File "/home/ameya/venv/bin/generateDS.py", line 1511, in collectElementNames
        parent.collectElementNames(elementNames, count)
      File "/home/ameya/venv/bin/generateDS.py", line 1511, in collectElementNames
        parent.collectElementNames(elementNames, count)
      [Previous line repeated 97 more times]
      File "/home/ameya/venv/bin/generateDS.py", line 1510, in collectElementNames
        raise RuntimeError(msg)
    RuntimeError: Extension/restriction recursion detected.  Suggest you check definitions of types apiType and apiType.
    

    Seems like it falls over while trying to split into multiple files, but single file generation works without any issues.

    Let me know in case you need more inputs.

    Ameya

     

Log in to post a comment.