Attach XmlSchema to XmlDocument

JaedenRuiner

Well-known member
Joined
Aug 13, 2007
Messages
340
Programming Experience
10+
Well,

on the W3C site pertaining to XML, there is this statement:
VB.NET:
<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">

Now, when I set the NamespaceURI of the XmlDocument.DocumentElement (you know the root) it is listed like this:
VB.NET:
<?xml version="1.0" encoding="Windows-1252"?>
<preferences app="RexamShip" version="1.1" xmlns="http://www.w3.org/2001/XMLSchema-instance" />

I'm curious about two things:
  1. What is that :xsi stuff that the W3C put in their declaration?
  2. I've got the XmlDocument, and a compiled Schema in the "XmlDocument.Schemas() XmlSchemaSet. Now what?

Not that I'm asking you all to tell me what I'm to write next *chuckle*, but more that I'm not exactly sure how the Schema and Document interconnect. Is the schema only there for the Validate() method, or is there something else I can do with it? I'm hoping to use the Schema to create a XmlDataDocument what would allow for DataSet access and control binding ability, but i'm still a trifle lost in the middle there. W3c has awesome syntax guides for the languages, but I've yet to find one that parallels it for simplicity and straightforwardness with any other language, so I still need a little help in the VB side of the Xml object library.

Thanks
 
"xmlns:xsi" defines the "xsi" namespace prefix, this prefix is used as shortcut instead of specifying "xmlns="http://www.w3.or..." for every node that belongs to this namespace.

I have not used XmlDataDocument yet, only base class XmlDocument, but basically a xml schema maps directly to Dataset, you can load the dataset schema with ReadXmlSchema method to read a .xsd file. You can also load the Dataset from xml data and write out the inferred schema with WriteXmlSchema method. I see a XmlDataDocument can be initialized from a Dataset too. Looking at a Dataset in VS Solution Explorer you see it has the .xsd extension. Hope this helps some in seeing the interconnections of this. From about XmlDataDocument:
XmlDataDocument has a close affiliation with the DataSet class, which provides a relational view of the loaded XML data. Any changes made to the XmlDataDocument are reflected in the DataSet and vice versa.
The schemas for XmlDocument is only used for validation, but for XmlDataDocument a change of data (and schema structure) maps directly back to a DataSet object.
 
Back
Top