- From: Lemmin, Harald <Harald.Lemmin@softwareag.com>
- Date: Thu, 13 Dec 2001 11:15:34 +0100
- To: "'Jeni Tennison'" <jeni@jenitennison.com>
- Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Jeni, thank you very much. Harald -----Original Message----- From: Jeni Tennison [mailto:jeni@jenitennison.com] Sent: Donnerstag, 13. Dezember 2001 10:50 To: Lemmin, Harald Cc: xmlschema-dev@w3.org Subject: Re: Attribute uses of complexType complexContent restriction Hi Harald, > I'm confused about the attribute uses of complexType complexContent > restriction: > The primer states in "4.4 Deriving Complex Types by Restriction": > "Notice that types derived by restriction must repeat all the components of > the base type definition that are to be included in the derived type:" > My question: Does this hold true for the attribute declarations, too? No, it doesn't apply to attributes, just to elements. The attribute uses from the base type are inherited by the restricted type whether you specify them in the restricted type or not. You can *prevent* an attribute use from being inherited by the restricted type by specifying that attribute with use="prohibited" in the restricted type, which prevents it from being added to the attribute uses for the restricted type. > Example: > <xs:complexType name="baseType"> > <xs:attribute name = "att1" type = "xs:string" use = "optional"/> > <xs:attribute name = "att2" type = "xs:string" use = "optional"/> > <xs:attribute name = "att3" type = "xs:string" use = "optional"/> > <xs:attribute name = "att4" type = "xs:string" use = "optional"/> > </xs:complexType> > > <xs:complexType name="restrictedType"> > <xs:complexContent> > <xs:restriction base = "target:baseType"> > <xs:attribute name = "att1" type = "xs:string" use = "required"/> > <xs:attribute name = "att2" type = "xs:string" use = "prohibited"/> > <xs:attribute name = "att3" type = "xs:string" use = "optional"/> > </xs:restriction> > </xs:complexContent> > </xs:complexType> > > That means: > att1 -> restricted by putting from optional to required. Right. > att2 -> restricted by putting from optional to prohibited. Yes, such that elements of the restrictedType cannot have the att2 attribute. > att3 -> mentioned again, because it should be still there. You can mention it again as you have if you want, but you don't have to. The attribute declaration you've included in the restrictedType could be safely omitted if you wanted att3 to be exactly the same. > att4 -> not mentioned, because "restrictedType" should not have this > attribute. That's not the effect of leaving out att4. To stop att4 being allowed in the restrictedType, you have to do what you did for att2, and make use="prohibited". As you've left it out, this attribute will be inherited from the base type. I hope that clears things up for you, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Thursday, 13 December 2001 05:15:43 UTC