472,958 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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 2299
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sarah Tegtmeier | last post by:
Hi I have a question about the correct use of the attribute xsi:schemaLocation. My programm has to process XML files where the value of this attribute causes some problems. The programm is...
0
by: Ron James | last post by:
I'm developing a GUI application in C#. I have a schema file (.XSD) and am able to serialize and deserialize the applications data using the schema file to an .XML file. (I'm using xsd.exe to...
2
by: kaush | last post by:
Hi all, I am trying to serialize a C# object into a XML document using "XmlSerializer" class. One of the elements of the XML document needs a "xsi:schemaLocation" attribute. I am not sure how to...
2
by: grochmal | last post by:
I am trying to use XmlSerializer to serialize a class I have created specifically for generating an XML file. The problem is that the XML file must contain a xsi:schemaLocation attribute in my...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.