473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with .NET Beta2 upgrade, with XSD traversal (LocalElements issue!!) ...Please help

Hello,

I had a program in .NET Beta1, where in I was programmatically traversing
the Xml Schema using the given code snippet.

However today with migration to Beta2, I am facing a compilation issue that
LocalElements property on XmlSchemaComplexType not found. I now dont know
how to traverse XSD programmatically!!!
- I have a 4 level heirarchy XSD with a mix and match of complex elements
containing content and attributes both!

Please do help. Our current application BREAKS and I cannot go ahead with
development which is in its important phase, to be delivered by tomorrow!!

I would like to know what way I can traverse an XSD in a generic fashion as
possible, so that I could go to 1st level, 2nd level, 3rd or 4th level with
same peice of foreach code. Some documentation would reallly help. Also why
the LocalElements is not supported, I see its only supported in Compact
framework....
===========================================
XmlReader reader = new XmlTextReader(fileName);
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchema schema = XmlSchema.Read(reader, null);
XmlSchemaObjectEnumerator itr = schema.Items.GetEnumerator();

//schema is added to schemaset
schemaSet.Add(schema);
// compile schemaset : some properties are enabled post compilation
schemaSet.Compile();

// A better way to Traverse the XSD
foreach (XmlSchemaElement parentElem in schema.Elements.Values)
{
XmlSchemaComplexType ct = parentElem.ElementSchemaType as
XmlSchemaComplexType;
if (ct != null)
{
foreach (XmlSchemaElement childElem in ct.LocalElements.Values)
{
string str = childElem.Name;
XmlSchemaComplexType ct1 = childElem.ElementSchemaType as
XmlSchemaComplexType;
Type type = null;
foreach (XmlSchemaElement gChildElem in ct1.LocalElements.Values)
{
if (gChildElem != null)
{
// Inner elements
string str1 = gChildElem.Name;
XmlSchemaComplexType ct2 = gChildElem.ElementSchemaType as
XmlSchemaComplexType;
foreach (XmlSchemaElement gGChildElem in ct2.LocalElements.Values)
{
decimal occurence = gGChildElem.MaxOccurs;
}
}//if
}//foreach
}//foreach
}//if ct !=null
}//foreach
===========================================

Thanks
Uma

Jul 21 '05 #1
0 1176

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

Similar topics

12
1455
by: Bill | last post by:
When I compile the following code fragment, the compiler errors saying the variable connection is not initialized. As I understand C#, I thought it would be initialized. Please help me and explain...
5
1561
by: Nevets Steprock | last post by:
I have been building a website diligently for the past three months and everything has been working well so far. Yesterday, I added a link on my javascript menu. This link is supposed to go to a...
0
193
by: Uma Abhyankar | last post by:
Hello, I had a program in .NET Beta1, where in I was programmatically traversing the Xml Schema using the given code snippet. However today with migration to Beta2, I am facing a compilation...
8
6561
by: Dip | last post by:
Hello Experts, Here is the code to flatten a PC hierarchy into a level based table. It works fine. SELECT t1.TASK_ID AS TASK_LV1, t2.TASK_ID AS TASK_LV2, t3.TASK_ID AS TASK_LV3, t4.TASK_ID AS...
0
1177
by: jegray | last post by:
I am very much a beginner in dealing with connection statments. I am getting the following error: Microsoft OLE DB Provider for ODBC Drivers error '80004005' Data source name not found and no...
5
1671
nabh4u
by: nabh4u | last post by:
hi, i have a program where every thing is working properly. i have a vector with some values. i use iterators and delete a specific value in the vector. here the loop runs infinitely only for some...
1
1548
by: hemendravyas | last post by:
Please help out in following code snippet: For the first time it gives prompt while XmlSchema.Read(). Second time schema_collection_object is not null and so does not enter into this block of...
5
2934
by: suma | last post by:
hi to all plaese help me i have same problem when download the phpdev and phptriad i cant connect to mysql when click the MyAdmin apear this messege in the page 'Warning: MySQL Connection...
12
1619
by: hotflash | last post by:
Hi All, There is a field in my MS Access database called WorkDescription and it is set to MEMO. Required: No Allow Zero Length: Yes Indexed: No Unicode Compression: Yes Sometimes if...
0
7125
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
7002
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
7165
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
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4588
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...
0
3093
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...
0
1417
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 ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
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...

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.