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 26 forks source link

When 2 validation errors happen, exception should contain both errors #24

Open simonech opened 7 years ago

simonech commented 7 years ago

I added two empty units (without segments) I get exception only for the first error it encounters, not for all the errors. For example

            XliffDocument xliff = new XliffDocument("en-GB");
            Localization.Xliff.OM.Core.File file = new Localization.Xliff.OM.Core.File("f1");
            xliff.Files.Add(file);

            Unit unit1 = new Unit("u1");
            Unit unit2 = new Unit("u2");

            file.Containers.Add(unit1);
            file.Containers.Add(unit2);

And I write it using the sample code

try
{
    using (IO.Stream stream = new IO.MemoryStream())
    {
        XliffWriter writer;

        writer = new XliffWriter();
        writer.Serialize(stream, document);
    }
}
catch (ValidationException e)
{
    Console.WriteLine("ValidationException Details:");
    Console.WriteLine(e.Message);
    if (e.Data != null)
    {
        foreach (object key in e.Data.Keys)
        {
            Console.WriteLine("  '{0}': '{1}'", key, e.Data[key]);
        }
    }
}

I get

ValidationException Details:
The element must contain one or more Resources.
  'SelectorPath': '#/f=f1/u=u1'

while I should also get '#/f=f1/u=u2'

VladimirRybalko commented 2 years 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.