Last post Jan 23, 2008 01:25 AM by Samu Zhang - MSFT
Jan 21, 2008 04: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 06: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 06: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 08: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 09:27 PM|stevenjamesfrank65|LINK
I don't mean to sound ungrateful, but how does that answer my initial question?
Jan 21, 2008 09: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 21, 2008 11:18 PM|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 21, 2008 11:33 PM|Bonekrusher|LINK
hmm can you post the code you use to create the XML from the Dataset?
Jan 21, 2008 11:40 PM|stevenjamesfrank65|LINK
Aside from populating some tables, this is how it goes from DataSet to Xml:
Jan 22, 2008 03:38 PM|Bonekrusher|LINK
I would loose this line:
wf1OrderDs.Namespace = "http://www.w3.org/2001/XMLSchema-instance"
its not needed.
Jan 22, 2008 03: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 01: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: