Re: complexType names

On Fri, 1 Dec 2000, Eric van der Vlist wrote:

> Hi,
> 
> Daniel Acton wrote:
> > 
> > The two instances will have the same elements, but with a different root
> > element. Do I have to write two seperate schemas for this? The examples
> > I've been looking at have this kind of definition of the root element:
> 
> You have many ways to do it, the only common point being that you'll
> have to use a xsd:choice at some point...
> 
> One of them is to define a complexType that will be used to define both
> dogs and cats:
> 
> <xsd:complexType name="animal">
>   <xsd:sequence>
>     <xsd:element name="height" .../>
>     <xsd:element name="weight" .../>
>   </xsd:sequence>
> </xsd:complexType>
> 
> and to use a xsd:choice in the definition of your root element:
> 
> <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. 

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>
> 

Received on Friday, 1 December 2000 07:50:17 UTC