Re: Attribute with fixed value in derived types

I suspect that you have to first define a restriction of the type in 
which the attribute has a fixed value, and then define an extension of 
the restricted type.

Or in XSD 1.1, as I discovered recently on this list, you can add an 
assertion as part of the extension, so you could define the fixed value 
by means of an assertion and thereby avoid the restriction step. (But 
you wanted an XSD 1.0 solution...)

Michael Kay
Saxonica

On 27/06/2012 10:44, Florent Georges wrote:
>    Hi,
>
>    I have a complex type with a required attribute:
>
>      <xs:complexType name="type">
>         ...
>         <xs:attribute ref="my:attr" use="required"/>
>      </xs:complexType>
>
>    I then use it to define some elements with additional children:
>
>      <xs:element name="elem">
>         <xs:complexType>
>        <xs:complexContent>
>           <xs:extension base="my:type">
>          <xs:sequence>
>             ...
>          </xs:sequence>
>           </xs:extension>
>        </xs:complexContent>
>         </xs:complexType>
>      </xs:element>
>
>    For some of those elements, I'd like to set a fixed value for the
> attribute.  How can I do that, with XML Schema 1.0?  In addition, is
> it possible to set a fixed value in the complex type, then to override
> it in some elements only?
>
>    Regards,
>
>

Received on Wednesday, 27 June 2012 10:08:23 UTC