- From: Xan Gregg <xan.gregg@jmp.com>
- Date: Tue, 14 Sep 2004 11:11:44 -0400
- To: xmlschema-dev@w3.org
I finally figured out where <redefine> came from: it reproduces one of the uses of internal parameter entities in DTDs where you can override the definition of an IPE that was part of an ATTLIST, say, to augment the content of an element declaration. For a use case, consider the XML Schema for the CDISC ODM standard [1], which is a format for exchange of clinical trials data. The schema allows for vendor extensions as long as there is type information available for the extensions. It does this by means of strict wildcards in ##other namespace. Complete validation of any instance document is important for this group. The problem with the strict wildcards sprinkled throughout is that any global attribute can go in any element. There's no way to say a particular vendor-added attribute can only go on a particular element, which is a problem in practice. A vendor defines extension attributes and then is surprised to see them in unexpected places while the user says, "it's valid according to the schema". A better solution, I realize, would be to use redefinable attribute groups, which would allow the vendor to specify which attributes are allowed where. Instead of a wildcard, the original schema should define an attribute group for each element. <xs:attributeGroup name="ItemDefAttrs"> <!-- redefine this group to add vendor extensions to the corresponding element --> </xs:attributeGroup> <xs:element name="ItemDef"> <xs:complexType> <xs:sequence>... </xs:sequence> ... <xs:attributeGroup ref="ItemDefAttrs"/> </xs:complexType> </xs:element> The vendor attributes are defined in a vendor schema document and pulled into a redefining schema: <xs:import namespace="http://www.vendor.org/" schemaLocation="vendor.xsd"/> <xs:redefine schemaLocation="ODM.xsd"> <xs:attributeGroup name="ItemDefAttrs"> <xs:attributeGroup ref="ItemDefAttrs"/> <xs:attribute ref="ven:Label"/> <xs:attribute ref="ven:DisplayFormat"/> </xs:attributeGroup> </xs:redefine> If this scheme is used throughout the original document, the vendor attribute will be allowed on the target element and only on the target element. This is a pretty straightforward use of redefine/attributeGroup, but it hadn't occurred to me as a planned extensibility mechanism. xan [1] http://www.cdisc.org/models/odm/v1.2/index.html
Received on Tuesday, 14 September 2004 15:11:54 UTC