mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Intoduced project
This commit is contained in:
40
Transformation-2023-9-15/Program.cs
Normal file
40
Transformation-2023-9-15/Program.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
const string XML_PATH = "D:/Simon/source/hamann-xml/transformations_2023-9-14_test/";
|
||||
const string GIT_PATH = "../../hamann-xml/";
|
||||
const string BRANCH_NAME = "testdata";
|
||||
|
||||
if (File.Exists(GIT_PATH + ".git/HEAD") || !Directory.Exists(XML_PATH)) {
|
||||
var text = File.ReadAllText(GIT_PATH + ".git/HEAD").Trim();
|
||||
if (!text.EndsWith(BRANCH_NAME)) {
|
||||
throw new("Not it the Branch " + BRANCH_NAME);
|
||||
}
|
||||
} else {
|
||||
throw new("Specified Paths do not exist");
|
||||
}
|
||||
|
||||
var xmls = Directory.GetFiles(XML_PATH, "*.xml");
|
||||
|
||||
if (xmls == null || !xmls.Any()) {
|
||||
throw new("No XML Data fonund!");
|
||||
}
|
||||
|
||||
List<(string, XDocument)> Documents = new();
|
||||
|
||||
foreach (var f in xmls) {
|
||||
Documents.Add((f, XDocument.Load(f, LoadOptions.PreserveWhitespace)));
|
||||
Console.WriteLine("" + f);
|
||||
}
|
||||
|
||||
|
||||
void SaveHamannFile(XElement element, string basefilepath, string oldfile) {
|
||||
var filename = "hamann_" + ".xml";
|
||||
var path = Path.Combine(basefilepath, filename);
|
||||
|
||||
if (!Directory.Exists(basefilepath))
|
||||
Directory.CreateDirectory(basefilepath);
|
||||
using (var targetStream = System.IO.File.Create(path))
|
||||
element.Save(targetStream, SaveOptions.DisableFormatting);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user