473,748 Members | 8,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot Load Dataset with XMLSCHEMA object or Schema as string

Hi all,

I have a weird problem which has been causing me a headache for the last two
days.

I have to dynamicly generate a schema in memory and load it into a dataset
in memory to be returned for further use.
To create the schema I am using the XMLSchema classes and the result is the
following which compiles successfully:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
xmlns:mstns="Te st.Keystone.Ser vices.Schema.En tityName"
xmlns:msprop="u rn:schemas-microsoft-com:xml-msprop"
xmlns="Test.Key stone.Services. Schema.EntityNa me"
attributeFormDe fault="unqualif ied" elementFormDefa ult="unqualifie d"
targetNamespace ="Test.Keystone .Services.Schem a.EntityName" id="EntityName "
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="EntityNam eTable">
<xs:sequence>
<xs:element msprop:Generato r_UserColumnNam e="EntityNameCo unter"
msprop:Generato r_ColumnPropNam eInRow="EntityN ameCounter"
msprop:Generato r_ColumnVarName InTable="column EntityNameCount er"
msprop:Generato r_ColumnPropNam eInTable="Entit yNameCounterCol umn"
msdata:ReadOnly ="true" msdata:AutoIncr ement="true" form="unqualifi ed"
name="EntityNam eCounter" type="xs:int" />
<xs:element msprop:Generato r_UserColumnNam e="EntityIDCoun ter"
msprop:Generato r_ColumnPropNam eInRow="EntityI DCounter"
msprop:Generato r_ColumnVarName InTable="column EntityIDCounter "
msprop:Generato r_ColumnPropNam eInTable="Entit yIDCounterColum n"
msdata:ReadOnly ="true" form="unqualifi ed" name="EntityIDC ounter"
type="xs:int" />
<xs:element msprop:Generato r_UserColumnNam e="EntityName "
msprop:Generato r_ColumnPropNam eInRow="EntityN ame"
msprop:Generato r_ColumnVarName InTable="column EntityName"
msprop:Generato r_ColumnPropNam eInTable="Entit yNameColumn"
msdata:ReadOnly ="true" form="unqualifi ed" name="EntityNam e">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="200" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="SortName"
msprop:Generato r_ColumnPropNam eInRow="SortNam e"
msprop:Generato r_ColumnVarName InTable="column SortName"
msprop:Generato r_ColumnPropNam eInTable="SortN ameColumn" minOccurs="0"
form="unqualifi ed" name="SortName" >
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="485" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="OtherName"
msprop:Generato r_ColumnPropNam eInRow="OtherNa me"
msprop:Generato r_ColumnVarName InTable="column OtherName"
msprop:Generato r_ColumnPropNam eInTable="Other NameColumn" minOccurs="0"
form="unqualifi ed" name="OtherName ">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="200" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="LookupTitleC ounter"
msprop:Generato r_ColumnPropNam eInRow="LookupT itleCounter"
msprop:Generato r_ColumnVarName InTable="column LookupTitleCoun ter"
msprop:Generato r_ColumnPropNam eInTable="Looku pTitleCounterCo lumn"
minOccurs="0" form="unqualifi ed" name="LookupTit leCounter" type="xs:int" />
<xs:element msprop:Generato r_UserColumnNam e="Forename1"
msprop:Generato r_ColumnPropNam eInRow="Forenam e1"
msprop:Generato r_ColumnVarName InTable="column Forename1"
msprop:Generato r_ColumnPropNam eInTable="Foren ame1Column" minOccurs="0"
form="unqualifi ed" name="Forename1 ">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="Forename2"
msprop:Generato r_ColumnPropNam eInRow="Forenam e2"
msprop:Generato r_ColumnVarName InTable="column Forename2"
msprop:Generato r_ColumnPropNam eInTable="Foren ame2Column" minOccurs="0"
form="unqualifi ed" name="Forename2 ">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="Forename3"
msprop:Generato r_ColumnPropNam eInRow="Forenam e3"
msprop:Generato r_ColumnVarName InTable="column Forename3"
msprop:Generato r_ColumnPropNam eInTable="Foren ame3Column" minOccurs="0"
form="unqualifi ed" name="Forename3 ">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="Forename4"
msprop:Generato r_ColumnPropNam eInRow="Forenam e4"
msprop:Generato r_ColumnVarName InTable="column Forename4"
msprop:Generato r_ColumnPropNam eInTable="Foren ame4Column" minOccurs="0"
form="unqualifi ed" name="Forename4 ">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="Initials"
msprop:Generato r_ColumnPropNam eInRow="Initial s"
msprop:Generato r_ColumnVarName InTable="column Initials"
msprop:Generato r_ColumnPropNam eInTable="Initi alsColumn" minOccurs="0"
form="unqualifi ed" name="Initials" >
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="Nickname"
msprop:Generato r_ColumnPropNam eInRow="Nicknam e"
msprop:Generato r_ColumnVarName InTable="column Nickname"
msprop:Generato r_ColumnPropNam eInTable="Nickn ameColumn" minOccurs="0"
form="unqualifi ed" name="Nickname" >
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="Honours"
msprop:Generato r_ColumnPropNam eInRow="Honours "
msprop:Generato r_ColumnVarName InTable="column Honours"
msprop:Generato r_ColumnPropNam eInTable="Honou rsColumn" minOccurs="0"
form="unqualifi ed" name="Honours">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="ShortName"
msprop:Generato r_ColumnPropNam eInRow="ShortNa me"
msprop:Generato r_ColumnVarName InTable="column ShortName"
msprop:Generato r_ColumnPropNam eInTable="Short NameColumn" minOccurs="0"
form="unqualifi ed" name="ShortName ">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="200" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="EffectiveFro m"
msprop:Generato r_ColumnPropNam eInRow="Effecti veFrom"
msprop:Generato r_ColumnVarName InTable="column EffectiveFrom"
msprop:Generato r_ColumnPropNam eInTable="Effec tiveFromColumn" minOccurs="0"
form="unqualifi ed" name="Effective From" type="xs:dateTi me" />
<xs:element msprop:Generato r_UserColumnNam e="NatureOfChan ge"
msprop:Generato r_ColumnPropNam eInRow="NatureO fChange"
msprop:Generato r_ColumnVarName InTable="column NatureOfChange"
msprop:Generato r_ColumnPropNam eInTable="Natur eOfChangeColumn " minOccurs="0"
form="unqualifi ed" name="NatureOfC hange">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generato r_UserColumnNam e="IsConfirme d"
msprop:Generato r_ColumnPropNam eInRow="IsConfi rmed"
msprop:Generato r_ColumnVarName InTable="column IsConfirmed"
msprop:Generato r_ColumnPropNam eInTable="IsCon firmedColumn"
msdata:ReadOnly ="true" form="unqualifi ed" name="IsConfirm ed"
type="xs:boolea n" />
<xs:element msprop:Generato r_UserColumnNam e="DateEffectiv eTo"
msprop:Generato r_ColumnPropNam eInRow="DateEff ectiveTo"
msprop:Generato r_ColumnVarName InTable="column DateEffectiveTo "
msprop:Generato r_ColumnPropNam eInTable="DateE ffectiveToColum n" minOccurs="0"
form="unqualifi ed" name="DateEffec tiveTo" type="xs:dateTi me" />
<xs:element msprop:Generato r_UserColumnNam e="DateEffectiv eFrom2"
msprop:Generato r_ColumnPropNam eInRow="DateEff ectiveFrom2"
msprop:Generato r_ColumnVarName InTable="column DateEffectiveFr om2"
msprop:Generato r_ColumnPropNam eInTable="DateE ffectiveFrom2Co lumn"
minOccurs="0" form="unqualifi ed" name="DateEffec tiveFrom2" type="xs:dateTi me"
/>
<xs:element msprop:Generato r_UserColumnNam e="DateEffectiv eTo2"
msprop:Generato r_ColumnPropNam eInRow="DateEff ectiveTo2"
msprop:Generato r_ColumnVarName InTable="column DateEffectiveTo 2"
msprop:Generato r_ColumnPropNam eInTable="DateE ffectiveTo2Colu mn" minOccurs="0"
form="unqualifi ed" name="DateEffec tiveTo2" type="xs:dateTi me" />
<xs:element msprop:Generato r_UserColumnNam e="CreatedByUse rCounter"
msprop:Generato r_ColumnPropNam eInRow="Created ByUserCounter"
msprop:Generato r_ColumnVarName InTable="column CreatedByUserCo unter"
msprop:Generato r_ColumnPropNam eInTable="Creat edByUserCounter Column"
minOccurs="0" form="unqualifi ed" name="CreatedBy UserCounter" type="xs:int" />
<xs:element msprop:Generato r_UserColumnNam e="DateCreate d"
msprop:Generato r_ColumnPropNam eInRow="DateCre ated"
msprop:Generato r_ColumnVarName InTable="column DateCreated"
msprop:Generato r_ColumnPropNam eInTable="DateC reatedColumn" minOccurs="0"
form="unqualifi ed" name="DateCreat ed" type="xs:dateTi me" />
<xs:element msprop:Generato r_UserColumnNam e="ModifiedByUs erCounter"
msprop:Generato r_ColumnPropNam eInRow="Modifie dByUserCounter"
msprop:Generato r_ColumnVarName InTable="column ModifiedByUserC ounter"
msprop:Generato r_ColumnPropNam eInTable="Modif iedByUserCounte rColumn"
minOccurs="0" form="unqualifi ed" name="ModifiedB yUserCounter" type="xs:int" />
<xs:element msprop:Generato r_UserColumnNam e="DateLastModi fied"
msprop:Generato r_ColumnPropNam eInRow="DateLas tModified"
msprop:Generato r_ColumnVarName InTable="column DateLastModifie d"
msprop:Generato r_ColumnPropNam eInTable="DateL astModifiedColu mn" minOccurs="0"
form="unqualifi ed" name="DateLastM odified" type="xs:dateTi me" />
<xs:element msprop:Generato r_UserColumnNam e="mTimestamp "
msprop:Generato r_ColumnPropNam eInRow="mTimest amp"
msprop:Generato r_ColumnVarName InTable="column mTimestamp"
msprop:Generato r_ColumnPropNam eInTable="mTime stampColumn" minOccurs="0"
form="unqualifi ed" name="mTimestam p" type="xs:base64 Binary" />
</xs:sequence>
<xs:attribute name="RowState" use="optional">
<xs:simpleTyp e>
<xs:restricti on base="xs:string ">
<xs:enumerati on value="Unchange d" />
<xs:enumerati on value="Modified " />
<xs:enumerati on value="Added" />
<xs:enumerati on value="Deleted" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:schema>

