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

Issue with type="xsd:date" maxOccurs="unbounded" #128

Open
eveninglily opened this issue Jan 14, 2021 · 1 comment
Open

Issue with type="xsd:date" maxOccurs="unbounded" #128

eveninglily opened this issue Jan 14, 2021 · 1 comment
Labels

Comments

@eveninglily
Copy link

Hi! Thanks for the excellent tool.

I was using xsdgen on this schema: https://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd

This mostly worked, except for one field:

<xsd:element name="ScheduledOn" type="xsd:date" minOccurs="0" maxOccurs="unbounded"/>

The resulting struct has the correct type:

ScheduledOn []time.Time      `xml:"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 ScheduledOn,omitempty"`

but in the marshall/unmarshall functions, there's a type mismatch (cannot convert &layout.T.ScheduledOn (value of type *[]time.Time) to *xsdDate)

func (t *Workoutt) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	type T Workoutt
	var layout struct {
		*T
		ScheduledOn *xsdDate `xml:"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 ScheduledOn,omitempty"`
	}
	layout.T = (*T)(t)
	layout.ScheduledOn = (*xsdDate)(&layout.T.ScheduledOn)
	return e.EncodeElement(layout, start)
}
func (t *Workoutt) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
	type T Workoutt
	var overlay struct {
		*T
		ScheduledOn *xsdDate `xml:"http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 ScheduledOn,omitempty"`
	}
	overlay.T = (*T)(t)
	overlay.ScheduledOn = (*xsdDate)(&overlay.T.ScheduledOn)
	return d.DecodeElement(&overlay, &start)
}
@droyo droyo added the bug label Jan 17, 2021
@lorenz
Copy link

lorenz commented Feb 4, 2021

Same with

    <xs:complexType name="ArrayOfAppManifestsType">
        <xs:sequence>
            <xs:element name="Manifest" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

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

No branches or pull requests

3 participants