Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

Get valid elements using XmlSchema - .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
merdaf - 06 Jul 2006 16:03 GMT
Hallo all,

I am looking for a funcion in the .Net framework that returns a list of
all the valid elements, for a specific element, accrording to the xml
schema restrictions.

I will try to be more accurate using this example:
if this is the xml
<a>
  <b>
 </b>
</a>

and this is the xml schema:
<xs:element name="a">
   <xs:complexType>
     <xs:sequence>
       <xs:element name="b" type="xs:string"/>
       <xs:element name="c" type="xs:string"/>
     </xs:sequence>
  </xs:complexType>
</xs:element>

I am looking for a function that returns the element 'c' as the only
element valid for element 'a' (and this is true because element 'b' is
already decleared in the xml)

I have used XmlSchemaValidator.GetExpectedParticles() but it doesn't
help - it returns all the possible values regardless to the xml data.
in this case it returns a list with both 'b' and 'c'.

I really appreciate any help in this matter,
Thanks in advance,
Izik Lisbon
Priya Lakshminarayanan - 06 Jul 2006 18:11 GMT
XmlSchemaValidator.GetExpectedParticles() is the right method to use.
XmlSchemaValidator is a push model validation engine and
GetExpectedParticles will return expected elements given the current state
of the validator.
Consider the following sequence of calls,
ValidateElement(a)
GetExpectedParticles() -> Should return b since b is the next expected
element as a's first child
ValidateElement(b)
ValidateEndElement() -> closing b's context
GetExpectedParticles() -> should return c since c is the next expected
sibling

Thanks,
Priya

> Hallo all,
>
[quoted text clipped - 30 lines]
> Thanks in advance,
> Izik Lisbon

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.