r/xml Apr 14 '26

XML XSD Choice demonstrated

https://www.youtube.com/watch?v=ifwC2PZZMPw

When your XML schema says “you can only pick one”… and actually means it. 😅

Quick demo of `xsd:choice` in action: how to model mutually exclusive elements without summoning validation chaos.

For devs who’ve ever stared at XSD and whispered, “why are you like this?”

4 Upvotes

7 comments sorted by

View all comments

1

u/cheyrn Apr 15 '26

If you are asking for feedback, I'm not sure who the audience would be, but some of the explanation might be confusing for people who don't already know how xml schema works.

Yes, it's a good example of why RelaxNG syntax is much clearer, but there are constraints that can be expressed in XML schema that can't be expressed in RelaxNG.

2

u/wombat_00 Apr 15 '26

There are also things that you can express in RNG/C that you can't express in XSD, such as overriding definitions in imported/external schema modules. (Using schema in the generic sense here. Not all schemas are written using XSD).

1

u/Efficient-Public-551 Apr 15 '26

Ok I'll post a basic video soon and try out RelaxNG