473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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="urn:schemas-microsoft-com:xml-msdata"
xmlns:mstns="Test.Keystone.Services.Schema.EntityN ame"
xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"
xmlns="Test.Keystone.Services.Schema.EntityName"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="Test.Keystone.Services.Schema.Ent ityName" id="EntityName"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EntityNameTable">
<xs:sequence>
<xs:element msprop:Generator_UserColumnName="EntityNameCounter "
msprop:Generator_ColumnPropNameInRow="EntityNameCo unter"
msprop:Generator_ColumnVarNameInTable="columnEntit yNameCounter"
msprop:Generator_ColumnPropNameInTable="EntityName CounterColumn"
msdata:ReadOnly="true" msdata:AutoIncrement="true" form="unqualified"
name="EntityNameCounter" type="xs:int" />
<xs:element msprop:Generator_UserColumnName="EntityIDCounter"
msprop:Generator_ColumnPropNameInRow="EntityIDCoun ter"
msprop:Generator_ColumnVarNameInTable="columnEntit yIDCounter"
msprop:Generator_ColumnPropNameInTable="EntityIDCo unterColumn"
msdata:ReadOnly="true" form="unqualified" name="EntityIDCounter"
type="xs:int" />
<xs:element msprop:Generator_UserColumnName="EntityName"
msprop:Generator_ColumnPropNameInRow="EntityName"
msprop:Generator_ColumnVarNameInTable="columnEntit yName"
msprop:Generator_ColumnPropNameInTable="EntityName Column"
msdata:ReadOnly="true" form="unqualified" name="EntityName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="SortName"
msprop:Generator_ColumnPropNameInRow="SortName"
msprop:Generator_ColumnVarNameInTable="columnSortN ame"
msprop:Generator_ColumnPropNameInTable="SortNameCo lumn" minOccurs="0"
form="unqualified" name="SortName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="485" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="OtherName"
msprop:Generator_ColumnPropNameInRow="OtherName"
msprop:Generator_ColumnVarNameInTable="columnOther Name"
msprop:Generator_ColumnPropNameInTable="OtherNameC olumn" minOccurs="0"
form="unqualified" name="OtherName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="LookupTitleCounte r"
msprop:Generator_ColumnPropNameInRow="LookupTitleC ounter"
msprop:Generator_ColumnVarNameInTable="columnLooku pTitleCounter"
msprop:Generator_ColumnPropNameInTable="LookupTitl eCounterColumn"
minOccurs="0" form="unqualified" name="LookupTitleCounter" type="xs:int" />
<xs:element msprop:Generator_UserColumnName="Forename1"
msprop:Generator_ColumnPropNameInRow="Forename1"
msprop:Generator_ColumnVarNameInTable="columnForen ame1"
msprop:Generator_ColumnPropNameInTable="Forename1C olumn" minOccurs="0"
form="unqualified" name="Forename1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="Forename2"
msprop:Generator_ColumnPropNameInRow="Forename2"
msprop:Generator_ColumnVarNameInTable="columnForen ame2"
msprop:Generator_ColumnPropNameInTable="Forename2C olumn" minOccurs="0"
form="unqualified" name="Forename2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="Forename3"
msprop:Generator_ColumnPropNameInRow="Forename3"
msprop:Generator_ColumnVarNameInTable="columnForen ame3"
msprop:Generator_ColumnPropNameInTable="Forename3C olumn" minOccurs="0"
form="unqualified" name="Forename3">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="Forename4"
msprop:Generator_ColumnPropNameInRow="Forename4"
msprop:Generator_ColumnVarNameInTable="columnForen ame4"
msprop:Generator_ColumnPropNameInTable="Forename4C olumn" minOccurs="0"
form="unqualified" name="Forename4">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="Initials"
msprop:Generator_ColumnPropNameInRow="Initials"
msprop:Generator_ColumnVarNameInTable="columnIniti als"
msprop:Generator_ColumnPropNameInTable="InitialsCo lumn" minOccurs="0"
form="unqualified" name="Initials">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="Nickname"
msprop:Generator_ColumnPropNameInRow="Nickname"
msprop:Generator_ColumnVarNameInTable="columnNickn ame"
msprop:Generator_ColumnPropNameInTable="NicknameCo lumn" minOccurs="0"
form="unqualified" name="Nickname">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="Honours"
msprop:Generator_ColumnPropNameInRow="Honours"
msprop:Generator_ColumnVarNameInTable="columnHonou rs"
msprop:Generator_ColumnPropNameInTable="HonoursCol umn" minOccurs="0"
form="unqualified" name="Honours">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="ShortName"
msprop:Generator_ColumnPropNameInRow="ShortName"
msprop:Generator_ColumnVarNameInTable="columnShort Name"
msprop:Generator_ColumnPropNameInTable="ShortNameC olumn" minOccurs="0"
form="unqualified" name="ShortName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="EffectiveFrom"
msprop:Generator_ColumnPropNameInRow="EffectiveFro m"
msprop:Generator_ColumnVarNameInTable="columnEffec tiveFrom"
msprop:Generator_ColumnPropNameInTable="EffectiveF romColumn" minOccurs="0"
form="unqualified" name="EffectiveFrom" type="xs:dateTime" />
<xs:element msprop:Generator_UserColumnName="NatureOfChange"
msprop:Generator_ColumnPropNameInRow="NatureOfChan ge"
msprop:Generator_ColumnVarNameInTable="columnNatur eOfChange"
msprop:Generator_ColumnPropNameInTable="NatureOfCh angeColumn" minOccurs="0"
form="unqualified" name="NatureOfChange">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element msprop:Generator_UserColumnName="IsConfirmed"
msprop:Generator_ColumnPropNameInRow="IsConfirmed"
msprop:Generator_ColumnVarNameInTable="columnIsCon firmed"
msprop:Generator_ColumnPropNameInTable="IsConfirme dColumn"
msdata:ReadOnly="true" form="unqualified" name="IsConfirmed"
type="xs:boolean" />
<xs:element msprop:Generator_UserColumnName="DateEffectiveTo"
msprop:Generator_ColumnPropNameInRow="DateEffectiv eTo"
msprop:Generator_ColumnVarNameInTable="columnDateE ffectiveTo"
msprop:Generator_ColumnPropNameInTable="DateEffect iveToColumn" minOccurs="0"
form="unqualified" name="DateEffectiveTo" type="xs:dateTime" />
<xs:element msprop:Generator_UserColumnName="DateEffectiveFrom 2"
msprop:Generator_ColumnPropNameInRow="DateEffectiv eFrom2"
msprop:Generator_ColumnVarNameInTable="columnDateE ffectiveFrom2"
msprop:Generator_ColumnPropNameInTable="DateEffect iveFrom2Column"
minOccurs="0" form="unqualified" name="DateEffectiveFrom2" type="xs:dateTime"
/>
<xs:element msprop:Generator_UserColumnName="DateEffectiveTo2"
msprop:Generator_ColumnPropNameInRow="DateEffectiv eTo2"
msprop:Generator_ColumnVarNameInTable="columnDateE ffectiveTo2"
msprop:Generator_ColumnPropNameInTable="DateEffect iveTo2Column" minOccurs="0"
form="unqualified" name="DateEffectiveTo2" type="xs:dateTime" />
<xs:element msprop:Generator_UserColumnName="CreatedByUserCoun ter"
msprop:Generator_ColumnPropNameInRow="CreatedByUse rCounter"
msprop:Generator_ColumnVarNameInTable="columnCreat edByUserCounter"
msprop:Generator_ColumnPropNameInTable="CreatedByU serCounterColumn"
minOccurs="0" form="unqualified" name="CreatedByUserCounter" type="xs:int" />
<xs:element msprop:Generator_UserColumnName="DateCreated"
msprop:Generator_ColumnPropNameInRow="DateCreated"
msprop:Generator_ColumnVarNameInTable="columnDateC reated"
msprop:Generator_ColumnPropNameInTable="DateCreate dColumn" minOccurs="0"
form="unqualified" name="DateCreated" type="xs:dateTime" />
<xs:element msprop:Generator_UserColumnName="ModifiedByUserCou nter"
msprop:Generator_ColumnPropNameInRow="ModifiedByUs erCounter"
msprop:Generator_ColumnVarNameInTable="columnModif iedByUserCounter"
msprop:Generator_ColumnPropNameInTable="ModifiedBy UserCounterColumn"
minOccurs="0" form="unqualified" name="ModifiedByUserCounter" type="xs:int" />
<xs:element msprop:Generator_UserColumnName="DateLastModified"
msprop:Generator_ColumnPropNameInRow="DateLastModi fied"
msprop:Generator_ColumnVarNameInTable="columnDateL astModified"
msprop:Generator_ColumnPropNameInTable="DateLastMo difiedColumn" minOccurs="0"
form="unqualified" name="DateLastModified" type="xs:dateTime" />
<xs:element msprop:Generator_UserColumnName="mTimestamp"
msprop:Generator_ColumnPropNameInRow="mTimestamp"
msprop:Generator_ColumnVarNameInTable="columnmTime stamp"
msprop:Generator_ColumnPropNameInTable="mTimestamp Column" minOccurs="0"
form="unqualified" name="mTimestamp" type="xs:base64Binary" />
</xs:sequence>
<xs:attribute name="RowState" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Unchanged" />
<xs:enumeration value="Modified" />
<xs:enumeration value="Added" />
<xs:enumeration 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.Schema.Ent ityName"
xmlns:mstns="Test.Keystone.Services.Schema.EntityN ame"
xmlns="Test.Keystone.Services.Schema.EntityName"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="EntityName" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded" />
</xs:complexType>
</xs:element>
</xs:schema>

I have tried using anxmldatadocument as follows:

StreamReader myStreamReader = null;
myStreamReader = new StreamReader(@"c:\test.xsd");
XmlDataDocument myXmlDataDocument = new XmlDataDocument();
myXmlDataDocument.DataSet.EnforceConstraints = true;
myXmlDataDocument.DataSet.Namespace =
"http://www.w3.org/2001/XMLSchema";
myXmlDataDocument.DataSet.ReadXmlSchema(myStreamRe ader);

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 2010

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

Similar topics

0
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....
9
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...
2
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...
4
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. ...
4
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...
0
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...
1
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"...
1
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...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
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...

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.