[Mono-bugs] [Bug 502168] New: Xml schema validation: Group references handled incorrectly in some cases (Patch included)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri May 8 10:32:01 EDT 2009


           Summary: Xml schema validation: Group references handled
                    incorrectly in some cases (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: atsushi at ximian.com
        ReportedBy: jonas.larsson at manodo.se
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=291005)
 --> (http://bugzilla.novell.com/attachment.cgi?id=291005)
Patch for this bug

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:
Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10

There is a bug in monos handling of xml schema group references. I shows
itself if the same group is used in different contexts. I have tried
to keep the length of the following test code to a minimum, but it's still
quite long. Sorry for that! (Original schema is ~4k lines!)

Test code
On mono it will fail with "Invalid complex content extension was found."
net works ok.

 string xsd = @"<xs:schema id='Layout'

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

 <xs:complexType name='Layout'>
  <xs:group ref='AnyLayoutElement' minOccurs='0' maxOccurs='unbounded' />

 <xs:group name='AnyLayoutElement'>
   <xs:element name='Layout' type='Layout' />   
   <xs:element name='ImageContainer' type='ImageContainer' />
   <xs:element name='VideoInstance' type='VideoInstance'/>

 <xs:complexType name='ImageDummy'>

 <xs:complexType name='LayoutElement' abstract='true'>  

 <xs:group name='AnyImageElement'>
   <xs:element name='ImageDummy' type='ImageDummy' />

 <xs:complexType name='ImageContainer'>
   <xs:extension base='LayoutElement'>
    <xs:choice minOccurs='1' maxOccurs='1'>
     <xs:element name='Content' type='SingleImage' minOccurs='1' maxOccurs='1'

 <xs:complexType name='SingleImage'>
  <xs:group ref='AnyImageElement' minOccurs='1' maxOccurs='1'/>

 <xs:complexType name='VideoApplicationFile'>
   <xs:extension base='VideoInstance'>
    <xs:attribute name='fileName' type='xs:string' use='optional'/>

 <xs:complexType abstract='true' name='Video'>
   <xs:extension base='LayoutElement'>
    <xs:group ref='AnyImageElement' minOccurs='0' maxOccurs='1'/>    

 <xs:complexType abstract='true' name='VideoInstance'>
   <xs:extension base='Video'>
    <xs:attribute name='name' type='xs:string' use='optional'/>

 XmlDocument doc = new XmlDocument();
 XmlSchema schema = XmlSchema.Read(XmlReader.Create(new StringReader(xsd)),
 doc.LoadXml(@"<Layout xmlns='foo' />");
 doc.Validate(null); // Mono fails here "Invalid complex content extension was


When calculating OptimizedParticle for XmlSchemaGroupRef a shallow clone of a
calculated optimized particle is created:
OptimizedParticle = OptimizedParticle.GetShallowClone ();

This particle in turn can have an already calculated OptimizedParticle, that's
guaranteed to be valid in the current context since GroupRef's can be used in

After getting the shallow clone above, set it's optimized particle to null.
will stop the old one from being used in an invalid context:
OptimizedParticle.OptimizedParticle = null;

Reproducible: Always

Steps to Reproduce:
Run above test code
Actual Results:  
Validation fails

Expected Results:  
Successful validation

My local changes are starting to pile up now. I don't know how to create a
patch for the unit test, since that file contains several new tests not related
to this bug. Please use the posted code as basis for a unit test.

As with all the patches I submit, I've run all tests with no regressions before

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