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

Re: Is name attribute essential in an attribute

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 15 Apr 2002 15:28:04 +0100
Message-ID: <701148062146.20020415152804@jenitennison.com>
To: "Dwivedi , Ajay Kumar" <AjayKumar.Dwivedi@dresdner-bank.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Ajay,

> I am an XML newbie and am trying to understand the Schema
> documentation.

Have you read the Primer? That's the best place to start.

> In the document http://www.w3.org/TR/xmlschema-1/, "XML
> Representation Summary: attribute Element Information Item", the
> name attribute is not shown as bold, which should mean it is
> optional. However the property description says:
>         {name} The ·actual value· of the name [attribute]
> Since .absent. is not allowed , doesn't it mean name is necessary attribute.
>         I am confused. Please Help

Each section of the Recommendation that deals with XML syntax follows
the pattern:

  XML representation syntax
  ---
  if something is true then:
    definition of a set of properties
  ---
  if something else is true then:
    definition of another set of properties
  ...

Basically, each XML Schema element can follow a number of different
patterns, depending on its context and what it's actually doing. The
XML syntax for an XML Schema element is actually the most general
syntax that covers all the different uses for a particular XML Schema
element.

If you look at the attribute element information item, you see the
following breakdown:

  XML representation syntax
  ---
  If the <attribute> element information item has <schema> as its
  parent, the corresponding schema component is as follows:
    ... Attribute Declaration Schema Component with one set of
    properties ...
  ---
  otherwise if the <attribute> element information item has
  <complexType> or <attributeGroup> as an ancestor and the ref
  [attribute] is absent, it corresponds to an attribute use with
  properties as follows (unless use='prohibited', in which case the
  item corresponds to nothing at all):
    ... Attribute Use Schema Component with a set of properties...
    ... Attribute Declaration Schema Component with a different set of
    properties ...
  ---
  otherwise (the <attribute> element information item has
  <complexType> or <attributeGroup> as an ancestor and the ref
  [attribute] is present), it corresponds to an attribute use with
  properties as follows (unless use='prohibited', in which case the
  item corresponds to nothing at all):
    ... Attribute Use Schema Component with another set of
    properties ...

So the XML syntax actually covers three different situations. In the
first and second situation, the xs:attribute element has to have a
name attribute, but in the third situation it doesn't, because it has
a ref attribute. That's why the XML syntax doesn't show the name
attribute in bold.

The fact that in the first situation, the name property is defined in
terms of the name attribute implies that the name attribute has to be
present in those circumstances. If you read the XML Schema for XML
Schema (at http://www.w3.org/TR/xmlschema-1/#normative-schemaSchema)
closely, you'll see that this is actually defined within the schema
for XML Schema.

The other thing that it's useful to read when trying to work out what
attributes have to be present on a particular XML Schema element are
the sections called "Constraints on XML Representations of ...", for
example the "Constraints on XML Representations of Attribute
Declarations" at
http://www.w3.org/TR/xmlschema-1/#section-Constraints-on-XML-Representations-of-Attribute-Declarations.
These sections give you all the extra rules that can't be expressed in
XML Schema, usually co-occurrence constraints between attributes or
between attributes and child elements.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 15 April 2002 10:28:06 GMT

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