Newbie question. It is posible do complex type content dependent of a attribute value without xsi:type

Hello everybody.

It is posible do complex type content dependent of a attribute value
without xsi:type?

Next, is a example. TYPE content depend of class attribute values.

The next schema have two error.

First, VINIT element are diferent type on schema and I get one error
form  Schema validator.

After, content TYPE element are "unbounded" to class attribute, so, is
valid write a "bool" class atribute with a enum content.

Thanks in avance.


<!-- ==================FILE================================== -->
<?xml version="1.0" encoding="iso-8859-1" ?>
<DATATYPES
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation='datatypes.xsd'>

 <SYMBOLS>
   <TYPE id="first" class="bool">
     <VINIT>true</VINIT>
     <TRUE>this is true</TRUE>
     <FALSE>this is false</FALSE>
   </TYPE>

   <TYPE id="second" class="string">
     <VINIT>this is a string</VINIT>
     <MAXLEN>100</MAXLEN>
   </TYPE>

   <TYPE id="third" class="enum">
     <VINIT>1</VINIT>
     <OPTIONS>
       <OPTION value="1">first option</OPTION>
       <OPTION value="2">second option</OPTION>
       <OPTION value="3">third option</OPTION>
     </OPTIONS>
   </TYPE>


<!-- this is a error but good for schema  -->
   <TYPE id="fourth" class="bool">
     <VINIT>1</VINIT>
     <OPTIONS>
       <OPTION value="1">first option</OPTION>
       <OPTION value="2">second option</OPTION>
       <OPTION value="3">third option</OPTION>
     </OPTIONS>
   </TYPE>
 </SYMBOLS>

<!-- ..... anothers elements ... -->

</DATATYPES>


<!-- ============= SCHEMA ============ -->

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">


 <xsd:group name="groupClassString">
   <xsd:sequence>
     <xsd:element name="VINIT"  type="xsd:string" />
     <xsd:element name="MAXLEN"    type="xsd:unsignedInt" minOccurs="0"/>
   </xsd:sequence>
 </xsd:group>


 <xsd:group name="groupClassBool">
   <xsd:sequence>
     <xsd:element name="VINIT"  type="xsd:boolean" />
     <xsd:element name="TRUE"   type="xsd:string"/>
     <xsd:element name="FALSE"  type="xsd:string"/>
   </xsd:sequence>
 </xsd:group>


 <xsd:group name="groupClassEnum">
   <xsd:sequence>
     <xsd:element name="VINIT"  type="xsd:unsignedInt" />
     <xsd:element name="OPTIONS"  >
       <xsd:complexType>
         <xsd:sequence>
           <xsd:element name="OPTION" maxOccurs="unbounded">
             <xsd:complexType>
               <xsd:simpleContent>
                 <xsd:extension base="xsd:string">
                   <xsd:attribute name="value" type="xsd:unsignedInt"
use="required"/>
                 </xsd:extension>
               </xsd:simpleContent>
             </xsd:complexType>
           </xsd:element>
         </xsd:sequence>
       </xsd:complexType>
     </xsd:element>
   </xsd:sequence>
 </xsd:group>

 <xsd:complexType name="ClassSymbol">

   <xsd:choice >
     <xsd:group ref="groupClassString"/>
     <xsd:group ref="groupClassBool"/>
     <xsd:group ref="groupClassEnum"/>
   </xsd:choice>


   <xsd:attribute name="id" use="required" type="xsd:string"/>
   <xsd:attribute name="class" use="required">
     <xsd:simpleType>
       <xsd:restriction base="xsd:string">
         <xsd:enumeration value="string"/>
         <xsd:enumeration value="bool"/>
         <xsd:enumeration value="enum"/>
       </xsd:restriction>
     </xsd:simpleType>
   </xsd:attribute>
 </xsd:complexType>



 <xsd:element name="DATATYPES">
   <xsd:complexType>
     <xsd:sequence>
       <xsd:element name="SYMBOLS">
         <xsd:complexType >
           <xsd:sequence>
             <xsd:element name="TYPE" minOccurs="0" maxOccurs="unbounded"
                      type="ClassSymbol" />
           </xsd:sequence>
         </xsd:complexType>
       </xsd:element>
<!-- ....... Others elements ....... -->
     </xsd:sequence>
   </xsd:complexType>
 </xsd:element>


</xsd:schema>



-- 
José Luis Zabalza
jlz.3008  a t  gmail.com
Linux Counter 172551

Received on Friday, 8 June 2007 14:16:01 UTC