[quoted text, click to view] "David Thielen" <thielen@nospam.nospam> wrote in message
news:87F99090-5235-4A48-8D4E-9E76029E610C@microsoft.com...
> Hi;
>
> I have an xsd that has:
> <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
> <xsd:element name="comment" type="xsd:string"/>
>
> I get this as an XmlSchema using:
> XmlSchema schema = XmlSchema.Read(new FileStream(datasource.SchemaUrl,
> FileMode.Open, FileAccess.Read, FileShare.Read), null);
> schema.Compile(null);
>
> Two questions:
>
> 1) Is this the best way to get the schema? I am getting a warning that I
> should put it in an XmlSchemaSet and compile the set although this is my
> only
> schema.
I suggest you follow what the warning is telling you. XmlSchemaSet will
allow for the possibility in the future that the first schema might refer to
a second, or that your instance document will some day require more than one
schema to describe it.
[quoted text, click to view] > 2) The <purchaseOrder> element is the root node. But how do I know that
> from
> the xsd file? Is the root node always the first one and the rest are for
> references?
The schema fragment you've supplied permits either <purchaseOrder> or
<comment> to be the root node in an instance document that validates against
this schema (assuming it's the only schema being used).
What are you trying to accomplish? What is it about the "root node" that you
want to find out?
--
John Saunders [MVP]