- From: Vineet Chaoji <chaoji@roguewave.com>
- Date: Sun, 29 Dec 2002 21:33:37 -0800
- To: "'Jeni Tennison'" <jeni@jenitennison.com>
- Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Thanks Jeni, for the detailed response. I have one enhancement to my question. Does to answer to my questions change if I add the clause that the base and derived complex types are in different target namespaces as follows: <xsd:schema targetNamespace="Alma/CommonEntity" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ent="Alma/CommonEntity" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1"> ................... <xsd:complexType name="EntityT"> <xsd:attribute name="entityTypeName" type="ent:EntityTypeNameT" use="required"/> </xsd:complexType> </xsd:schema> <xsd:schema targetNamespace="Alma/ObsProject" xmlns:prj="Alma/ObsProject" xmlns:ent="Alma/CommonEntity" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1"> ...... <xsd:complexType name="ObsProjectEntityT"> <xsd:complexContent> <xsd:restriction base="ent:EntityT"> <xsd:attribute name="entityTypeName" type="ent:EntityTypeNameT" use="required" fixed="ObsProject"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> </xsd:schema> Looking at the specs it seems that your answers assumed that both the complex types are in the same target namespace. But I dont understand how does the target namespace influence the answer to my questions. In context of my schema, I think, that the derived complex type should have the use="required" irrespective of what its target namespace is. Am I wrong? And if I am, why? Thanks, Vineet -----Original Message----- From: Jeni Tennison [mailto:jeni@jenitennison.com] Sent: Sunday, December 29, 2002 8:56 AM To: Vineet Chaoji Cc: 'xmlschema-dev@w3.org' Subject: Re: Newbie question Hi Vineet, > Consider the following complexTypes > > <xsd:complexType name="EntityT"> > <xsd:attribute name="entityTypeName" type="ent:EntityTypeNameT" > use="required"/> > </xsd:complexType> > > <xsd:complexType name="ObsProjectEntityT"> > <xsd:complexContent> > <xsd:restriction base="ent:EntityT"> > <xsd:attribute name="entityTypeName" type="ent:EntityTypeNameT" > fixed="ObsProject"/> > </xsd:restriction> > </xsd:complexContent> > </xsd:complexType> > > ObsProjectEntityT restricts EntityT. > Now my question is whether it is necessary to have the use="required" in > ObsProjectEntityT when it puts constraints on the attribute entityTypeName. > > Is it that attributes ('use' in this case) not defined in the restricting > complexType are assumed to be picked from the base complexType? No. The derived complex type either inherits the entire attribute declaration or overrides the attribute declaration completely [1]; it does not inherit individual attributes. > As per my understanding, the derived complexType should represent a > subset of the base complexType and the absence of use="required" > (which implies use="optional") in the derived complexType violates > this rule. That is correct. [2] states that either the base attribute use must not be required or the restricted attribute use must be required, so in this case, since the attribute use in the base type is required the corresponding attribute use in the restricted type must also be required. In other words you need use="required" on the attribute declaration in the derived complex type. Cheers, Jeni [1] http://www.w3.org/TR/xmlschema-1/#c-add1 [2] http://www.w3.org/TR/xmlschema-1/#c-rad --- Jeni Tennison http://www.jenitennison.com/
Received on Monday, 30 December 2002 00:35:23 UTC