[Mono-bugs] [Bug 82063][Nor] New - Default attributes in schemas are broken

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jul 10 20:50:25 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jesjones at mindspring.com.

http://bugzilla.ximian.com/show_bug.cgi?id=82063

--- shadow/82063	2007-07-10 20:50:25.000000000 -0400
+++ shadow/82063.tmp.24249	2007-07-10 20:50:25.000000000 -0400
@@ -0,0 +1,107 @@
+Bug#: 82063
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com                            
+ReportedBy: jesjones at mindspring.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Default attributes in schemas are broken
+
+Description of Problem:
+When using default attributes in an xml schema
+XmlSchemaValidatingReader.get_Prefix throws a NullReferenceException.
+
+Steps to reproduce the problem:
+Run the program below.
+
+Actual Results:
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+  at Mono.Xml.Schema.XmlSchemaValidatingReader.get_Prefix () [0x00000] 
+  at System.Xml.XmlDocument.ReadAttributeNode (System.Xml.XmlReader reader)
+[0x00000] 
+  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader)
+[0x00000] 
+  at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000] 
+  at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00000] 
+  at Program.DoLoad () [0x00000] 
+  at Program.Main (System.String[] args) [0x00000] 
+
+
+Expected Results:
+name: Bob
+address: -
+
+How often does this happen? 
+Always.
+
+Additional Information:
+-- Main.cs ------------------------------
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+
+public class Program
+{
+    public static void Main(string[] args)
+    {
+        XmlDocument xml = DoLoad();
+        DoProcess(xml.FirstChild);
+    }
+    
+    public static XmlDocument DoLoad()
+    {
+        Stream stream = File.OpenRead("Schema.xml");
+        XmlSchema schema = XmlSchema.Read(stream, Program.DoValidationEvent);
+    
+        XmlReaderSettings settings = new XmlReaderSettings();
+        settings.Schemas.Add(schema);
+        settings.ValidationEventHandler += Program.DoValidationEvent;
+        settings.ValidationType = ValidationType.Schema;
+
+        stream = File.OpenRead("Test2.xml");
+        XmlReader reader = XmlReader.Create(stream, settings);
+
+        XmlDocument xml = new XmlDocument();
+        xml.Load(reader);
+        
+        return xml;
+    }
+    
+    public static void DoProcess(XmlNode element)
+    {
+        Console.WriteLine("name: {0}", element.Attributes["name"].Value);
+        Console.WriteLine("address: {0}", element.Attributes["address"].Value);
+    }
+        
+    private static void DoValidationEvent(object sender, ValidationEventArgs e)
+    {
+        Console.WriteLine("{0}", e.Message);
+    }
+} 
+
+-- Schema.xml ---------------------------
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <xsd:element name="Customer" type="CustomerType"/>
+        
+    <xsd:complexType name="CustomerType">
+        <xsd:attribute name="name" type="xsd:string"/>
+        <xsd:attribute name="address" type="xsd:string" default="-"/>   
+<!-- the default attribute causes XmlSchemaValidatingReader.get_Prefix to
+throw -->
+    </xsd:complexType>
+</xsd:schema> 
+
+-- Test2.xml ----------------------------
+<Customer name = "Bob">
+</Customer>


More information about the mono-bugs mailing list