[Mono-dev] XsdValidatingReader patch for multiple schema validation

Atsushi Eno atsushi at ximian.com
Mon Dec 26 09:19:10 EST 2005


Applied the patch with a few changes. Thanks for a good test!

It would be better if you try "make run-test" to check if your changes
are fine.
It runs our unit tests and tells you if there is breaking tests. With
this patch 
it resulted in an infinite loop ;-)

Atsushi Eno

>  <<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).
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list