Last post Jan 23, 2008 02:25 AM by Samu Zhang - MSFT
Jan 21, 2008 05:33 PM|stevenjamesfrank65|LINK
I'm having trouble getting a namespace defined to an element in an XmlDataDocument object.
Specifically, I need to add xmlns:xsi="blah" to the top-level element and for some reason I just can't seem to get it right.
<topLevel xmlns:xsi="some namespace string">
I'm wondering if this has something to do with the fact that the Xml is question is in an XmlDataDocument instead of an XmlDocument.
Jan 21, 2008 07:48 PM|Bonekrusher|LINK
Namespace declaration xsi is reserved for "http://www.w3.org/2001/XMLSchema-instance"
Is that your name space?
Jan 21, 2008 07:57 PM|stevenjamesfrank65|LINK
Yes, it is.
The XmlDataDocument is being created from a DataSet. I have set the DataSet's namespace according, but I don't know how to get the "xsi" in there.
I'm open to doing it in the DataSet, if possible, before I create the XmlDataDocument or after the XmlDataDocument is created (whichever method makes more sense).
Jan 21, 2008 09:40 PM|Bonekrusher|LINK
This usually means that you either have an element which has a child or children element(s) of a different namespace or a vis versa.
Jan 21, 2008 10:27 PM|stevenjamesfrank65|LINK
I don't mean to sound ungrateful, but how does that answer my initial question?
Jan 21, 2008 10:38 PM|Bonekrusher|LINK
With out seeing your input xml and your output xml, thats all I can give you. POst a small sample of your input XML and output XML.
Jan 22, 2008 12:18 AM|stevenjamesfrank65|LINK
There is no input Xml, the source is from a DataSet which is being transformed into an XmlDataDocument. If there is some way to modify the DataSet prior to creating the XmlDataDocument to acheive the desired result, that'd be great.
As for the Xml that is the result, a protion is below:
<Identity TransactionKey="080114100015980" TransactionDate="2008-01-21" TransactionTime="02:23:45" xmlns="">
Jan 22, 2008 12:33 AM|Bonekrusher|LINK
hmm can you post the code you use to create the XML from the Dataset?
Jan 22, 2008 12:40 AM|stevenjamesfrank65|LINK
Aside from populating some tables, this is how it goes from DataSet to Xml:
Jan 22, 2008 04:38 PM|Bonekrusher|LINK
I would loose this line:
wf1OrderDs.Namespace = "http://www.w3.org/2001/XMLSchema-instance"
its not needed.
Jan 22, 2008 04:49 PM|stevenjamesfrank65|LINK
If I don't have that, I get some other Namespace added by the system (which my client complains about).
Unfortunately, I'm at the mercy of the customer, I have to adhere to what they want in the document, which again, is:
As the top-level element.
Jan 23, 2008 02:25 AM|Samu Zhang - MSFT|LINK
Hi stevenjamesfrank65 ,
I have tried to set ds.Prefix = "xsi" , but it change the root element's namespace .
So I think the best way to generate the target xml file which is different from the original is to use xsl.
Have a look at this link: