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

Re: Forcing a certain document element

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 12 Jan 2001 17:36:35 +0000
To: Ian Stokes-Rees <ian@decisionsoft.com>
Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <f5bwvc01xlo.fsf@cogsci.ed.ac.uk>
Ian Stokes-Rees <ian@decisionsoft.com> writes:

> I would like to force a single document element to be valid in my
> schema, however I have designed my sechma so it looks like (for
> illustration purposes only):
> 
> <schema>
>   <element name="documentElement">
>     <complexType>
>       <element ref="someRefElement" minOccurs="0"
> maxOccurs="unbounded"/>
>     </complexType>
>   </element>
> 
>   <element name="someRefElement">
>     <complexType>
>       <attribute name="foo" use="required"/>
>       <attribute name="bar" use="required"/>
>     </complexType>
>   </element>
> </schema>
> 
> And I would like this XML document to validate:
>  
> <documentElement>
>   <someRefElement foo="1" bar="2"/>
> </documentElement>
> 
> But not have this validate:
> 
> <someRefElement foo="1" bar="2" />
> 
> (where "someRefElement" is the document element).
> 
> How can I use XSDL to enforce this?

You can't use the XML Schema language itself to enforce this, just as
you can't say it in a DTD document.  The XML Schema WG has taken on
board a request that it be a requirement on XML Schema _processors_
that they can be invoked in a way which specifies the element
declaration to be used to validate the document element.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
Received on Friday, 12 January 2001 12:36:38 GMT

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