W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2000

Re: complexType names

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Fri, 01 Dec 2000 14:04:26 +0100
Message-ID: <3A27A1DA.147426E@dyomedea.com>
To: xmlschema-dev@w3.org
Daniel Acton wrote:
> 
> > <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema">
> >   <xsd:element type="someComplexType" name="xmlRootElement"/>
>                                               ^^^^^^^^^^^^^^
> That's exactly where my problem lies, I'm afraid. I stand to correction,
> but the above line is explicitly telling the schema validator to look for
> an element (in this case the root element) called 'xmlRootElement'. I am
> trying to steer clear of this, so that I can use the schema in the most
> extensible way possible.

Oops sorry, I must have read your email too fast.

Then the good news is that W3C XML Schema doesn't ask you to specify the
name of the document element.

<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
	<xsd:complexType name="animal">
		<xsd:sequence>
			<xsd:element name="height" type="xsd:string"/>
			<xsd:element name="weight" type="xsd:string"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:element name="Dog" type="animal"/>
	<xsd:element name="Cat" type="animal"/>
</xsd:schema>

will validate both cat.xml and dog.xml.

Eric



> Ideally, I wish to have one schema and n xml documents, and validate any existing (or any new xml document that may come up in the future) xml
> document of this kind. What I am thinking of is abstracting this name from
> the schema validator, and building a wrapper around the validator (I'm
> using Oracle's Java validator).
> 
> Thanks for the help.
> Daniel
> 
> >   <xsd:complexType name="someComplexType">
> >     <xsd:choice minOccurs="..." maxOccurs="...">
> >       <xsd:element name="Dog" type="animal" .../>
> >       <xsd:element name="Cat" type="animal" .../>
> >     </xsd:choice>
> >   </xsd:complexType>
> >   <!-- Rest of schema definition here -->
> > </xsd:schema>
> >

-- 
See you at XML 2000
      http://gca.org/attend/2000_conferences/XML_2000/building.htm#vlist
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
http://xmlfr.org         http://4xt.org              http://ducotede.com
------------------------------------------------------------------------
Received on Friday, 1 December 2000 08:01:41 GMT

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