Apply a facet constraining the length : list « XML Schema « XML

Apply a facet constraining the length

File: Data.xml

<?xml version="1.0"?>
<data xmlns:xsi=""
              xsi:schemaLocation=" Schema.xsd"

  1 2 3   

File: Schema.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs=""
  targetNamespace="" xmlns=""

    <xs:element name="data" type="myRestrictedStringList"/>

  <xs:simpleType name="myStringList">
    <xs:list itemType="xs:string" />

  <xs:simpleType name="myRestrictedStringList">
    <xs:restriction base="myStringList">
      <xs:maxLength value="10" />


Related examples in the same category

1.A list datatype can be done by embedding a xs:simpleType element
2.To define a string datatype of 100 and 200 words, each having a length of less than 15 characters
3.decimal list type