Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: BUG: The minLength attribute in an XML Schema is not validated

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 10/11/2008 1:41:00 PM

TimB wrote:
> Does anyone know when the issue identified in the following knowledge base 
> article will be fixed with a service pack to the .Net Framework version 3.5?
> 
> http://support.microsoft.com/default.aspx/kb/826753
> 
> This issue prevents empty elements or attributes that have a minLength 
> greater than zero from being identified as validation errors when validating 
> an xml document using a schema.

That problem linked to above applies to

•	Microsoft XML Core Services 4.0
•	Microsoft XML Core Services 4.0 Service Pack 1
•	Microsoft XML Parser 3.0 Service Pack 3
•	Microsoft XML Parser 3.0 Service Pack 2
•	Microsoft XML Parser 3.0 Service Pack 1
•	Microsoft XML Parser 3.0
•	Microsoft XML Parser 2.6
•	Microsoft XML Parser 2.5
•	Microsoft XML Parser 2.0

and not to the .NET framework.

With the .NET framework and a W3C XML schema the problem does not exist:

             XmlReaderSettings xrs = new XmlReaderSettings();
             xrs.ValidationType = ValidationType.Schema;
             xrs.ValidationEventHandler += delegate(object sender, 
ValidationEventArgs vargs)
             {
                 Console.WriteLine("{0}: {1}", vargs.Severity, 
vargs.Message);
             };
             xrs.Schemas.Add(null, @"..\..\XMLSchema1.xsd");

             using (XmlReader rd = 
XmlReader.Create(@"..\..\XMLFile1.xml", xrs))
             {
                 while (rd.Read()) { }
             }

where the schema is as follows:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="root">
     <xs:complexType>
       <xs:sequence>
         <xs:element name="foo">
           <xs:simpleType>
             <xs:restriction base="xs:string">
               <xs:minLength value="2"/>
             </xs:restriction>
           </xs:simpleType>
         </xs:element>
         <xs:element name="bar">
           <xs:complexType>
             <xs:attribute name="baz" use="required">
               <xs:simpleType>
                 <xs:restriction base="xs:string">
                   <xs:minLength value="2"/>
                 </xs:restriction>
               </xs:simpleType>
             </xs:attribute>
           </xs:complexType>
         </xs:element>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
</xs:schema>

and the instance is as follows:
<?xml version="1.0" encoding="utf-8" ?>
<root>
   <foo></foo>
   <bar baz=""/>
</root>


outputs the following two validation errors with Visual Studio 2005:

Error: The 'foo' element is invalid - The value '' is invalid according 
to its datatype 'String' - The actual length is less than the MinLength 
value.
Error: The 'baz' attribute is invalid - The value '' is invalid 
according to its datatype 'String' - The actual length is less than the 
MinLength value.


Or are you still using an XDR schema?

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent