From 0e0b1e2b0700ff01af08ed7f14b9620b89ae178f Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 24 Jun 2019 16:54:16 +0200 Subject: [PATCH] remove schem version - use common include files --- VectoCore/VectoCore/Utils/XMLDefinitions.cs | 22 ++++++--------------- VectoCore/VectoCore/Utils/XMLValidator.cs | 7 +++---- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs index 6ad119ac04..42903ce30c 100644 --- a/VectoCore/VectoCore/Utils/XMLDefinitions.cs +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -75,32 +75,22 @@ namespace TUGraz.VectoCore.Utils {XmlDocumentType.DeclarationComponentData, "VectoDeclarationComponent.xsd"}, {XmlDocumentType.EngineeringJobData, "VectoEngineeringJob.xsd" }, {XmlDocumentType.EngineeringComponentData, "VectoEngineeringComponent.xsd" }, - {XmlDocumentType.ManufacturerReport, "VectoOutputManufacturer{0}.xsd" }, - {XmlDocumentType.CustomerReport , "VectoOutputCustomer{0}.xsd"}, - {XmlDocumentType.MonitoringReport , "VectoMonitoring{0}.xsd"}, + {XmlDocumentType.ManufacturerReport, "VectoOutputManufacturer.xsd" }, + {XmlDocumentType.CustomerReport , "VectoOutputCustomer.xsd"}, + {XmlDocumentType.MonitoringReport , "VectoMonitoring.xsd"}, }; - public static string GetSchemaFilename(XmlDocumentType type, string xsdType) + public static string GetSchemaFilename(XmlDocumentType type) { if (!schemaFilenames.ContainsKey(type)) { throw new Exception(string.Format("Invalid argument {0} - only use single flags", type)); } var entry = schemaFilenames[type]; - var version = GetSchemaVersion(xsdType); - return string.Format(entry, string.IsNullOrWhiteSpace(version) ? "" : "." + version); + + return entry; } - - public static string GetSchemaVersion(string nodeType) - { - var parts = nodeType?.Split(':'); - if (parts?.Length == 2) { - return XMLHelper.GetVersionFromNamespaceUri(parts[0]); - } - - return null; - } } } diff --git a/VectoCore/VectoCore/Utils/XMLValidator.cs b/VectoCore/VectoCore/Utils/XMLValidator.cs index 6d0ece005a..e831ea2c33 100644 --- a/VectoCore/VectoCore/Utils/XMLValidator.cs +++ b/VectoCore/VectoCore/Utils/XMLValidator.cs @@ -101,16 +101,15 @@ namespace TUGraz.VectoCore.Utils } } - private static XmlSchemaSet GetXMLSchema(XmlDocumentType docType, string xsdType) + private static XmlSchemaSet GetXMLSchema(XmlDocumentType docType) { var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; - foreach (var entry in EnumHelper.GetValues<XmlDocumentType>()) { if ((entry & docType) == 0) { continue; } - var schemaFile = XMLDefinitions.GetSchemaFilename(entry, xsdType); + var schemaFile = XMLDefinitions.GetSchemaFilename(entry); if (schemaFile == null) { continue; } @@ -120,7 +119,7 @@ namespace TUGraz.VectoCore.Utils resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schemaFile); } catch (Exception e) { throw new Exception( - string.Format("Unknown XML schema! version: {0}, xml document type: {1} ({2})", entry, xsdType, schemaFile), e); + string.Format("Missing resource {0} for XML document type: {1} ({2})", schemaFile, entry, docType.ToString()), e); } var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); -- GitLab