[Mono-dev] Mono & .Net difference - handling xs:extension please help

MarLOne InfoSeeker002 at gmail.com
Wed Nov 12 07:15:10 UTC 2014


Not sure if this issue has been raised as it is driving me nuts as another
Mono/.Net runtime behavior differences.

I have a xml schema called FamilyTree2.xsd  FamilyTree2.xsd
<http://mono.1490590.n4.nabble.com/file/n4664552/FamilyTree2.xsd>  . This
has been validate in Eclipse's Xsd Editor.

Then I have an instance document created using this schema and is called
FamilyTree2SimplePerson.xml  FamilyTree2SimplePerson.xml

I then use xsd.exe in Mono runtime to generate a C# class from the
schema. I then use the following code to deserialize the instance document
into an person object:
        public void TestSimplePerson ()
            const String testFile = "FamilyTree2SimplePerson.xml";
            String fileName = Path.Combine( Constants.DataFilesDirectory,
testFile );
            Assert.IsTrue( File.Exists( fileName ) );
            LMar.Demo.person p = null;
            using( Stream input = File.OpenRead( fileName ) )
                XmlReaderSettings rs = new XmlReaderSettings();
                rs.Schemas = new XmlSchemaSet();
                rs.Schemas.Add( SchemaLoaders.FamilyTree2 );
                rs.ValidationType = ValidationType.Schema;
                using( XmlReader reader = XmlReader.Create( input, rs ) )
                    XmlSerializer ser = new XmlSerializer( typeof(
LMar.Demo.person ) );
                    p = ser.Deserialize( reader ) as LMar.Demo.person;  //
                    Assert.IsNotNull( p );

The schema is embedded into the assembly as embedded resource,

The exception message is as follows:
System.Xml.Schema.XmlSchemaValiationException: XmlSchema error: Attribute
declaration was not found for name XML Line 6, Position 12.

person is the base class of spouse which uses the xs:extension to define it
in the schema. This error message points to the name for the spouse object. 

I believe this is a Mono & MS .Net incompatibility runtime error for the
following reasons:
1) The instance document has been validated by Eclipse xsd/xml editor as
well as online validator. In fact the instance document was created by
Eclipse xml editor.
2) The same code ( the xsd generated code produced in .Net and Mono appear
to be the same) shown above runs without error in MS .Net and retrieving all
the values.

Has anyone discovered this error? It is a simple usage of xs:extension, a
very commonly used construct and should not cause any incompatibility. 

It is so disheartening to see superficial compatibility while beneath the
surface so much differences. Is there a site that lists this kind of runtime
incompatibility for people wanting to use Mono as serious tool? Every time I
push Mono, I end up in a hole like this as I have encountered time and time
again incompatibilities.

Is there some quirky flags in the XmlReaderSettings to get this going in



View this message in context: http://mono.1490590.n4.nabble.com/Mono-Net-difference-handling-xs-extension-please-help-tp4664552.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list