I am then convert this to s string and try to load this into a dataset using
the LoadXMLSchema property but when I read the schema after accepting changes
in the dataset the result is:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="EntityName "
targetNamespace ="Test.Keystone .Services.Schem a.EntityName"
xmlns:mstns="Te st.Keystone.Ser vices.Schema.En tityName"
xmlns="Test.Key stone.Services. Schema.EntityNa me"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
attributeFormDe fault="qualifie d" elementFormDefa ult="qualified" >
<xs:element name="EntityNam e" msdata:IsDataSe t="true"
msdata:UseCurre ntLocale="true" >
<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded" />
</xs:complexType>
</xs:element>
</xs:schema>

I have tried using anxmldatadocume nt as follows:

StreamReader myStreamReader = null;
myStreamReader = new StreamReader(@" c:\test.xsd");
XmlDataDocument myXmlDataDocume nt = new XmlDataDocument ();
myXmlDataDocume nt.DataSet.Enfo rceConstraints = true;
myXmlDataDocume nt.DataSet.Name space =
"http://www.w3.org/2001/XMLSchema";
myXmlDataDocume nt.DataSet.Read XmlSchema(myStr eamReader);

I have also tried using a simple dataset with the same result.

Any help with this would be much appreciated.
Lastbuilders
Jun 27 '08 #1
0 2035

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5082
by: Max | last post by:
Suppose we have an object hierarchy in XSD. For example, let us take Control, Label, TextBox and LinkLabel windows controls. Each control has some properties which are represented as elements. Some of the elements are of complex types as well, like bounds - of type rectangle. (See full example in the bottom of the letter.) DataSet.ReadXMLSchema fails to parse such XSD file. The problem is caused by complex type as an element of the...
9
2929
by: Rob Mayo | last post by:
I have a bunch of XSD files in my assembly as embedded content that are read out via reflection and streams. My app creates the XML on the fly, and I want to validate it using the schema files embedded in my assembly. Unfortunately, my problem is that every element is coming up invalid. Here is the code: Public Sub Validate(ByVal XmlText As String)Dim strmXML As New System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(XmlText))Dim...
2
6932
by: PeterW | last post by:
I have an xml file from which I want to generate an xsd schema and at a later stage a cs class. The xml file has a mix of defined namespaces and also an empty namespace. These are defined as follows: <silcn:silcn xmlns:silcn='http://silcn.org/200309' xmlns='http://xmlprobe.com/200312'> it contains an element <report> off the root and also a separate <Silcn:report> again off the root.
4
5754
by: Alfetta159 | last post by:
I've been setting up a schema with the XML Designer in VS .NET 2003. The designer lets me set up a lot of things including a complex type that contains an unnamed complex type called modified. When I try to preview the dataset, I get an error described as "The same table (modified) cannot be the child table in two nested relations. I've run into this before with a different complex type, and I've changed the name of the instance of...
4
7486
by: Brian Keating | last post by:
wonder if anyone can help me here, i've a framework 1.1 dataset which i serialize in framework 1.1 and deserialize in framework 2.0. This is fine, problem is that i want to modify some of the records in framework 2.0 and serialize the data so framework 1.1 can deserialize it and do what it required. Is this possible?
0
1202
by: Zimri | last post by:
All, I am trying to read an XML of a set of records (an "order") from one machine and then turn it into a set of records on another machine. But some of the order's dependent records are optional, and I'd like to continue to bypass them when the original user bypassed them. This set spans four tables. One is the header table and the other three are all subject to it. These three are misc charge, instruction, and detail. For any given...
1
11287
by: techie | last post by:
Hi, I am using an xml schema (Schema1.xsd) which refers to two other Schemas as follows. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:plcm-s="http://www.mycompany.com/plcm" targetNamespace="http://www.mycompany.com/plcm" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:include schemaLocation="Schema2.xsd"/> <xsd:include schemaLocation="Schema3.xsd"/>
1
3631
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify xsd:restriction conditions are ingested without a murmur. Is this a bug or a feature? Very frustrating. Evidence: 1) XML data <?xml version="1.0" encoding="utf-8"?>
1
3823
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises the exception ONLY in Web Sites:
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.