1

I have several XSD files from which we have generated python bindings with pyxb (1.2.6). Each of these XSD files use the same namespace. Some of them define elements that have the same name (MyNamedElement). As a result, importing two of such bindings at once yields the following error:

pyxb.exceptions_.NamespaceUniquenessError: my:NAMESPACE: name MyNamedElement used for multiple values in elementBinding

I do not have to use two bindings at the same time, so it would suffice to simply clear pyxb's internal namespace cache if thats possible.

Is there a way to do that, or some other python-magic to circumvent this problem? At the moment, my best idea is to use subprocesses, which perform the import and hopefully loose those again after finishing, s.t. pyxb will not complain.

Another question here on SO has the same error, but it turned out to be caused by a different problem: PyXB: two versions of XSDs with same namespace

BobMcFry
  • 21
  • 1
  • 4

1 Answers1

0

For those who are having the same problem, here is not the solution but a workaround. If the following imports throw a pyxb.exceptions_.NamespaceUniquenessError

import xml_binding_a
import xml_binding_b

you can add subprocesses that handle the imported modules separately

from multiprocessing import Process

def work_with_binding_a():
    import xml_binding_a
    # ...do more stuff here...

def work_with_binding_b():
    import xml_binding_b
    # ...do more stuff here...


p = Process(target=work_with_binding_a)
p.start()
p.join()

p = Process(target=work_with_binding_b)
p.start()
p.join()
BobMcFry
  • 21
  • 1
  • 4
  • Have you found a real solution by now? I'd find it kind of disturbing that I'd have to use multiprocessing for such a "simple" problem. – Hendrik Wiese Aug 27 '21 at 06:08
  • No unfortunately not. But I have not worked on that project for a long time, so I am not sure about the current state of the package. – BobMcFry Dec 20 '21 at 19:32