Search code examples
xmlxsdrex

how to create simple derived type from XSD


how to can I create derived simpleType in your XSD file BASED ON xs:ID. The restriction should use a pattern with a value that starts with a "_", followed by two characters that are digits in the range 1 - 8.

element from xml

  <piece identifier="p" postion="_44"></piece>

XSD

     <xs:attribute name="postion">
                         <xs:simpleType>
                           <xs:restriction base="xs:ID">
                             <xs:pattern value="??">
                           </xs:restriction>
                         </xs:simpleType>

Solution

  • the redexp is _[1-8][1-8]

     <xs:attribute name="postion">
                         <xs:simpleType>
                           <xs:restriction base="xs:ID">
                             <xs:pattern value="_[1-8][1-8]">
                           </xs:restriction>
                         </xs:simpleType>