Closed Thread Icon

Topic awaiting preservation: XML attribute issue Pages that link to <a href="https://ozoneasylum.com/backlink?for=27808" title="Pages that link to Topic awaiting preservation: XML attribute issue" rel="nofollow" >Topic awaiting preservation: XML attribute issue\

 
Author Thread
Lord_Fukutoku
Paranoid (IV) Inmate

From: San Antonio
Insane since: Jul 2002

posted posted 04-19-2006 17:42

I'm not sure if this is an XML problem I have or C# or what, so if any MadSci feels like moving it, go ahead.

I have the following snippet (C#, same problem in 1.1 and 2.0):

code:
XmlDocument xd = new XmlDocument();
XmlElement xe1 = xd.CreateElement("someXmlDoc");
xe1.SetAttribute("xsi:noNamespaceSchemaLocation", "C:\\schemas\\someXmlDoc.xsd");
xe1.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

xd.AppendChild(xe1);

string text = xd.DocumentElement.OuterXml;



The problem is that "text" looks like:

code:
"<someXmlDoc noNamespaceSchemaLocation="C:\schemas\someXmlDoc.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />"



The "xsi:noNamespaceSchemaLocation" atribute doesnt have the "xsi:" in it anymore... If I use something other than "noNamespaceSchemaLocation", it still loses the "xsi:"

Any idea where it went or what happened? I've done a little bit of searching around, but nothing has turned up yet.

--

Any sufficiently advanced bug is indistinguishable from a feature.

HZR
Paranoid (IV) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 04-19-2006 21:25

Checking the documentation, you can set the namespace by using three parameters:

code:
public virtual string SetAttribute (
    string localName,
    string namespaceURI,
    string value
)



so it should probably be

code:
xe1.SetAttribute("noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance", "C:\\schemas\\someXmlDoc.xsd");


if I'm not totally mistaken.

(Edited by HZR on 04-19-2006 21:39)

Lord_Fukutoku
Paranoid (IV) Inmate

From: San Antonio
Insane since: Jul 2002

posted posted 04-20-2006 00:28

I only had time right now to plug that in and try it, but it gives text a value of:

code:
"<someXmlDoc d1p1:noNamespaceSchemaLocation=\"C:\\schemas\\someXmlDoc.xsd\" xmlns:d1p1=\"http://www.w3.org/2001/XMLSchema-instance\" />"



I'll look a little closer tomorrow at that and see if something doesn't flip a lightbulb on for me. Thanks.

[edit (note to self): seems that all I need is a way to set the "d1p1" to "xsi"...

--

Any sufficiently advanced bug is indistinguishable from a feature.

(Edited by Lord_Fukutoku on 04-20-2006 00:34)

« BackwardsOnwards »

Show Forum Drop Down Menu