Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs =================================================================== diff -u -ra59b471e3b6a02319f91b7317b3814a099ef0221 -r9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a59b471e3b6a02319f91b7317b3814a099ef0221) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -193,6 +193,15 @@ } /// + /// Looks up a localized string similar to Het XML-document dat de configuratie voor de berekeningen beschrijft is niet geldig.. + /// + public static string PipingCalculationGroupReader_Configuration_contains_no_valid_xml { + get { + return ResourceManager.GetString("PipingCalculationGroupReader_Configuration_contains_no_valid_xml", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database.. /// public static string PipingSoilProfileReader_Critical_Unexpected_value_on_column { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx =================================================================== diff -u -ra59b471e3b6a02319f91b7317b3814a099ef0221 -r9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision a59b471e3b6a02319f91b7317b3814a099ef0221) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -260,4 +260,7 @@ {0} Deze ondergrondschematisatie wordt overgeslagen. + + Het XML-document dat de configuratie voor de berekeningen beschrijft is niet geldig. + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationGroupReader.cs =================================================================== diff -u -r4ef4e426c0a77d547b58ec56581f292ddb3ed381 -r9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationGroupReader.cs (.../PipingCalculationGroupReader.cs) (revision 4ef4e426c0a77d547b58ec56581f292ddb3ed381) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingCalculationGroupReader.cs (.../PipingCalculationGroupReader.cs) (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -21,8 +21,10 @@ using System.Collections.Generic; using System.Linq; +using System.Xml.Linq; using System.Xml.Schema; using Core.Common.Utils.Reflection; +using Ringtoets.Piping.IO.Properties; namespace Ringtoets.Piping.IO.Readers { @@ -45,6 +47,7 @@ /// Reads a piping configuration from XML and creates a collection of corresponding . /// /// A collection of read . + /// Thrown when the schema validation failed. public IEnumerable Read() { return Enumerable.Empty(); @@ -60,5 +63,17 @@ return xmlSchema; } + + private void ValidateToSchema(XDocument document) + { + try + { + document.Validate(schema, null); + } + catch (XmlSchemaValidationException e) + { + throw new PipingConfigurationConversionException(Resources.PipingCalculationGroupReader_Configuration_contains_no_valid_xml, e); + } + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationConversionException.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationConversionException.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Readers/PipingConfigurationConversionException.cs (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -0,0 +1,57 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Runtime.Serialization; + +namespace Ringtoets.Piping.IO.Readers +{ + /// + /// Exception thrown when something went wrong while converting a piping configuration. + /// + [Serializable] + public class PipingConfigurationConversionException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public PipingConfigurationConversionException() {} + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The message that describes the error. + public PipingConfigurationConversionException(string message) + : base(message) {} + + /// + /// Initializes a new instance of the class with a specified error message + /// and a reference to the inner exception that is the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, or a + /// null reference if no inner exception is specified. + public PipingConfigurationConversionException(string message, Exception innerException) : base(message, innerException) {} + + protected PipingConfigurationConversionException(SerializationInfo info, StreamingContext context) : base(info, context) {} + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -r4ef4e426c0a77d547b58ec56581f292ddb3ed381 -r9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 4ef4e426c0a77d547b58ec56581f292ddb3ed381) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -61,6 +61,7 @@ + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingConfigurationConversionExceptionTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingConfigurationConversionExceptionTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Readers/PipingConfigurationConversionExceptionTest.cs (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -0,0 +1,32 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Piping.IO.Readers; + +namespace Ringtoets.Piping.IO.Test.Readers +{ + [TestFixture] + public class PipingConfigurationConversionExceptionTest : + CustomExceptionDesignGuidelinesTestFixture {} +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj =================================================================== diff -u -r0122d4ac58ee6f7be4ff804db1f6c65e88ce4562 -r9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 0122d4ac58ee6f7be4ff804db1f6c65e88ce4562) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Ringtoets.Piping.IO.Test.csproj (.../Ringtoets.Piping.IO.Test.csproj) (revision 9fd6d5a7d2289de6a5c6447fe8e0a9019cf75701) @@ -76,6 +76,7 @@ +