![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Validation problem in XMLValidatingReader Validation problem in XMLValidatingReaderTo: NULL Date: 4/6/2005 7:44:00 AM Hi!
I need to validate this xml file
--------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<ElementGroup1A xmlns= "http://tempuri.org/XMLSchema.xsd">
<Na></Na>
<Li></Li>
</ElementGroup1A>
---------------------------------------------
according to this schema
-----------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ElementGroup1A">
<xs:complexType mixed="true">
<xs:choice>
<xs:element ref="SodiumFamily"></xs:element>
<xs:element ref="H"></xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="H"></xs:element>
<xs:element name="Na"></xs:element>
<xs:element name="Li"></xs:element>
<xs:element name="Ca"></xs:element>
<xs:element name="SodiumFamily">
<xs:complexType mixed="true">
<xs:choice>
<xs:element ref="Na"></xs:element>
<xs:element ref="Li"></xs:element>
<xs:element ref="Ca"></xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
------------------------------------------------------------
I am using XMLValidatingReader as
-------------------------------------------------------------
Dim v As New Xml.XmlValidatingReader(TextArea.Text,
Xml.XmlNodeType.Element, Nothing)
v.Schemas.Add("http://tempuri.org/XMLSchema.xsd", "XMLSchema.xsd")
v.ValidationType = Xml.ValidationType.Schema
AddHandler v.ValidationEventHandler, AddressOf errorDetector
While v.Read : End While
-----------------------------------------------------------------------
but validator finds following validation errors in the XML
------------------------------------------------------------
The element 'http://tempuri.org/XMLSchema.xsd:ElementGroup1A' has
invalid child element 'http://tempuri.org/XMLSchema.xsd:Na'. Expected
'http://tempuri.org/XMLSchema.xsd:SodiumFamily
http://tempuri.org/XMLSchema.xsd:H'. An error occurred at , (3, 3).
--------------------------------------------------------------
You can see XMLValidatingReader is taking SodiumFamily as an element
rather than a block of element.Is there any way that i can compell
XMLValidatingReader to differntiate between element and block of
elements or is there any modification i can do in schema.
Regards,
Khawar
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
