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

Limited implementation of Global Attributes?

From: Paul Tomlinson <ptomlinson@atmedicausa.com>
Date: Thu, 21 Feb 2002 16:13:31 -0500 (EST)
To: <xmlschema-dev@w3.org>
Message-ID: <000101c1bb1c$6d1f97f0$6a0a0a0a@dohealth.com>
I'm encountering a rather unique error that may have to do with the actual
schema specification (verified with separate parsing engines) I'd like to
get someone else's eyes on.  Take the following snippet of XML:


  <SecondLevelElement xmlns:Action="Add">

Note the "xmlns:" namespace qualifier in front of "Action", basically
declaring this attribute to exist in the currently defined space.  I
*should* be able to take this off and simply have:

<SecondLevelElement Action="Add">

But no such luck - this produces an error, varying in text from one
implementation to the next, but identical in trigger:

XMLSpy: This file is not valid: Unexpected attribute 'Action' - the parent
element requires some attributes to be qualified, because your Schema uses
attributeForm='qualified' or global attributes.  You may need to specify a
prefix for your schema namespace.

MSXML4: Validate failed because the document does not contain exactly one
root node.

XMLSpy makes a great deal more sense, but still doesn't quite explain the
situation.  The "Action" attribute *is* a global definition, but it's been
incorporated into the current namespace.  The main schema is similar to

  <xs:include schemaLocation="GenericTypes.xsd"/>
  <xs:element name="TopLevelElement">
        <xs:element name="SecondLevelElement" maxOccurs="unbounded">
              <xs:extension base="SecondLevelType">
                <xs:attribute ref="Action"/>
Referencing a second schema with global elements (GenericTypes.xsd) and
attributes, thus:

  <xs:attribute name="Action">
      <xs:restriction base="xs:string">
        <xs:enumeration value="Add"/>
        <xs:enumeration value="Update"/>
        <xs:enumeration value="Delete"/>
        <xs:enumeration value="NoChange"/>

It's probably important to note that although I have definitions scattered
across multiple documents (all within the same namespace) the same error is
encountered even if the "Action" attribute definition is removed to the
primary validating schema.
The schemata are valid and interact with one another properly (referenced
definitions from GenericTypes in the primary schema are properly enforced,
etc.).  No issue occurs in validating these - only when the XML enters the
picture.  Apparently the attribute being global invalidates the schema's
attributeFormDefault, but that still shouldn't push the responsibility of
declaring namespace qualifications onto the XML.  Aside from declaring
"Action" locally for those elements which require it (or constructing a
verbose schema via XSL which references a single implementation, for ease of
maintenance) is there any way to clean this up?  Has anyone encountered this
before that might be able to help me understand the reasoning in force?

Paul L. Tomlinson
Received on Friday, 22 February 2002 03:47:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:59 UTC