go-xml icon indicating copy to clipboard operation
go-xml copied to clipboard

Only flatten a type once

Open boekkooi-fresh opened this issue 6 years ago • 5 comments

This should resolve issue https://github.com/droyo/go-xml/issues/86

boekkooi-fresh avatar Jun 12 '19 15:06 boekkooi-fresh

Thank you for opening this. Are you sure this resolves #86 ? #86 happens during parsing within the xsd package, but your change is to the xsdgen package. I have a unit test reproduction in the recursive-types branch.

Instead this looks more like a performance optimization. Does this change the xsdgen output at all?

droyo avatar Jun 14 '19 05:06 droyo

It solved an infinity loop problem that had when running xsdgen!

t0rr3sp3dr0 avatar Jul 04 '19 19:07 t0rr3sp3dr0

But… it generated invalid recursive types

t0rr3sp3dr0 avatar Jul 04 '19 19:07 t0rr3sp3dr0

@droyo Sorry in my haste to go to have a holiday I miss read the 86 ticket I will fix this once I figure out the error @t0rr3sp3dr0 is having.

@t0rr3sp3dr0 Could you maybe provided me with the xsd that you used where you noticed the invalid types that are generated? Thanks in advance

boekkooi-fresh avatar Jul 05 '19 12:07 boekkooi-fresh

Sure @boekkooi-fresh! I was trying to generate models for SAML. They are all packed together at https://docs.oasis-open.org/security/saml/v2.0/saml-2.0-os-xsd.zip. I’ve solved the problem by converting all fields that had omitempty tag to pointers.

PS: I also had to change encoding for one document, it was US-ASCII and it just worked when changed it to UTF-8. I don’t know if it is a known problem of the tool, but I can assure you the files are well-formed as I’ve generated Java classes for it using xjc.

PS2: To make it simpler for you, disconsider all saml-schema-authn-* files. Unfortunately you’ll still have to download some dependencies such as xmlenc.

t0rr3sp3dr0 avatar Jul 06 '19 02:07 t0rr3sp3dr0