Thursday, June 11, 2020

XSD - enumeration -Restrictions on a Set of Values of a element

Restrictions on a Set of Values
To limit the content of an XML element to a set of acceptable values, we would use the enumeration constraint.

The example below defines an element called "Color" with a restriction. The only acceptable values are: green, red, blue:

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="" xmlns=""
            targetNamespace="" elementFormDefault="qualified">
  <xsd:element name="SomeElement">
        <xsd:element name="Color" type="xsd:colorT"/>
        <xsd:element name="code" type="xsd:string"/>
      <xsd:simpleType name="colorT">
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="green"/>
        <xsd:enumeration value="red"/>
        <xsd:enumeration value="blue"/>

No comments:

Post a Comment

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...