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

add marshal for one element in enum #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

carolinasolfernandez
Copy link
Contributor

Generates a marshal function to assign the default value when in an enumeration type there is only one posibility

Example:

<complexType name="Person">
		<complexContent>
				<sequence>
					<element name="type" minOccurs="1" maxOccurs="1">
						<simpleType>
							<restriction base="string">
								<enumeration value="Human" />
							</restriction>
						</simpleType>
					</element>
				</sequence>
			</extension>
		</complexContent>
	</complexType>
type Person struct {
	Type         _anon1    `xml:"type"`
}

// May be one of Human
type _anon1 string

func (x *_anon1) MarshalText() ([]byte, error) {
	return []byte("Human"), nil
}

@droyo
Copy link
Owner

droyo commented Jul 3, 2020

Hmm, what if the element is not provided at all, or is nillable? It doesn't seem correct to populate the value.

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

Successfully merging this pull request may close these issues.

None yet

2 participants