xsi:noNameSpaceSchemaLocation

Hi,

I am creating C# calsses to seralize and deserialize based on xsd.

When defining the classes to do seralization i need to specify the
schema for the reference. Typically my class definition looks like this
:

[XmlRootAttribute(NameSpace = "", IsNullable=false)]
public class MyClass
{
public string myString;
}

I need to specify xsi:noNameSpaceSchemaLocation somewhere in the
XmlRootAttribute. Please help me....

Regards

Balaji. V
=============

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
0
balajiv (1)
8/14/2003 9:30:04 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
1786 Views

Similar Articles

[PageSpeed] 59

Balaji V wrote:

> I am creating C# calsses to seralize and deserialize based on xsd.
> 
> When defining the classes to do seralization i need to specify the
> schema for the reference. Typically my class definition looks like this
> :
> 
> [XmlRootAttribute(NameSpace = "", IsNullable=false)]
> public class MyClass
> {
> public string myString;

> I need to specify xsi:noNameSpaceSchemaLocation somewhere in the
> XmlRootAttribute. Please help me....
Add dummy field to your class and serialize it as desired attribute:
[XmlAttribute(AttributeName="noNamespaceSchemaLocation", 
Namespace="http://www.w3.org/2001/XMLSchema-instance")]
public string noNamespaceSchemaLocation = foo.xsd";

-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
8/14/2003 11:18:47 AM
Reply:

Similar Artilces:

XmlValidatingReader invalid xsi:type
I have an abstract base class and two derived classes that I want to serialize and deserialize with schema validation. When I serialize instances of the derived classes the XmlSerializer adds the xsi:type="DerivedClass" attribute and the Instance Namespace. When I attempt to validate the xml upon deserialization the XmlValidatingReader chokes on this attribute value. I can't seem to find a way around this. Any suggestions? Could you post your final XSD and XML you are trying to validate using XmlValidatingReader ? "Jason Cartwright" <jason@cartwrightkids.com> w...

setting xsi:schemaLocation on XmlSerialize
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 generate my serializable class, XmlSerializer to Serialize and DeSerialize and XMLValidatingReader to validate. My intention is that application users can edit the content of the .XML file using their favorite XML editor as well as by using my app. However I want the user's XML editor to be aware of my .XSD file. In a previous posting Priya Lakshminarayanan pointed out that, wi...

xsi:noNameSpaceSchemaLocation
Hi, I am creating C# calsses to seralize and deserialize based on xsd. When defining the classes to do seralization i need to specify the schema for the reference. Typically my class definition looks like this : [XmlRootAttribute(NameSpace = "", IsNullable=false)] public class MyClass { public string myString; } I need to specify xsi:noNameSpaceSchemaLocation somewhere in the XmlRootAttribute. Please help me.... Regards Balaji. V ============= *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Balaji V wrote...

XmlSerializer and xsi:schemaLocation
I am trying to use XmlSerializer to serialize a class I have create specifically for generating an XML file. The problem is that the XML file must contain a xsi:schemaLocatio attribute in my root node but I can't figure out any way to do it. Here is what the resulting XML file must look like (small sample): <TXLife xmlns="http://ACORD.org/Standards/Life/2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance *xsi:schemaLocation="http://ACORD.org/Standards/Life/ TXLife2.11.01.xsd"* Version="2.11.01"> <blah>whatever</blah> </TXLife> Th...

xsi:type infopath
Hi, I have an XML Schema containing inherited complex types, and xs:elements using @type of the top complex type, meaning, any child complex type can be an instance of that element by declaring the complex type name using xsi:type . If I write the xml by hand, and validate against the xml schema, works really well. Using infopath I can import the schema and the data structure is displayed in the form designer, although there is no apparent way to allow users to select the xsi:type the instance of that element will be using. Has anybody used xsi:type with infopath before, or know any way to...

How to add xsi:schemaLocation to serialized c# class
Hi all, I'm getting really confused how to solve this. I've got this class generated from XSD with xsd (from visual studio 2005) namespace gpx { using System.Xml.Serialization; /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")] [System.Xml.Ser...

xsi:noNamespaceSchemaLocation Problem
I use the following code to create the XML from a class object Dim serialize As New System.Xml.Serialization.XmlSerializer(GetType(XYZObject)) serialize.Serialize(obWtiter, obObject) But I need the following ' xsi:noNamespaceSchemaLocation="obj-envelope.xsd"' to be included in the in the main opening tag How can I cause the XmlSerializer to do that? Thank you, Samuel "Samuel" <samuel.shulman@ntlworld.com> wrote in message news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl... > > > > I use the following code to create the XM...

Redundant qualified xsi:type's
I have created a schema to write out some configuration data, and the OutPort element uses an abstract complex type (it can be a Message, Discrete, Continuous, Array, etc...). I use the provided XSD.exe tool with the /c option to generate the XML-attribute'd classes. When the data is written to disk is looks like this: <OutPort xmlns:q1="urn:MicroMax:MxVDev:3.x" xsi:type="q1:SignalDiscrete" Name="brd0/di0"> <Minimum>0</Minimum> <Maximum>1</Maximum> </OutPort...

XmlDocument xsi: Problem
I've been looking through MSDN, books and googling for a couple hours but haven't found the solution yet. I'm using CSharp in VS .NET 2003. I'm trying to use XmlDocument to save XML files that are valid to a schema I've developed. I want the root element to look like this: <TestCase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TestCaseSchema_03.xsd"> I've tried several variations of XmlElement.SetAttribute() and " XmlAttribute att = [XmlDocument].CreateAttribute() " The closest I'...

XmlRootAttribute Hide xmlns:xsi
I have xml returning from a webservice which look like so... <CiscoIPPhoneMenu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Title>Title</Title> <Prompt>Select A Service</Prompt> <MenuItem> <Name>name</Name> <URL>http://</URL> </MenuItem> </CiscoIPPhoneMenu> how do I make the XmlRootAttribute look like this... <CiscoIPPhoneMenu> <Title>Title</Title> <Prompt>Select A Service</Prompt> <MenuIt...

changing the xsi:type
I have an arraylist with up to 4 different classes that can be contained. e.g.... <carpark> <car /> <truck /> <motorcycle /> <rv /> </carpark> It's largely working. The output is:- <carpark> <anytype xsi:type="xmlcar" /> <anytype xsi:type="xmltruck" /> <anytype xsi:type="xmlmotorcycle" /> <anytype xsi:type="xmlrv" /> </carpark> I've tried changing the element name, the arrayitem name, but I can't get it to rename from "xmlcar" to ...

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(&q...

Validation error The 'xsi:noNameSpaceSchemaLocation' attribute is not declared
Hi, I'm getting the following error trying to validate an xml document against a schema: The 'xsi:noNameSpaceSchemaLocation' attribute is not declared My xml file looks like this: <?xml version="1.0" encoding="utf-8"?> <TitleNotification xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" d1p1:noNameSpaceSchemaLocation="http://www.pdr.com&#xA;https://extw3c.pdr.co m/prism/b2b/schemas/TitleNotification.xsd" ParagonID="1234" Version="1" Source="5&quo...

understanding use of xsi:type
I have a bit of xml that I am trying to create an xsd schema from. A very simplified version is as follows: <?xml version="1.0" encoding="UTF-8"?> <centre xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:ucles.cbtas.model.Centre"> <number>25279</number> <customer-id>16</customer-id> </centre> The real xml is much more complex but the basic problem is the same. If I use xsd.exe to create a schema from this I get the following: <?xml version="1.0" encoding="utf-8"...

Dataset diffgram doesn't set xsi:nil for nullable elements
I found a post about this exact issue: http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/1dfeb38170cb0b1/ea073666a4035bd5?lnk=st&q=decimal+parse+error+loading+dataset&rnum=6&hl=en#ea073666a4035bd5 but it only shows how to correct the issue manually, not whether it is a known bug. My situation is slightly different only in that the xml data and schema I have are coming directly from the DataSet using: DataSet.GetXml() DataSet.GetXmlSchema() I have a nullable numeric database column: MONTHS I want to be able to actualy set the value to null in the da...

How to serialize with xsi:noNamespaceSchemaLocation attribute?
Hello, I have got a schema file "myschema.xsd" from my customer for which I must create xml files. I used xsd.exe to create a class for the schema. I fill an object for that class with data and serialize it. My customer gave me an example xml file, how it should look like, and it begins with <?xml version="1.0" encoding="UTF-8"?> <muma xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="myschema.xsd"> <name> .... ========= Question: ========= How do I achieve to get the attributes xmlns...

serialize c# class with xsi:type attribute
This may be a simple question, but I'm struggling to find the answer to it, so any suggestions would be greatly appreciated.... I want to know if there's some way to ensure that the xsi:type attribute is included when serializing a c# class. The basic situation is this: I have a class, ClassB which derives from ClassA. ClassC contains a list of ClassB, which I want to serialize as an XmlArray of 'bListItem's as per the code below: [Serializable] [XmlType("classA")] public class ClassA { private string _id; [XmlAttribute("id&quo...

How to add xsi:schemaLocation attribute to XML element
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 add this to the XML element Please help me with if you can. Thanks, kaush The root element of the document can contain, along with all the xmlns stuff, an attribute called xsi:schemaLocation="namespaceURI filename.xsd" There are two tokens inside the single string. This is a hint for the validator to know where to find a physical xsd file to...

"xsi:type" from Dataset.GetXML
Hello, Is it possible to make the dataset give the "xsi:type" data as well?. I need result from the dataset.GetXML method something like this for the column "a": <a xsi:type="int">12</a> Is it possible?. I would appreciate any pointers/code help. Thanks. Ganesh, I use the XmlTypeAttribute for this. [XmlTypeAttribute("int")] My problem is the opposite. I don't want it to be there. Apparently, when you serialized derived classes the serialization framework takes it upon itself to specify the actual specialized class that the da...

Deserializing with xsi:type="xsd:string"
I have a custom hashtable (a Dictionary<string, object>) for type-varying (database-derived) values with which I've implemented IXmlSerializable using XmlSerializer. The output of the value of a string typed as System.Object is like so: <anyType xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">it works</anyType> When I use more or less the same XmlSerializer to deserialize this value, I get an error: System.InvalidOperationException: Namespace prefix 'xsd' is not defined. I see what's going on, bu...

Removing xmlns:xsd and xmlns:xsi when using ImportNode
I'm doing some document merging where I want to bring in an XmlDocument and import its document element into another document deeper in its tree. However, when serializing my underlying objects, .Net likes to add these namespaces: <RootNode xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ChildNode xmlns="MyObjectHierarchyNamespace/> </RootNode> The problem this is causing me is that any node(s) that have those namespaces get properly imported into the XML, but those nodes fail to dese...

How to add xsi:schemaLocation attribute to XML element #2
Hi all, I am trying to serialize a C# object into a XML document usin "XmlSerializer" class. One of the elements of the XML document needs "xsi:schemaLocation" attribute. I am not sure how to add this to my XM element Please help me with this if you can. Thanks, kaus -- kaushsoa ----------------------------------------------------------------------- kaushsoap's Profile: http://www.msusenet.com/member.php?userid=544 View this thread: http://www.msusenet.com/t-187116553 ...

programatically adding attribute xsi:nil=true to XML element
Hi, I want to add the xsi:nil="true' attribute to an element in XML. I am using XmlNode.Attributes.Append() but the generated output results in the attribute [nil="true"] ignoring the "xsi:" prefix. How do I work around this problem?. Nabeel Moeen wrote: > I want to add the xsi:nil="true' attribute to an element in XML. I am using > XmlNode.Attributes.Append() but the generated output results in the attribute > [nil="true"] ignoring the "xsi:" prefix. It works like this, using CreateAttribute and SetAttributeNode: ...

"xsi:type" missing from serialization of object- XmlSerializer
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new FileStream(NavCmdFile, FileMode.Create, FileAccess.Write, FileShare.None); XmlSerializer xmlFmt = new XmlSerializer(someObject.GetType()); xmlFmt.Serialize(fs, someObject); One of the objects is a parameter and this is what you get: <someObject_parameter> <name>name</name> <source>soucename</source> <value type="xsd:int">1</value> </someObject_param...

Reading the value of an "xsi:type" attribute [unfortunate, but necessary cross-posting]
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and outs with datasets and datatables (and navigating through the filled datatable)... Just when I thought I had gotten the hang of it, another problem arose: I can't seem to access the "xsi:type" attribute. That is, the XML file looks something like this: .... <situation> <objectID>123</objectId> <situationElement xsi:type="td:roadWorksType"> ....