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

Xsd Choice is interpreted as Option<> * Option<_>..... #1452

Open
MarkNicholls opened this issue Jun 22, 2022 · 0 comments
Open

Xsd Choice is interpreted as Option<> * Option<_>..... #1452

MarkNicholls opened this issue Jun 22, 2022 · 0 comments

Comments

@MarkNicholls
Copy link

MarkNicholls commented Jun 22, 2022

This has been noted many years ago with JSON, I assume that does the same thing.

type RawXml3 = XmlProvider<Schema = """
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:complexType name="rootType">
		<xs:sequence>
			<xs:element name="vehicle">
				<xs:complexType>
					<xs:choice>
						<xs:element name="CAR"/>
						<xs:element name="BICYCLE"/>
					</xs:choice>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:element name="ROOT" type="rootType">
	</xs:element>
</xs:schema>""">

let t = RawXml3.Parse "file.xml"

match t.Vehicle.Bicycle, t.Vehicle.Car with
| Some bike, None -> 
    printfn "a bike"
| None, Some car -> 
    printfn "a car"
| None, None -> 
    printfn "not allowed"
| Some _ , Some _ -> 
    printfn "not allowed"

Not the end of the world, but not ideal, we have a state space that allows None * None and Some _ * Some _, both of which are illegal.

is there some way to turn on choice?

(The situation with multiple choices values is I think slightly worse because it maps to Car[] and Bicycle[], rather than Choice<Car,Bicycle>[], so I assume it destroys the relative ordering of Cars and Bicycles e.g.

<Car/>
<Bicycle/>
<Car/>

and

<Car/>
<Car/>
<Bicycle/>

will be indistinguishable, rarely an issue, but some XML is order sensitive)

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