Based on user-defined simple type : simpleContent « XML Schema « XML






Based on user-defined simple type


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.java2s.com" xmlns="http://www.java2s.com"
  elementFormDefault="qualified">

  <xs:simpleType name="string255">
    <xs:restriction base="xs:token">
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="supportedLanguages">
    <xs:restriction base="xs:language">
      <xs:enumeration value="en" />
      <xs:enumeration value="es" />
    </xs:restriction>
  </xs:simpleType>
  <xs:attribute name="lang" type="supportedLanguages" />

  <xs:element name="title">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="string255">
          <xs:attribute ref="lang" />
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>


</xs:schema>

 








Related examples in the same category

1.simpleContent with extension
2.complexType based on simpleContent