[Mono-bugs] [Bug 82578][Nor] New - XmlValidatingReader fails to correctly validate an element whose data type is the xml schema union of two enumerations.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Aug 24 14:21:55 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 jim.matysczak at metier.com.
http://bugzilla.ximian.com/show_bug.cgi?id=82578
--- shadow/82578 2007-08-24 14:21:55.000000000 -0400
+++ shadow/82578.tmp.20901 2007-08-24 14:21:55.000000000 -0400
@@ -0,0 +1,167 @@
+Bug#: 82578
+Product: Mono: Class Libraries
+Version: 1.2
+OS: GNU/Linux [Other]
+OS Details: Fedora Core 5 and 6
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Sys.XML
+AssignedTo: atsushi at ximian.com
+ReportedBy: jim.matysczak at metier.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: XmlValidatingReader fails to correctly validate an element whose data type is the xml schema union of two enumerations.
+
+Description of Problem:
+XmlValidatingReader fails to correctly validate an element whose data type
+is the xml schema union of two enumerations.
+
+I have an xml schema simple type (type1) that is the union of two other
+simple types (type2 and type3). type2 and type3 are both enumerations. I am
+using type1 as the type for elements in my xsd. When I validate my xml
+document using my xsd, it appears that only the first enumeration specified
+in the union in type1 is being used and the second enumeration defined in
+the union is being ignored.
+
+
+Steps to reproduce the problem:
+1. Compile XMLValidationTestMain.cs to XMLValidationTest.exe
+2. Run: mono XMLValidationTest.exe inputxml.xml inputxsd.xml
+
+Actual Results:
+Run on FC 6 with mono 1.2.2:
+
+-->XmlSchema error: Specified value was invalid against the facets. XML
+URI: file:///.../inputxml.xml . Line 4, Position 47.
+ vr.BaseURI: file:///.../inputxml.xml
+ vr.LocalName: myfield2
+ vr.NamespaceURI:
+-->XmlSchema error: Specified value was invalid against the facets. XML
+URI: file:///.../inputxml.xml . Line 5, Position 42.
+ vr.BaseURI: file:///.../inputxml.xml
+ vr.LocalName: myfield3
+ vr.NamespaceURI:
+-->XmlSchema error: Specified value was invalid against the facets. XML
+URI: file:///.../inputxml.xml . Line 6, Position 46.
+ vr.BaseURI: file:///.../inputxml.xml
+ vr.LocalName: myfield4
+ vr.NamespaceURI:
+
+Expected Results:
+Run on MS Windows XP Pro SP 2 with .NET v1.1.4322:
+
+-->The 'myfield3' element has an invalid value according to its data type.
+An error occurred at file:///.../inputxml.xml, (5, 42).
+ vr.BaseURI: file:///.../inputxml.xml
+ vr.LocalName: myfield3
+ vr.NamespaceURI:
+
+
+How often does this happen?
+Always.
+
+Additional Information:
+XMLValidationTestMain.cs
+------------------------
+using System;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace XMLValidationTest
+{
+ class XMLValidationTestMain
+ {
+ static XmlValidatingReader vr = null;
+ [STAThread]
+ static void Main(string[] args)
+ {
+ XmlSchemaCollection sc = new XmlSchemaCollection();
+ XmlTextReader tr = new XmlTextReader(args[0]);
+ XmlTextReader tr2 = new XmlTextReader(args[1]);
+ vr = new XmlValidatingReader(tr);
+
+ try
+ {
+ sc.Add(null, tr2);
+
+ vr.ValidationType = ValidationType.Schema;
+ vr.Schemas.Add(sc);
+ vr.ValidationEventHandler += new
+ValidationEventHandler(ValidationCallBack);
+
+ while (vr.Read())
+ {
+ }
+ }
+ catch (Exception ee)
+ {
+ Console.WriteLine(ee.Message);
+ Console.WriteLine(ee.StackTrace);
+ Console.WriteLine(ee.Source);
+ }
+ }
+
+ static void ValidationCallBack(Object sender, ValidationEventArgs e)
+ {
+ Console.WriteLine("-->" + e.Message);
+ if (vr != null)
+ {
+ Console.WriteLine(" vr.BaseURI: " + vr.BaseURI);
+ Console.WriteLine(" vr.LocalName: " + vr.LocalName);
+ Console.WriteLine(" vr.NamespaceURI: " + vr.NamespaceURI);
+ }
+ }
+ }
+}
+
+
+inputxml.xml
+------------
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<mydocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:noNamespaceSchemaLocation="inputxsd.xml">
+ <myfield1>this is in the first enumeration</myfield1>
+ <myfield2>this is in the second enumeration</myfield2>
+ <myfield3>this isn't in an enumeration</myfield3>
+ <myfield4>this is in the first enumeration</myfield4>
+ <myfield5>this is in the second enumeration</myfield5>
+</mydocument>
+
+
+inputxsd.xml
+------------
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="mydocument">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="myfield1" type="myunionedenumeration"/>
+ <xs:element name="myfield2" type="myunionedenumeration"/>
+ <xs:element name="myfield3" type="myunionedenumeration"/>
+ <xs:element name="myfield4" type="myunionedenumerationbackwards"/>
+ <xs:element name="myfield5" type="myunionedenumerationbackwards"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:simpleType name="myunionedenumeration">
+ <xs:union memberTypes="myenumeration1 myenumeration2"/>
+ </xs:simpleType>
+ <xs:simpleType name="myunionedenumerationbackwards">
+ <xs:union memberTypes="myenumeration2 myenumeration1"/>
+ </xs:simpleType>
+ <xs:simpleType name="myenumeration1">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="this is in the first enumeration"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType name="myenumeration2">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="this is in the second enumeration"/>
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
More information about the mono-bugs
mailing list