[Home] [By Thread] [By Date] [Recent Entries]

  • From: Mukul Gandhi <mukulg@s...>
  • To: Kurt Cagle <kurt.cagle@g...>
  • Date: Thu, 17 Feb 2022 17:00:06 +0530

Hi Kurt,

On Thu, Feb 17, 2022 at 11:09 AM Kurt Cagle <kurt.cagle@g...> wrote:
If you had to do this as an enumeration, I'd use the following:
<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="airportType">
        <xsd:simpleType>
            <xsd:list>
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:enumeration value="civil"/>
                        <xsd:enumeration value="military"/>
                        <xsd:enumeration value="active"/>
                        <xsd:enumeration value="inactive"/>
                        <xsd:enumeration value="permanent"/>
                        <xsd:enumeration value="temporary"/>
                    </xsd:restriction>                  
                </xsd:simpleType>               
            </xsd:list>
        </xsd:simpleType>
    </xsd:element>
</xsd:schema>
Then you would have:
<airportType>active civil permanent</airportType>

 Nice thought.

The schema you've posted, would allow the XML element <airportType>active active civil permanent</airportType> to be reported as valid (i.e, duplicate strings are permitted).

It seems that, a modification like following (with XSD 1.1 needed) could fix that,

<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   
    <xsd:element name="airportType">
        <xsd:simpleType>
           <xsd:restriction base="AirportType">
              <xsd:assertion test="count($value) = count(distinct-values($value))"/>
           </xsd:restriction>
        </xsd:simpleType>
    </xsd:element>
   
    <xsd:simpleType name="AirportType">
       <xsd:list>
          <xsd:simpleType>
             <xsd:restriction base="xsd:string">
               <xsd:enumeration value="civil"/>
               <xsd:enumeration value="military"/>
               <xsd:enumeration value="active"/>
               <xsd:enumeration value="inactive"/>
               <xsd:enumeration value="permanent"/>
               <xsd:enumeration value="temporary"/>
             </xsd:restriction>                  
          </xsd:simpleType>              
       </xsd:list>
    </xsd:simpleType>
   
</xsd:schema>


--
Regards,
Mukul Gandhi


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member