[Mono-dev] XsdValidatingReader patch for multiple schema validation

Vorobiev Maksim MVorobiev at croc.ru
Fri Dec 23 07:19:12 EST 2005


 <<XsdValidatingReader.cs.diff>> Good day.

I've found an issue in implementation of XSD schema validation. This
feature works with MS.NET, but doesn't worked with Mono. I've fixed it
for my project. Can somebody check this patch and submit it to common
source base?

The problem is the next. schemaLocation attribute could handle multiple
schema references. They contained in this attribute as set of pairs
<URI>-<schema file>. But Mono validating only with last pair - the only
schema supported. While validating, XsdValidator reads these files and
collect it into the SchemasCollection. It was implemented in this way:

				tmp = schemaLocation.Split
(XmlChar.WhitespaceChars);
....
				for (int i = 0; i < tmp.Length; i += 2)
{
					try {
						schema =
ReadExternalSchema (tmp [i + 1]);
					} catch (Exception) { // FIXME:
(wishlist) It is bad manner ;-(
						if (!schemas.Contains
(tmp [i]))
							HandleError
(String.Format ("Could not resolve schema location URI: {0}",
								i + 1 <
tmp.Length ? tmp [i + 1] : String.Empty), null, true);
						continue;
					}
...
				}
			}
			if (schema != null) {
				if (!schemas.Contains
(schema.TargetNamespace)) {
					schemaAdded = true;
					schemas.Add (schema);
				}
			}

As it can be seen, every pair of URI and file reads, analized... And the
end. Only the last schema added to collection, because it's out of
for-cycle.
My patch fixes this issue and also moves try-block from cycle (marked as
"bad manner") to outer one - for correct error processing.

I've also attached test case. Binary and source for xmlvalue.exe utility
is simple example of call XmlValidationReader. Data for this example is
file testXSDvalidator.xml, that contains references to two schemas. This
test works with MS.NET, but fails for Mono 1.1.12. With my patch this
example works with Mono. I've tested it under Solaris 9 (SPARC).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xsd-validator.zip
Type: application/x-zip-compressed
Size: 5069 bytes
Desc: xsd-validator.zip
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20051223/0cf6c626/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XsdValidatingReader.cs.diff
Type: application/octet-stream
Size: 1248 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20051223/0cf6c626/attachment.obj 


More information about the Mono-devel-list mailing list