Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / August 2007

Tip: Looking for answers? Try searching our database.

Which is the root element

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 30 Jun 2007 23:56 GMT
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.

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?

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

John Saunders [MVP] - 01 Jul 2007 00:54 GMT
> Hi;
>
[quoted text clipped - 13 lines]
> 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.

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

John Saunders [MVP]

David Thielen - 01 Jul 2007 15:04 GMT
We want to have a wizard that helps the user create valid XPath statements
for the xml. So we put the schema in a TreeView that they can click on to
select elements.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> > Hi;
> >
[quoted text clipped - 30 lines]
> What are you trying to accomplish? What is it about the "root node" that you
> want to find out?
John Saunders [MVP] - 02 Jul 2007 16:26 GMT
> We want to have a wizard that helps the user create valid XPath statements
> for the xml. So we put the schema in a TreeView that they can click on to
> select elements.

Ok, then I think you may need to change your schema to have only one global
element, hence only one possible root node.
Signature

John Saunders [MVP]

druqlqrvsd - 26 Aug 2007 03:26 GMT
Hello! Good Site! Thanks you! qqqjlhvztc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.