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