[Mono-bugs] [Bug 356522] System.Xml.Linq.XNodeReader incorrect behavior 2

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jan 29 15:25:41 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=356522

User avk at rsdn.ru added comment
https://bugzilla.novell.com/show_bug.cgi?id=356522#c7


Andrew Koryavchenko <avk at rsdn.ru> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
             Status|RESOLVED                                        |REOPENED
         Resolution|FIXED                                           |




--- Comment #7 from Andrew Koryavchenko <avk at rsdn.ru>  2008-01-29 13:25:41 MST ---
But another bug added :(
New test (node not at root level):
using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace XNodeReaderBug
{
        class Program
        {
                static void Main(string[] args)
                {
                        var schema = XmlSchema.Read(
                                new StringReader(
                                        "<xs:schema id='xnodereadertest' "
                                        +
"targetNamespace='XNodeReaderTest.xsd' "
                                        + "elementFormDefault='qualified' "
                                        + "xmlns='XNodeReaderTest.xsd' "
                                        +
"xmlns:xs='http://www.w3.org/2001/XMLSchema'>"
                                        + " <xs:element name='root'
type='xs:string'/>"
                                        + "</xs:schema>"),
                                        (sender, e) => { });

                        var rdr = new StringReader(
                                "<container><root
xmlns='XNodeReaderTest.xsd'>Value</root><root2/></container>");
                        var xDoc = XDocument.Load(rdr);
                        var reader = xDoc.Root.FirstNode.CreateReader();

                        var settings = new XmlReaderSettings();
                        settings.ValidationType = ValidationType.Schema;
                        settings.Schemas.Add(schema);
                        reader = XmlReader.Create(reader, settings);

                        var xs = new XmlSerializer(typeof (TestClass));
                        Console.WriteLine("3");
                        var tc = (TestClass)xs.Deserialize(reader);

                        Console.WriteLine(tc.Value);
                }
        }

        [XmlRoot("root", Namespace = "XNodeReaderTest.xsd")]
        public class TestClass
        {
                [XmlText]
                public string Value {get; set; }
        }
}

Result:
Unhandled Exception: System.Xml.Schema.XmlSchemaValidationException: XmlSchema
error: Element declaration for root2 is missing.
  at System.Xml.XmlReaderSettings.OnValidationError (System.Object o,
System.Xml.Schema.ValidationEventArgs e) [0x00000] 
  at
Mono.Xml.Schema.XmlSchemaValidatingReader+<>c__CompilerGenerated0.<XmlSchemaValidatingReader>c__8
(System.Object o, System.Xml.Schema.ValidationEventArgs e) [0x00000] 
  at System.Xml.Schema.XmlSchemaValidator.HandleError
(System.Xml.Schema.XmlSchemaValidationException exception, Boolean isWarning)
[0x00000] 
  at System.Xml.Schema.XmlSchemaValidator.HandleError (System.String message,
System.Exception innerException, Boolean isWarning) [0x00000] 
  at System.Xml.Schema.XmlSchemaValidator.HandleError (System.String message)
[0x00000] 
  at System.Xml.Schema.XmlSchemaValidator.AssessCloseStartElementSchemaValidity
(System.Xml.Schema.XmlSchemaInfo info) [0x00000] 
  at System.Xml.Schema.XmlSchemaValidator.ValidateEndOfAttributes
(System.Xml.Schema.XmlSchemaInfo info) [0x00000] 
  at Mono.Xml.Schema.XmlSchemaValidatingReader.Read () [0x00000] 
  at System.Xml.XmlReader.ReadEndElement () [0x00000] 
  at System.Xml.Serialization.XmlSerializationReader.ReadEndElement ()
[0x00000] 
  at
System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadClassInstance
(System.Xml.Serialization.XmlTypeMapping typeMap, Boolean isNullable, Boolean
checkType) [0x00000] 
  at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadObject
(System.Xml.Serialization.XmlTypeMapping typeMap, Boolean isNullable, Boolean
checkType) [0x00000] 
  at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot
(System.Xml.Serialization.XmlTypeMapping rootMap) [0x00000] 
  at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot ()
[0x00000] 
  at System.Xml.Serialization.XmlSerializer.Deserialize
(System.Xml.Serialization.XmlSerializationReader reader) [0x00000] 


-- 
Configure bugmail: https://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