Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - BUG: The minLength attribute in an XML Schema is not validated >Thread Next - Re: BUG: The minLength attribute in an XML Schema is not validated Re: BUG: The minLength attribute in an XML Schema is not validatedTo: 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/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
