OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] misunderstanding of XML Schema ?

[ Lists Home | Date Index | Thread Index ]

Your schema and XML document threw XML Spy into a funk because you did
something that is illegal.  It is not valid in W3C Schema to declare the
same element multiple times with a different datatype, as you have -
*unless* the elements are in different namespaces.  That is, one could
have the following in an XML document instance (just showing the
pertinent elements):

<meas:foot>12</meas:foot>
<phys:foot>Good</<phys:foot>

The "foot" element is used in 2 different senses above - the first being
the measurement, the second being the condition of the body part.  Each
prefix ("meas" and "phys") would be associated with a different
namespace that signifies its domain (measurement or physical).

By a quick glance at your XML instance, it appears that this is *not*
what you want - i.e. you want to have a single Property element repeated
multiple times, with the same content model and (potentially) different
contents each time.  So you should simply declare it once as the
datatype you intend, and make it repeatable using the "maxOccurs" facet.

Hope that helps.
Joe Chiusano
Booz | Allen | Hamilton
Bill Riegel wrote:
> 
> Thank you for you response,
> 
> Why does it expect the second Propery to be of DisplayPropertyType?
> I have defined the second Property to be of type "TypePropertyType".
> 
> Bill Riegel
> LandMark Graphics
> 713-839-3388
> 
> -----Original Message-----
> From: Chiusano Joseph [mailto:chiusano_joseph@bah.com]
> Sent: Tuesday, February 04, 2003 9:17 AM
> To: Bill Riegel
> Cc: xml-dev@lists.xml.org
> Subject: Re: [xml-dev] misunderstanding of XML Schema ?
> 
> This is because you have defined the Property element several times
> within the same schema, with a different datatype each time.  XML Spy is
> complaining on the second Property element because it expects it to be
> of "DisplayPropertyType", but instead it is of "TypePropertyType".
> 
> According to your XML instance, it appears that Property has the same
> content model on each occurrence.  You should probably just declare the
> Property element once and use the "maxOccurs" facet on it, to make it
> repeatable.
> 
> Hope that helps.
> 
> Joe Chiusano
> Booz | Allen | Hamilton
> 
> > Bill Riegel wrote:
> >
> > 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>
begin:vcard 
n:Chiusano;Joseph
tel;work:(703) 902-6923
x-mozilla-html:FALSE
url:www.bah.com
org:Booz | Allen | Hamilton;IT Digital Strategies Team
adr:;;8283 Greensboro Drive;McLean;VA;22012;
version:2.1
email;internet:chiusano_joseph@bah.com
title:Senior Consultant
fn:Joseph M. Chiusano
end:vcard




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS