[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: misunderstanding of XML Schema ?
Bill, If you want to use the same element name (<property> defined by different types <DisplayPropertyType, ClassPropertyType etc. ) , you can define the <propertyType> as an abstract type, then derive all desired types such as <DisplayPropertyType>, <ClassPropertyType> etc. In the instance document, you can use xsi:type to associate required type with the <Property> element. If you need more details, please let me know. Cheers, Nada Reinprecht Information Services: Better Solutions for a Better Market 03 96488748 Bill Riegel <BRiegel@l...> To: xml-dev@l... cc: 05/02/2003 12:49 Subject: misunderstanding of XML Schema ? AM Trying to define a base type of PropertyType, And derived several types from this base type. Where the name element is restricted to a fix list in each derived type. Have a file that should have a list of these derived types in a specific order. In XML spy when I try to validate the file it complains that the second Property entry does not have DisplayName, when it has a Type. Why does it think all Property entires are DisplayPropertyType's ?? XML File <ComponentRegistry> <Components> <Component name="DB Reader"> <ShowOnDemand>true</ShowOnDemand> <Description> Reads data from a database whose data model is supported by an ObjectServer </Description> <Property> <Constant>true</Constant> <Name>DisplayName</Name> <Value>DB Readerr</Value> </Property> <Property> <Constant>true</Constant> <Name>Type</Name> <Value>ObjectServer Reader</Value> </Property> <Property> <Constant>true</Constant> <Name>Class</Name> <Value>com.lgc.im.dataio.db.objectserver.ReaderImpl</Value> </Property> <Property> <Constant>true</Constant> <Name>Category</Name> <Value>DataBase</Value> </Property> <Property> <Constant>true</Constant> <Name>Format</Name> <Value>ObjectServer</Value> </Property> <Property> <Constant>true</Constant> <Name>Resource Class</Name> <Value>com.lgc.im.dataio.db.objectserver.ResourceImpl</Value> </Property> </Component> </Components> </ComponentRegistry> <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by James L. Blunt (Landmark Graphics Corp.) --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault=" qualified" attributeFormDefault="unqualified"> <xs:element name="ComponentRegistry"> <xs:annotation> <xs:documentation>Comment describing your root element</ xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="Components"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name="Component"> <xs:complexType> <xs:sequence> <xs:element name="ShowOnDemand" type="xs:boolean"/> <xs:element name="Description" type="xs:string"/> <xs:element name="Property" type="DisplayPropertyType "/> <xs:element name="Property" type="TypePropertyType"/> <xs:element name="Property" type="ClassPropertyType"/> <xs:element name="Property" type="CategoryPropertyType "/> <xs:element name="Property" type="FormatPropertyType"/> <xs:element name="Property" type=" ResourceClassPropertyType"/> </xs:sequence> <xs:attribute name="name" type="xs:string" use="required "/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name" type="xs:string"/> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="DisplayPropertyType"> <xs:complexContent> <xs:restriction base="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="DisplayName"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="TypePropertyType"> <xs:complexContent> <xs:restriction base="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Type"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="ClassPropertyType"> <xs:complexContent> <xs:restriction base="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Class"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="CategoryPropertyType"> <xs:complexContent> <xs:restriction base="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Category"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="FormatPropertyType"> <xs:complexContent> <xs:restriction base="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Format"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="ResourceClassPropertyType"> <xs:complexContent> <xs:restriction base="PropertyType"> <xs:sequence> <xs:element name="Constant" type="xs:boolean" minOccurs="0"/> <xs:element name="Name"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Resource Class"/> </xs:restriction> </xs:simpleType> </xs:element> <xs:element name="Value" type="xs:string"/> <xs:element name="InVisible" type="xs:boolean" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema> Bill Riegel LandMark Graphics 713-839-3388 ----------------------------------------------------------------- The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative of OASIS <http://www.oasis-open.org> The list archives are at http://lists.xml.org/archives/xml-dev/ To subscribe or unsubscribe from this list use the subscription manager: <http://lists.xml.org/ob/adm.pl> ------------------------------------------ This e-mail is confidential. If you are not the intended recipient, any use, disclosure or copying of this document is unauthorised and prohibited. If you have received this document in error, please delete the email and notify me by return email or by phoning the NEMMCO Helpdesk on 1300 300 295.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|