Just a quick sketch ( could be done better) but you will see a possible way.
<xs:complexType name="EndPoint_t" abstract="1" />
<xs:complexType name="FileEndPoint_t">
<xs:complexContent>
<xs:extension base="EndPoint_t">
<xs:attribute name="folder" use="required" type="xs:anyURI" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="FtpEndPoint_t">
<xs:complexContent>
<xs:extension base="EndPoint_t">
<xs:attribute name="site" use="required" type="xs:anyURI" />
<xs:attribute name="port" use="required" type="xs:int" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- choise #1 -->
<!-- will require something like
<EndPoint folder="..." xsi:type="file_t"/>
-->
<xs:element name="EndPoint" type="EndPoint_t" />
<!-- choise #2 -->
<!-- will look like
<EndPoints>
<file folder="..." />
-->
<xs:element name="EndPoints">
<xs:complexType>
<xs:choice>
<xs:element name="file" type="FileEndPoint_t" />
<xs:element name="ftp" type="FtpEndPoint_t" />
</xs:choice>
</xs:complexType>
</xs:element>
Maksim,
Thanks. I had tried the <xs:choice> and its currently the one I'm going
with.
I liked better your other option where you use <xs:extension>, create the
element with the type of the base class, and then in the instance use
xsi:type, but I couldn't get that to validate properly in Visual Studio.NET.
(It seems VS.NET doesn't handle the xs:extension that great in the XML
editor, as far as validation and intellisense).
Thanks for your input and any further thoughts.
Mike
> Just a quick sketch ( could be done better) but you will see a possible way.
>
[quoted text clipped - 63 lines]
> > Mike Jansen
> > (mjansen)(at)(primepro-com)
Maksim - 28 Oct 2004 19:35 GMT
In case if you do not know that:
here is a little trick you could use. Put your schema into the
"<VISUAL STUDIO ROOT>\Common7\Packages\schemas\xml" folder.
Then you can create corresponding xml and that "popup helper" (IntelliSense)
will offer you to choose a namespace
as soon as you type "xmlns=", then you can validate you your xml.
Here is a link to W3C document that talks about abstract types
http://www.w3.org/TR/xmlschema-0/#abstract
Regards
> Maksim,
>
[quoted text clipped - 84 lines]
> > > Mike Jansen
> > > (mjansen)(at)(primepro-com)