xsdata icon indicating copy to clipboard operation
xsdata copied to clipboard

Unresolvable circular dependencies

Open ialarmedalien opened this issue 2 years ago • 1 comments

Schema source: https://gitlab.com/crossref/schema (checked out locally at other_schema/crossref).

There are a couple of different schemas in the repo that I'm looking at, but anything that includes the mathml3.xsd fails to generate the appropriate models.

e.g.

> xsdata other_schema/crossref/schemas/standard-modules/mathml3/mathml3.xsd --package crossref --structure-style namespaces

generates the error (stack trace edited for brevity)

  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/toposort.py", line 84, in toposort
    raise CircularDependencyError(data)
toposort.CircularDependencyError: Circular dependencies exist among these items: {'{http://www.w3.org/1998/Math/MathML}ImpliedMrow':{'{http://www.w3.org/1998/Math/MathML}mrow', ... '{http://www.w3.org/1998/Math/MathML}mover'}}

(same for single-package and filenames)

> xsdata other_schema/crossref/schemas/standard-modules/mathml3/mathml3.xsd --package crossref --structure-style namespace-clusters

error (stack trace edited for brevity):

  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/xsdata/utils/graphs.py", line 43, in strongly_connected_components
    yield from dfs(vertex)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/xsdata/utils/graphs.py", line 29, in dfs
    yield from dfs(w)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/xsdata/utils/graphs.py", line 29, in dfs
    yield from dfs(w)
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/xsdata/utils/graphs.py", line 29, in dfs
    yield from dfs(w)
  [Previous line repeated 1 more time]
  File "/Users/gwg/code/kbase/credit_engine/.venv/lib/python3.10/site-packages/xsdata/utils/graphs.py", line 27, in dfs
    for w in edges[v]:
KeyError: '{http://www.w3.org/1998/Math/MathML}product.class'

(same for clusters)

Can you suggest any way around this problem?

ialarmedalien avatar Aug 02 '22 16:08 ialarmedalien

wow even single package fails, I ''ll take a look sounds like an interesting case.

tefra avatar Aug 03 '22 14:08 tefra

Hi @ialarmedalien

This one was so hard to troubleshoot but I am glad you reported it, it revealed a few wrong things during the schema processing that no other suite in my samples and w3c-tests demostrated.

I took the liberty to add the crossref suite in the samples repo

https://github.com/tefra/xsdata-samples/tree/master/crossref

The fixes are on master!

fyi: the namespace-clusters, clusters and single-package should work for your case

tefra avatar Sep 07 '22 16:09 tefra

Thank you, that's fantastic!

ialarmedalien avatar Sep 07 '22 16:09 ialarmedalien