[Mono-bugs] [Bug 502251] New: Xml schema validation fails in XmlSchemaComplexType in some cases due to incorrect order of checks (patch included)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri May 8 12:55:12 EDT 2009


User jonas.larsson at manodo.se added comment

           Summary: Xml schema validation fails in XmlSchemaComplexType in
                    some cases due to incorrect order of checks (patch
    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: atsushi at ximian.com
        ReportedBy: jonas.larsson at manodo.se
         QAContact: mono-bugs at 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:
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 

Test code:
fails on mono "XmlSchema error: Invalid start element: foo:Conditional"

string xsd = @"
   <xs:schema id='foo' targetNamespace='foo' 

 <xs:group name='LayoutElementTypes'>
   <xs:element name='Rows' type='Rows' />
   <xs:element name='Conditional' type='Conditional' />   

 <xs:complexType name='Element' abstract='true'>
  <xs:attribute name='id' type='xs:ID' use='optional'/>

 <xs:complexType name='SingleChildElement' abstract='true'>
   <xs:extension base='Element'>
    <xs:group ref='LayoutElementTypes' minOccurs='1' maxOccurs='1' />

 <xs:complexType name='Rows'>
   <xs:extension base='Element'>
    <xs:sequence minOccurs='1' maxOccurs='unbounded'>
     <xs:element name='Row' type='Row' />

   <xs:complexType name='Row'>
   <xs:extension base='SingleChildElement'>    

 <xs:complexType name='Conditional'>
   <xs:extension base='Element'>    

 <xs:complexType name='Layout'>
   <xs:extension base='SingleChildElement'>

 <xs:element name='Layout' type='Layout' />

XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<Layout xmlns='foo'>

XmlSchema schema = XmlSchema.Read(XmlReader.Create(new StringReader(xsd)),

doc.Validate(null); // Mono fails here "XmlSchema error: Invalid start element:


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.

More information about the mono-bugs mailing list