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="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org"
            targetNamespace="http://www.example.org" elementFormDefault="qualified">
  <xsd:element name="SomeElement">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Color" type="xsd:colorT"/>
        <xsd:element name="code" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
      <xsd:simpleType name="colorT">
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="green"/>
        <xsd:enumeration value="red"/>
        <xsd:enumeration value="blue"/>
      </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>

No comments:

Post a Comment

Featured Post

OIC - how can I use XSLT functions to remove leading zeros from numeric and alphanumeric fields?

To remove leading zeros from an numeric field in Oracle Integration Cloud (OIC) using XSLT, you can Use number() Function The number() funct...