http://bugzilla.novell.com/show_bug.cgi?id=502251
User jonas.lars...@manodo.se added comment http://bugzilla.novell.com/show_bug.cgi?id=502251#c82010 Summary: Xml schema validation fails in XmlSchemaComplexType in some cases due to incorrect order of checks (patch included) Classification: Mono Product: Mono: Class Libraries Version: 2.4.x Platform: i686 OS/Version: Ubuntu Status: NEW Severity: Normal Priority: P5 - None Component: Sys.XML AssignedTo: atsu...@ximian.com ReportedBy: jonas.lars...@manodo.se QAContact: mono-bugs@lists.ximian.com Found By: --- Created an attachment (id=291049) --> (http://bugzilla.novell.com/attachment.cgi?id=291049) Patch for XmlSchemaComplexType. Fixes this bug without regressions User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10 Under certain circumstances validation of XmlSchemaComplexType fails due to the order of the different actions in the Validate () method. Judging from the test case for the non public bug #82010, I think the two are related. Put shortly: Problems occur if a type somehow can have itself as "child". The following test code demonstrates the problem, which only exists on mono ans not .net. The test code is quite long, sorry for that. Original code is several thousands of lines. I tried to strip it to keep it as simple as possible. Test code: fails on mono "XmlSchema error: Invalid start element: foo:Conditional" ----------- string xsd = @" <xs:schema id='foo' targetNamespace='foo' elementFormDefault='qualified' xmlns='foo' xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:group name='LayoutElementTypes'> <xs:choice> <xs:element name='Rows' type='Rows' /> <xs:element name='Conditional' type='Conditional' /> </xs:choice> </xs:group> <xs:complexType name='Element' abstract='true'> <xs:attribute name='id' type='xs:ID' use='optional'/> </xs:complexType> <xs:complexType name='SingleChildElement' abstract='true'> <xs:complexContent> <xs:extension base='Element'> <xs:group ref='LayoutElementTypes' minOccurs='1' maxOccurs='1' /> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name='Rows'> <xs:complexContent> <xs:extension base='Element'> <xs:sequence minOccurs='1' maxOccurs='unbounded'> <xs:element name='Row' type='Row' /> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name='Row'> <xs:complexContent> <xs:extension base='SingleChildElement'> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name='Conditional'> <xs:complexContent> <xs:extension base='Element'> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name='Layout'> <xs:complexContent> <xs:extension base='SingleChildElement'> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name='Layout' type='Layout' /> </xs:schema>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(@"<Layout xmlns='foo'> <Rows> <Row> <Conditional/> </Row> </Rows> </Layout>"); XmlSchema schema = XmlSchema.Read(XmlReader.Create(new StringReader(xsd)), null); doc.Schemas.Add(schema); doc.Validate(null); // Mono fails here "XmlSchema error: Invalid start element: foo:Conditional" ------------ Solution: Do exactly the same things as today but in a slightly different order. The patch reorders the operations so that this bug is eliminated. I made the above code into a unit test. My patch produces no regressions, so it should be safe to use/commit. Reproducible: Always Steps to Reproduce: Run above code Actual Results: Validation fails Expected Results: Successful validation The attached patch fixes this bug without regressions. Please feel free to use the posted code as an unit test. That's what I have locally, but I don't know how to generate diff for it since it contains new unrelated tests... :-( -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - mono-bugs@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-bugs