Re: Redeclaring attribute in derived type

Hi Jeni

>By the way, this schema isn't valid because you can't specify a fixed
>or default value on an attribute whose type is or is derived from
>xs:ID (from Schema Component Constraint: Attribute Declaration
>Properties Correct, clause 3). I kept it like that simply because that
>was how you had it in your example.

Thanks, I was not aware of that (and XSV didn't mention it).  I could achieve 
the desired effect using an enumeration with a single value or a pattern 
consisting of the literal string, right? 

>If you want to both *extend* a type (adding to the content model) and
>*restrict* a type (limiting attribute values), then you need to do it
>in two steps - one a restriction and one an extension. You can do it
>either way round, but since restrictions require you to specify the
>full content model, it's easiest to do it first (on the shorter
>content model):

Why do I have to do it in two steps / can I do it at all?

If I were just going to address the first question, I would say why can't I 
do this: 

[

<xsd:complexType name="BaseType">

  <xsd:sequence>

    <xsd:element ref="JMM:someElementABC" />

  </xsd:sequence>

  <xsd:attribute name="id" type="xsd:ID" />

</xsd:complexType>


<xsd:complexType name="DerivedType">

  <xsd:complexContent>

    <xsd:extension base="JMM:BaseType">

      <xsd:sequence>

        <xsd:element ref="JMM:someElementXYZ" />

      </xsd:sequence>

    </xsd:extension>

  </xsd:complexContent>

  <xsd:attribute name="id">

    <xsd:simpleType>

      <xsd:restriction base="xsd:ID">

        <xsd:pattern value="Derived" />

      </xsd:restriction>

    </xsd:simpleType>

  </xsd:attribute>

</xsd:complexType>

]

But doesn't clause 4 -- "4 Two distinct attribute declarations in the 
{attribute uses} must not have identical {name}s and {target namespace}s." -- 
of 3.4.6 Constraints on Complex Type Definition Schema Components preclude 
doing that (even on the second of the two steps you suggest)? 


--> Jesse

Received on Thursday, 20 December 2001 20:25:46 UTC