diff --git a/src/Core/WinSWCore/ServiceDescriptor.cs b/src/Core/WinSWCore/ServiceDescriptor.cs index b9eee89..fc06a9b 100755 --- a/src/Core/WinSWCore/ServiceDescriptor.cs +++ b/src/Core/WinSWCore/ServiceDescriptor.cs @@ -67,7 +67,8 @@ namespace winsw try { - ValidateAndLoadXmlSchema(GetXMLReader()); + string xmlstring = File.ReadAllText(BasePath + ".xml"); + dom = ServiceDescriptor.FromXML(xmlstring).dom; } catch (XmlException e) { @@ -101,41 +102,6 @@ namespace winsw this.dom = dom; } - public void ValidateAndLoadXmlSchema(XmlReader reader) - { - XmlReaderSettings settings = new XmlReaderSettings(); - - settings.ValidationType = ValidationType.Schema; - settings.ValidationEventHandler += new ValidationEventHandler(XmlValidationEventHandler); - - Assembly a = Assembly.GetExecutingAssembly(); - - using (Stream schemaStream = a.GetManifestResourceStream("winsw.XMLSchema.xsd")) - { - using (XmlReader schemaReader = XmlReader.Create(schemaStream)) - { - settings.Schemas.Add(null, schemaReader); - } - } - - var new_reader = XmlReader.Create(reader, settings); - - dom.Load(new_reader); - } - - private XmlReader GetXMLReader() - { - return XmlReader.Create(BasePath + ".xml"); - } - - private void XmlValidationEventHandler(object sender, ValidationEventArgs e) - { - if (e.Severity == XmlSeverityType.Error) - { - throw new XmlException("[Error] XML validation - " + e.Message); - } - } - // ReSharper disable once InconsistentNaming public static ServiceDescriptor FromXML(string xml) { diff --git a/src/Core/WinSWCore/XMLSchema.xsd b/src/Core/WinSWCore/XMLSchema.xsd index 0e079b0..c540f81 100644 --- a/src/Core/WinSWCore/XMLSchema.xsd +++ b/src/Core/WinSWCore/XMLSchema.xsd @@ -87,21 +87,21 @@ - + - + - - - - + + + + - + diff --git a/src/Test/winswTests/ServiceDescriptorTests.cs b/src/Test/winswTests/ServiceDescriptorTests.cs index a9274d3..d5b6ff2 100644 --- a/src/Test/winswTests/ServiceDescriptorTests.cs +++ b/src/Test/winswTests/ServiceDescriptorTests.cs @@ -446,22 +446,17 @@ $@" } [Test] - public void ValidateAndLoadXmlSchemaTest() + public void FromXMLTest() { const string seedXml = @" - myapp - appname - app description - jenkins - "; + myapp + MyApp Service (powered by WinSW) + This service is a service created from a minimal configuration + %BASE%\myExecutable.exe + +"; - XmlDocument dom = new XmlDocument(); - dom.LoadXml(seedXml); - - var serviceDescriptor = new ServiceDescriptor(dom); - - var reader = XmlReader.Create(new StringReader(seedXml)); - Assert.That(() => serviceDescriptor.ValidateAndLoadXmlSchema(reader), Throws.Exception.TypeOf()); + Assert.That(() => ServiceDescriptor.FromXML(seedXml), Throws.Exception.TypeOf()); } } }