fnogatz / xsd2json

Translate XML Schema into equivalent JSON Schema
MIT License
150 stars 28 forks source link

XSD Cycles not taken in charge by XSD2JSON #23

Open ghost opened 9 years ago

ghost commented 9 years ago

Hello,

I'm working as a Technical Architecte on SOA Governance standards. My current client designed an Enterprise Data model with XSD files, some of objects are referencing themselves (a company has contacts, and contacts are attached to a company). Today, I'm working on JSon Technical Design rules, and I wanted to base my assessment on Json Enterprise Data model, but the cycles between XSD are not correctly understood by xsd2json.

I also had some issues when I am not using the option "-u", I'm quite sure that using this option by default could help many people who are trying to resolve the problem by installing Visual Studio or Microsoft Visual Express or SDK or many other frameworks ..... With -u option at the end it is not necessary and more simple.

Could you please provide a patch for these loops? From my point of view, I analyzed the JSON files generated from an XSD without cycles, and I can see that references on complextypes are writen, as for XSD. So when the Complextype is detected the first time, it must be generated in the JSON file, but the second time, it is not necessary to go ahead on it. I think that a simple hashtable in memory, reminding the complextype "already processed" in order to NOT analyze them twice could be a good entry point, but as I am not expert on Javascript and Swiple programs, I am not able to propose a solution.

You can contact me on this email: richard.villanueva@eulerhermes.com

Thxs for your help, Richard

fnogatz commented 8 years ago

I've added two tests for recursive XSD, but both produce valid JSON Schema. My assumption is that the loops occur only when the cycles are across multiple XSD files referencing each other. Is this the case for your failing examples? Could you please provide a simple test case?

ghost commented 8 years ago

After checking, I think that my problem is related to the number of imports: I have sometimes more than 5 files imported, which have imports too inside.

Could you please check that xsd2json manages multiple imports correctly?

Thxs, Richard

2015-11-03 1:25 GMT+01:00 Falco Nogatz notifications@github.com:

I've added two tests for recursive XSD, but both produce valid JSON Schema. My assumption is that the loops occur only when the cycles are across multiple XSD files referencing each other. Is this the case for your failing examples? Could you please provide a simple test case?

— Reply to this email directly or view it on GitHub https://github.com/fnogatz/xsd2json/issues/23#issuecomment-153202650.

Richard VILLANUEVA