Skip to content

add marshal for one element in enum#111

Open
carolinasolfernandez wants to merge 1 commit intodroyo:masterfrom
carolinasolfernandez:feature/oneElementEnum
Open

add marshal for one element in enum#111
carolinasolfernandez wants to merge 1 commit intodroyo:masterfrom
carolinasolfernandez:feature/oneElementEnum

Conversation

@carolinasolfernandez
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants