473,396 Members | 2,011 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,396 software developers and data experts.

Finding nested elements in XSD

I've got a schema loaded into a XmlSchema class. Via the elements
collection I can see all the elements defiend at the root of the
schema. How can I get the definition of a nested schema element?

Thanks.

Nov 12 '05 #1
3 1953
Here's an example that shows how to traverse XmlSchema object.

void Start()
{
XmlSchemaComplexType complexType;
foreach (XmlSchemaType type in xs.SchemaTypes.Values)
{
complexType = type as XmlSchemaComplexType;
if (complexType != null)
TraverseParticle(complexType.ContentTypeParticle);
}

foreach (XmlSchemaElement el in xs.Elements.Values)
TraverseParticle(el);
}

void TraverseParticle(complexType.ContentTypeParticle)
{
if (particle is XmlSchemaElement)
{
XmlSchemaElement elem = particle as XmlSchemaElement;

if (elem.RefName.IsEmpty)
{
XmlSchemaType type = (XmlSchemaType)elem.ElementSchemaType;
XmlSchemaComplexType complexType = type as XmlSchemaComplexType;
if (complexType != null && complexType.Name == null)
TraverseParticle(complexType.ContentTypeParticle);
}
}
else if (particle is XmlSchemaGroupBase)
{ //xs:all, xs:choice, xs:sequence
XmlSchemaGroupBase baseParticle = particle as XmlSchemaGroupBase;
foreach (XmlSchemaParticle subParticle in baseParticle.Items)
TraverseParticle(subParticle);
}
}
--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"SideByEach" <kn*****@nb.sympatico.ca> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I've got a schema loaded into a XmlSchema class. Via the elements
collection I can see all the elements defiend at the root of the
schema. How can I get the definition of a nested schema element?

Thanks.

Nov 12 '05 #2
A thanks for the quick response. I think I get the gist of your code,
but I've never written any C# before so it's a little criptic. Do you
have a VB.Net example?

Nov 12 '05 #3
I don't have a VB example, but you can probably use one of the C# to VB
converters to get the code.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"SideByEach" <kn*****@nb.sympatico.ca> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
A thanks for the quick response. I think I get the gist of your code,
but I've never written any C# before so it's a little criptic. Do you
have a VB.Net example?

Nov 12 '05 #4

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

Similar topics

1
by: Stanimir Stamenkov | last post by:
Here's an example: <form action="bogus" method="post"> <p> <a href="prev.cgi"><input type="submit" name="prev" value="< Back"></a> <a href="next.cgi"><input type="submit" name="next"...
9
by: Dustin | last post by:
Here's what I am trying to do: (Names represent CSS classes.) I want to create a photo gallery. I want the entire gallery to be surrounded by a box named PhotoGallery. I want a fluid placement...
5
by: horndude77 | last post by:
Ok, this might be for a web designing group, but here's my problem. I'm trying to make a web page with tabs which you can navigate between without the page reloading. I have one set of tabs working...
5
by: Markus Ernst | last post by:
Hi I have a validation problem with a form and nested divs. I understand what the problem is, but I don't see how to fix it. This is my normal page structure, and it validates: <!DOCTYPE HTML...
46
by: Neptune | last post by:
Hello. I am working my way through Zhang's "Teach yourself C in 24 hrs (2e)" (Sam's series), and for nested loops, he writes (p116) "It's often necessary to create a loop even when you are...
1
by: psmahesh | last post by:
Hi folks, I am comparing two arrays and removing matches from the second array from the first array. Can someone take a look at this code below and mention if this is okay and perhaps if there...
2
by: Bardo | last post by:
Hi all, I am a newbie to using the XML Schema Object Model (SOM) and would like a few pointers on how to perform a particular task. I am essentially trying to search for elements/attributes via...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
1
by: Henrik Bechmann | last post by:
All, I'm trying to spoof Google's vertical tabs in a vertical menu structured with nested UL/LI elements. To do this, I need to find out where the anchor in the LI is, and then create an...
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
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.