You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Jose Luis Zabalza <jl...@gmail.com> on 2007/05/31 10:22:22 UTC
OffTopic: Newbie problems with Schema
Hello everybody.
I know this is a xerces list, so, if this question is a offtopic, I am
sorry. Accept my apologizes in avance.
Question :
It is posible do complex type content dependent of a attribute value?
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 Xerces Schema validator.
After, content TYPE element are "unbounded" to class attribute, so, is
valid write a "bool" class atribute with a enum content.
It would be thankful another list reference more appropiate to this question.
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@gmail.com
Linux Counter 172551
Re: OffTopic: Newbie problems with Schema
Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi,
"Jose Luis Zabalza" <jl...@gmail.com> writes:
> It is posible do complex type content dependent of a attribute value?
The only attribute that can influence the content model of an element is
xsi:type.
> It would be thankful another list reference more appropiate to this
> question.
That would be xmlschema-dev@w3.org:
http://lists.w3.org/Archives/Public/xmlschema-dev/
hth,
-boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding