Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - "Overriding" Attribute Declarations [Thread Next] Re: "Overriding" Attribute DeclarationsTo: "Eliot Kimber" <ekimber@---------------.---> Date: 6/12/2007 11:10:00 AM =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Eliot Kimber writes: > In XML DTDs, one can override the declaration of an attribute declared > in an external declaration set by declaring the overriding version > earlier, . . . > I don't see an obvious way to do with with XSD using redefine. Depends on the types of the attribute involved. If the new type is a restriction of the old, then this is straightforward: baseAR.xsd: <xs:schema> <xs:complexType name="b"> <xs:attribute name="a" type="xs:string"/> </xs:complexType> </xs:schema> 1AR.xsd: <xs:schema> <xs:redefine schemaLocation="baseAR.xsd"> <xs:complexType name="b"> <xs:complexContent> <xs:restriction base="b"> <xs:attribute name="a" type="xs:token"/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema> If the new type is _not_ a restriction of the old type, _and_ it's optional in the base, you can cheat. This is against the spirit of the REC, but in practice allowed (I believe): First we get rid of the attribute: 2AR.xsd: <xs:schema> <xs:redefine schemaLocation="baseAR.xsd"> <xs:complexType name="b"> <xs:complexContent> <xs:restriction base="b"> <xs:attribute name="a" use="prohibited"/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema> Then we add it back with the desired type: 3AR.xsd: <xs:schema> <xs:redefine schemaLocation="2AR.xsd"> <xs:complexType name="b"> <xs:complexContent> <xs:extension base="b"> <xs:attribute name="a" type="xs:integer"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema> If this helps, hold your nose and go for it! ht =2D -- Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh Half-time member of W3C Team 2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440 Fax: (44) 131 650-4587, e-mail: ht@i... URL: http://www.ltg.ed.ac.uk/~ht/ [mail really from me _always_ has this .sig -- mail without it is forged sp= am] =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQFGbmLtkjnJixAXWBoRAhgDAJ42zqyJXnxDDd563PERQF+OzuLYWwCdFHef oObEhzbTgejT4ykMLo+a2fs= =BG5E =2D----END PGP SIGNATURE----- From dan@m... Tue Jun 12 09:29:47 2007 Received: from maggie.w3.org ([193.51.208.68]) by frink.w3.org with esmtp (Exim 4.50) | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
