Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 0e0b1e2b authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

remove schem version - use common include files

parent 5204e3b4
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
}
......@@ -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://");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment