olofk / ipyxact

Python-based IP-XACT parser
MIT License
125 stars 48 forks source link

Use XML schemas to generate API #6

Closed tudortimi closed 2 years ago

tudortimi commented 8 years ago

Instead of hand-writing the yaml file, wouldn't it be better to generate the class API from the XML schemas?

I've started looking into generateDS and pyxb as options for doing this.

olofk commented 8 years ago

Cool! Yes, it has been my plan to do this eventually, but haven't had time to start working on it, so the yaml solution at least gave me something to start with. I'm happy to know more and help out if you start working on this. The IP-XACT schemas are quite well-defined so it should be possible to do it that way. That would also help with changes between versions. I've been a bit lazy so far and just defined all tags as valid for all IP-XACT versions

tudortimi commented 8 years ago

I've tried PyXB, but I didn't really like its philosophy. It generates code that depends on the PyXB packages, which means users have to additionally install this one as well. I also didn't work out of the box (I tried reading in a simple XML for an APB bus from the Accellera website and it didn't work).

tudortimi commented 8 years ago

I also tried generateDS and had better success with it. I managed to read the APB bus inside it. It has some issues with the schemas, though.

Per default, it generates one big module for everything. I gave it index.xsd and let it go wild. The same name, portType is used in multiple XSD files. Because of this, it generates a class called portType and another one called portType37 (or something), to keep the names unique within the module.

It also has an option to generate one module per XSD file, but this didn't work. It got confused because generator.xsd uses the name apiType for both an element and a type. I see this option as the most viable (one module per XSD), but it'll need some work on our part to get generateDS working and maybe some manual editing of the generated code as well.

tudortimi commented 8 years ago

I also thought about the option of generating C++ and importing that into Python. The rationale behind it was that the C++ ecosystem is more mature. The only free tools I found were under GPL and I'd rather stay away from that as I find it too limiting. In case some small startup somewhere ever wants to use ipyxact, they wouldn't be able to, because they'd need to open-source everything they make...

olofk commented 8 years ago

Just wanted to let you know that I haven't had time to investigate this further myself. GenerateDS sounds like the best option so far, but if it's tricky to adopt, I'm leaning towards a homebrewn solution for this particular problem. This might also give us better opportunity to make some manual changes and overrides

olofk commented 5 years ago

FYI I did some work on this last year but never got it finished. You can check out the preliminary work here which contains a python file generated by GenerateDS

olofk commented 2 years ago

Hey @tudortimi ! You know what? I pushed the generateDS version now. It will probably change a bit (as you say, there are multiple portType and so on) but it works mostly fine. Closing this now

tudortimi commented 2 years ago

A real blast from the past right here. :D

olofk commented 2 years ago

No one has ever accused me of being fast :)