468,110 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

xsi:schemaLocation in xmldatadocument class

I am creating an xmldatadocument from an acess database with visual basic.
Here is the header code I am using:

Dim xmldcl As XmlDeclaration = myDoc.CreateXmlDeclaration("1.0", "UTF-8",
"yes")
Dim newElem As XmlElement = myDoc.CreateElement("sender")
newElem.SetAttribute("schemaVersion", "1.0")
newElem.SetAttribute("xmlns", "http://www.somewhere.org")
newElem.SetAttribute("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance")
newElem.SetAttribute("xsi:schemaLocation", "http://www.somewhere.org
filename.xsd")
newElem.SetAttribute("name", "NewFile")
myDoc.AppendChild(newElem)
myDoc.InsertBefore(xmldcl, newElem)

The xml file created leaves off the :xsi prefix from the schema location.
The document then fails validation.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sender schemaVersion="1.0" xmlns="http://www.somewhere.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaLocation="http://www.somewhere.org filename.xsd" name="Filename">

So close - but not right... what am I doing wrong?
Sincerely,
Jean
Nov 15 '05 #1
1 2084
you are using the setattribute overload which does not take in a namespace
uri, you should use

public virtual string SetAttribute(string, string, string);

detailts at:
http://msdn.microsoft.com/library/de...ibutetopic.asp

"jean" <je**@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
I am creating an xmldatadocument from an acess database with visual basic.
Here is the header code I am using:

Dim xmldcl As XmlDeclaration = myDoc.CreateXmlDeclaration("1.0", "UTF-8",
"yes")
Dim newElem As XmlElement = myDoc.CreateElement("sender")
newElem.SetAttribute("schemaVersion", "1.0")
newElem.SetAttribute("xmlns", "http://www.somewhere.org")
newElem.SetAttribute("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance")
newElem.SetAttribute("xsi:schemaLocation", "http://www.somewhere.org filename.xsd")
newElem.SetAttribute("name", "NewFile")
myDoc.AppendChild(newElem)
myDoc.InsertBefore(xmldcl, newElem)

The xml file created leaves off the :xsi prefix from the schema location.
The document then fails validation.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sender schemaVersion="1.0" xmlns="http://www.somewhere.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaLocation="http://www.somewhere.org filename.xsd" name="Filename">

So close - but not right... what am I doing wrong?
Sincerely,
Jean

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.