W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2001

Re: [schema] Re: Forcing a certain document element

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Fri, 12 Jan 2001 21:32:54 +0100
Message-ID: <3A5F69F6.C767C5B9@dyomedea.com>
To: Robert Braddock <stormwarden@bigfoot.com>
CC: xmlschema-dev@w3.org
Robert Braddock wrote:
> 
> > > Can't you design your schema to have only one global element definition
> 
> > In the words of Richard Nixon (allegedly :-) "You could do that, but
> > it would be wrong."  By which I mean you're right, if you wrote such a
> > schema, it would have the desired effect, but that's a pretty
> > roundabout way to get it.
> 
> I disagree. Given that the only way to avoid polluting my instance documents
> with redundant schema information is to insure that all elements are locally
> defined (except the top element, of course), it's hardly roundabout. In
> fact, since combining other schemas with mine relies on linking into them
> without violating this property, I appreciate if people design without
> global elements (I just use global complexTypes where I had global elements
> before).

That's quite a constraint, though, especially where multiple namespaces
are involved since types behave differently than elements in this
context.

Thinking more about it, there is another workaround which is to isolate
the elements within groups:

<schema>
  <element name="documentElement">
    <complexType>
      <group ref="someRefGroup" minOccurs="0" maxOccurs="unbounded"/>
    </complexType>
  </element>

  <group name="someRefGroup">
   <sequence>
    <element name="someRefElement">
     <complexType>
       <attribute name="foo" use="required"/>
       <attribute name="bar" use="required"/>
     </complexType>
    </element>
   </sequence>
  </group>
</schema>

should also do the trick.

If I can end this mail by a comment/question, I have always be surprised
that it's not allowed to define elements at any level, since the right
way to specify what is requested here could be something like:

<schema>
  <element name="documentElement">
    <!-- definition of an element available under 
         this scope   -->
    <element name="someRefElement">
     <complexType>
       <attribute name="foo" use="required"/>
       <attribute name="bar" use="required"/>
     </complexType>
    </element>
    <!-- Definition of the content modelm of 
         "documentElement" -->
    <complexType>
      <element ref="someRefElement" minOccurs="0"
maxOccurs="unbounded"/>
    </complexType>
  </element>
</schema>

But this is forbidden by the W3C XML Schema syntax.

Eric

> Robert Braddock

-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------
Received on Friday, 12 January 2001 15:31:01 GMT

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