[Mono-bugs] [Bug 502115] New: Xml schema validation: Inconsistent attribute inheritance in mono <-> .net (Patch included)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri May 8 07:34:37 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=502115


           Summary: Xml schema validation: Inconsistent attribute
                    inheritance in mono <-> .net (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=290961)
 --> (http://bugzilla.novell.com/attachment.cgi?id=290961)
Suggested patch for this "bug"/inconsistency

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

There is a inconsistency in attribute inheritance between mono and .net.
Personally I think that the mono implementation in this case is by the
book and ms is not. However, existing code that (ab)uses ms buggy
implementation can not be ported to mono unless the same behaviour is
implemented. Consider this code:

-------------------------
   string xsd = @"
   <xs:schema id='foo'
    targetNamespace='foo'    
    xmlns='foo'                  
    xmlns:xs='http://www.w3.org/2001/XMLSchema'>

    <xs:element name='BaseElement' type='BaseType' />
                <xs:element name='ExtElement' type='ExtType' />

    <xs:complexType name='BaseType'>
     <xs:attribute name='id' type='xs:ID' use='optional' />
      <xs:attribute name='name' type='xs:string' use='optional' />
    </xs:complexType>

    <xs:complexType name='ExtType'>
     <xs:complexContent>
      <xs:extension base='BaseType'>
       <xs:attribute name='id' type='xs:ID' use='required' />                   
      </xs:extension>
     </xs:complexContent>
    </xs:complexType>
   </xs:schema>";

   XmlDocument doc = new XmlDocument ();

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

   doc.LoadXml (@"<BaseElement xmlns='foo'/>");
   doc.Schemas.Add (schema);
   doc.Validate (null); // Mono fails here "Named item id
                        // was already contained in the schema object table."

   try
   {
    doc.LoadXml(@"<ExtElement xmlns='foo'/>");
    doc.Schemas.Add (schema);
    doc.Validate (null);
    System.Console.Out.WriteLine("Behaviour incorrect");
   }
   catch (XmlSchemaException)
   {
    System.Console.Out.WriteLine("Behaviour correct"); 
   }

---------------
As stated, mono fails on the first Validate (null) because "id" is already
declared. .net however lets the attribute with usage required override the
one with usage optional.

The project that I'm porting to mono relies heavily on the (ab)usage of this
net feature.

Reproducible: Always

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

Expected Results:  
Successful validation and attribute override

Patch contains no unit test or no changelog. I have several changes locally for
several different bugs. I don't know how to produce separate patches for each
of them that wont give others problems with order of application etc... :-(

Please feel free to use the code submitted as basis for a unit test.

-- 
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