The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

XSD enumerations: key value pairs

Posted by jpluimers on 2016/04/26

One of the things you cannot do in XSD, is have string enumerations contain both a key and a value.

But there is a little appinfo trick inside annotation that you can user under some circumstances, for instance when you interpret the XSD:


<xs:simpleType name="event_result">
<xs:restriction base="xs:string">
<xs:enumeration value="101">
<xsd:annotation><xsd:appinfo>Syntax error</xsd:appinfo></xsd:annotation>
</xs:enumeration>
<xs:enumeration value="102">
<xsd:annotation><xsd:appinfo>Illegal operation</xsd:appinfo></xsd:annotation>
</xs:enumeration>
<xs:enumeration value="103">
<xsd:annotation><xsd:appinfo>Service not available</xsd:appinfo></xsd:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>

appinfo is the application counterpart of documentation: both can contain any xml, but appinfo is aimed at machines, whereas documentation is aimed at humans.

–jeroen

via:

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.