W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

Re: Question on abstract element

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 10 Apr 2002 18:55:55 +0100
Message-ID: <17728539925.20020410185555@jenitennison.com>
To: "Arnaud Blandin" <blandin@intalio.com>
CC: "Xmlschema-Dev" <xmlschema-dev@w3.org>
Hi Arnaud,

> The purpose of this schema is to prevent the element 'foo' from
> being used as a top-level element and only used when referenced
> inside a complexType or a group.
>
> The problem I have is: since 3.3.4 Element Declaration Validation
> Rules specifies that the 'abstract' attribute of a local element
> must be set to 'false', do I have to do it by hand (adding
> abstract='false' to the referenced element)or is it implied since I
> am using a 'ref'. I couldn't find any pointer in the spec.

The element must be *declared* as non-abstract. Making an element
abstract means that it can't be used in the instance document at any
level.

I think that in your case, you could put the element declaration into
a group, and then reference the group. This will mean that the element
can't be used as the document element (or as the head element of a
substitution group), but enables you to refer to the same declaration
many times in your schema:

<xs:group name="fooGroup">
  <xs:sequence>
    <xs:element name="foo" type="fooType" />
  </xs:sequence>
</xs:group>

<xs:element name="bar">
  <xs:complexType>
     <xs:sequence>
        <xs:group ref="fooGroup"/>
        ...
     </xs:sequence>
  </xs:complexType>
</xs:element>

Alternatively, you could declare the element locally within the
complex type.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 10 April 2002 13:55:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT