Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arrays of non-trivial builtins #61

Open
droyo opened this issue Nov 24, 2017 · 1 comment
Open

arrays of non-trivial builtins #61

droyo opened this issue Nov 24, 2017 · 1 comment

Comments

@droyo
Copy link
Owner

droyo commented Nov 24, 2017

Consider the element declaration below (note the "maxOccurs" attribute)

<element name="timestamps" type="xsd:dateTime" minOccurs="0" maxOccurs="unbounded">

In Go, the ideal declaration for this type would be []time.Time. For scalar types, we can get away with converting a *time.Time to an *xsdDateTime, a private type that we can attach MarshalXML/UnmarshalXML methods to. This doesn't work with slice types: https://play.golang.org/p/ZAOS7gzcUk .

Currently, xsdgen doesn't work at all for this scenario; it will generate code that tries to convert a *[]time.Time to an *xsdDateTime, which fails to compile.

@droyo
Copy link
Owner Author

droyo commented Nov 24, 2017

I really like the fact that generated code uses basic types like time.Time and []byte (for base64Binary) rather than exporting custom types, and would like to keep that property, if feasible. The most obvious way forward, then, is to add plural versions of all the "helper types":

type xsdDateTimeSlice []time.Time
type xsdBase64BinarySlice [][]byte

The accompanying methods would then look very similar to their scalar versions (see the principle here: https://play.golang.org/p/f715VAnArD)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant