microsoft / XLIFF2-Object-Model

If you’re looking to store localization data and propagate it through your localization pipeline allowing tools to interoperate then you may want to use the XLIFF 2.0 object model. The XLIFF 2.0 object model implements the OASIS Standard for the XLIFF 2.0 specification as defined at http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html.
Other
86 stars 25 forks source link

Enhancement request: Have option to open the file even if is not valid and return validation errors #27

Open rabularca opened 6 years ago

rabularca commented 6 years ago

There are some cases in which we want to open a file even if it has validation errors (for instance if you don't really care about a specific error or want to programmatically fix it). The library should let the user to decide whether he wants to open a file with validation or without validation, and if he chooses the latter one, he should have a way to find out which validation errors the library has thrown.

A way to do this thing would be to create two separate methods: ValidateFile(string filePath), which would return a list of validation errors, and DeserializeWithoutValidating(string filePath), which would return the XLIFF file stream even if the file is not valid.

simonech commented 6 years ago

It is possible to exclude validation. Just empty the Validators property of the XliffReader and you would open the file anyway.

As for getting the errors, you can just create 2 instances of the XliffReader, one with validators, one without, and get the list of errors from the first.

rabularca commented 6 years ago

Thank you very much for the answer!

However, regarding the second part of your answer: is there a way to get the list of errors? As far as I've seen, the library just stops reading after throwing the first exception. Or am I missing something?

simonech commented 6 years ago

Yeah, indeed... it just stops at the first validation error... not applicable then 😞

VladimirRybalko commented 1 year ago

This feature is finally available in the forked repository: Xliff.OM.NetStandard. Welcome to use it. Don't hesitate to create an issue there in case of any questions.