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

[kxml_compiler]Add support for choice #12

Open
martonmiklos opened this issue Feb 2, 2018 · 1 comment
Open

[kxml_compiler]Add support for choice #12

martonmiklos opened this issue Feb 2, 2018 · 1 comment
Assignees
Labels
kxml_compiler kxml_compiler

Comments

@martonmiklos
Copy link
Collaborator

I have an XSD with the following element:

	<xs:element name="Invoice">
		<xs:annotation>
			<xs:documentation xml:lang="hu">XML root element, számla vagy módosítás adatait leíró típus, amelyet BASE64 kódoltan tartalmaz az invoiceApi sémaleíró invoice elementje</xs:documentation>
			<xs:documentation xml:lang="en">XML root element, invoice or modification data type in BASE64 encoding, equivalent with the invoiceApi schema definition's invoice element</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:complexContent>
				<xs:extension base="InvoiceType"/>
			</xs:complexContent>
		</xs:complexType>
	</xs:element>

Where the InvoiceType is defined as the following:

<xs:complexType name="InvoiceType">
		<xs:annotation>
			<xs:documentation xml:lang="hu">Az adatszolgáltatás fő típusa</xs:documentation>
			<xs:documentation xml:lang="en">Main type of the data exchange</xs:documentation>
		</xs:annotation>
		<xs:choice>
			<xs:element name="invoiceExchange" type="InvoiceExchangeType">
				<xs:annotation>
					<xs:documentation xml:lang="hu">A számla adatszolgáltatás adatai</xs:documentation>
					<xs:documentation xml:lang="en">Invoice exchange data</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="invoiceAnnulment" type="InvoiceAnnulmentType">
				<xs:annotation>
					<xs:documentation xml:lang="hu">Korábbi adatszolgáltatás technikai érvénytelenítésének adatai</xs:documentation>
					<xs:documentation xml:lang="en">Data of technical annulment concerning previous data exchange</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:choice>
	</xs:complexType>

What would be the best generated code for this?

Have two properties (invoiceExchange and invoiceAnnulment) in the InvoiceType class, and create some logic to see which have been set and initialized first?

@cornelius
Copy link
Owner

Yes, this is a case which is not easy to reflect well in a static class hierarchy. So having two fields in the class and have explicit logic and functions to tell which one is set might be the best solution.

@martonmiklos martonmiklos added the kxml_compiler kxml_compiler label Dec 5, 2019
@martonmiklos martonmiklos self-assigned this Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kxml_compiler kxml_compiler
Projects
None yet
Development

No branches or pull requests

2 participants