From: Stefan B. <bo...@ap...> - 2009-05-14 10:18:21
|
On 2009-05-13, Филимонов Максим Сергеевич <tpa...@gm...> wrote: > Hi Stefan. > My comments below. > 13.05.2009, в 8:06, Stefan Bodewig написал(а): >> class ValidationError { >> readonly int line; // with a negative constant for UNKNOWN >> readonly int column; // ditto >> >> readonly String message; >> } >> .NET knows warnings in addition to errors, I'm not sure how we should >> handle them. >> class ValidationResult { >> readonly bool valid; >> readonly Iterable/IEnumerable<ValidationError> errors; > I think warning is important OK > what about use > IEnumerable<ValidationWarning> warnings > and > ValidationError : ValidationWarning > or > ValidationWarning : ValidationIncostistency , > ValidationError:ValidationIncostistency? Maybe an enum with Error and Warning and an attribute in ValidationError would do (together with renaming the class)? >> Since the Java code will be prettier if it uses different >> implementations for DTDs and W3C Schema I suggest to add a factory >> method >> class Validator { >> static Validator forLanguage(String); > What about pass enum not a string than user will know what validation > sets are supported and didn't try to pass something not supported. javax.xml.validation can be extended by additional libraries that add support for new schema languages, see <https://jaxp-sources.dev.java.net/nonav/docs/api/javax/xml/validation/SchemaFactory.html#newInstance(java.lang.String)> I've successfully used RelaxNG <http://stefan.samaflost.de/blog/en/oss/XMLUnit/relax_ng_validation_in_xmlunit.html> An enum would limit the choices to the schema langauges we know at the time of writing the enum, a string allows us to be forward compatible. Stefan |