There are various easy ways to convert one XML file into another XML file, usually through an XSL transformation. Most languages support this with little code. For example, in C# it could be something like this (simplified):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// load the XSL transform var transform = new XslCompiledTransform(); var xmlReader = new XmlTextReader(streamFromXslFile); transform.Load(xmlReader); // load the input XML file var reader = new StringReader(inputXmlData); var doc = new XPathDocument(reader); // create a writer for the destination XML data var stringWriter = new StringWriter(); var writer = new XmlTextWriter(stringWriter); // perform the transformation transform.Transform(doc, null, writer); |
However, I decided to create a simple web service to achieve a few things. For one, to demonstrate that such repetitive code can be wrapped into a service and accessed from everywhere, for example as part of build scripts. Other reasons include that I wanted to play with ASP.NET 5, experimenting with more complex options than just request-response despite the simple use case and host the service on an Azure Web App.
The current version of the service can be found on github at https://github.com/thoean/xUnit2NUnit. It builds with AppVeyor and as part of the build, I start the web service in the background and run a very basic service level test against it (I’ve written a dedicated blog post on service level testing recently).