Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Jose Luis Zabalza" <jlz.3008@-----.--->
To: xmlschema-dev@--.---
Date: 6/8/2007 11:08:00 AM
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="unboun=
ded"
                      type="ClassSymbol" />
           </xsd:sequence>
         </xsd:complexType>
       </xsd:element>
<!-- ....... Others elements ....... -->
     </xsd:sequence>
   </xsd:complexType>
 </xsd:element>


</xsd:schema>



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


From mike@s... Fri Jun 08 14:25:09 2007
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp (Exim 4.50)
	id 1HwfOn-0003dS-C4
	for xmlschema-dev@l...; Fri, 08 Jun 2007 14


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent