mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Started programming transforms
This commit is contained in:
3
Transformation-2023-9-15/.vscode/settings.json
vendored
Normal file
3
Transformation-2023-9-15/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"dotnet.defaultSolution": "Transformation-2023-9-15.sln"
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
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 XML_PATH = "D:/Simon/source/hamann-xml/base/";
|
||||
const string DEST_PATH = "D:/Simon/source/hamann-xml/transformations_2023-9-14_test/";
|
||||
const string GIT_PATH = "../../hamann-xml/";
|
||||
const string BRANCH_NAME = "testdata";
|
||||
|
||||
@@ -20,21 +21,86 @@ if (xmls == null || !xmls.Any()) {
|
||||
throw new("No XML Data fonund!");
|
||||
}
|
||||
|
||||
// Checks are done, we begin here
|
||||
// State
|
||||
List<(string, XDocument)> Documents = new();
|
||||
Dictionary<string, string> OldNewIndex = new();
|
||||
Dictionary<string, List<XElement>> Intlinks = new();
|
||||
Dictionary<string, List<XElement>> Marginals = new();
|
||||
Dictionary<string, List<XElement>> LetterTexts = new();
|
||||
Dictionary<string, List<XElement>> LetterTraditions = new();
|
||||
Dictionary<string, List<XElement>> LetterDescs = new();
|
||||
|
||||
foreach (var f in xmls) {
|
||||
Documents.Add((f, XDocument.Load(f, LoadOptions.PreserveWhitespace)));
|
||||
Console.WriteLine("" + f);
|
||||
var d = XDocument.Load(f, LoadOptions.PreserveWhitespace);
|
||||
Documents.Add((f, d));
|
||||
|
||||
var intlinks = d.Descendants("intlink");
|
||||
if (intlinks != null && intlinks.Any()) {
|
||||
foreach (var e in intlinks) {
|
||||
if (e.HasAttributes && e.Attribute("letter") != null) {
|
||||
if (!Intlinks.ContainsKey(e.Attribute("letter").Value)) Intlinks.Add(e.Attribute("letter").Value, new());
|
||||
Intlinks[e.Attribute("letter").Value].Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var marginals = d.Descendants("marginal");
|
||||
if (marginals != null && marginals.Any()) {
|
||||
foreach (var e in marginals) {
|
||||
if (e.HasAttributes && e.Attribute("letter") != null) {
|
||||
if (!Marginals.ContainsKey(e.Attribute("letter").Value)) Marginals.Add(e.Attribute("letter").Value, new());
|
||||
Marginals[e.Attribute("letter").Value].Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var lettertexts = d.Descendants("letterText");
|
||||
if (lettertexts != null && lettertexts.Any()) {
|
||||
foreach (var e in lettertexts) {
|
||||
if (e.HasAttributes && e.Attribute("index") != null) {
|
||||
if (!LetterTexts.ContainsKey(e.Attribute("index").Value)) LetterTexts.Add(e.Attribute("index").Value, new());
|
||||
LetterTexts[e.Attribute("index").Value].Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var lettertraditions = d.Descendants("letterTradition");
|
||||
if (lettertraditions != null && lettertraditions.Any()) {
|
||||
foreach (var e in lettertraditions) {
|
||||
if (e.HasAttributes && e.Attribute("ref") != null) {
|
||||
if (!LetterTraditions.ContainsKey(e.Attribute("ref").Value)) LetterTraditions.Add(e.Attribute("ref").Value, new());
|
||||
LetterTraditions[e.Attribute("ref").Value].Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var letterdescs = d.Descendants("letterDesc");
|
||||
if (letterdescs != null && letterdescs.Any()) {
|
||||
foreach (var e in letterdescs) {
|
||||
if (e.HasAttributes && e.Attribute("ref") != null) {
|
||||
if (!LetterDescs.ContainsKey(e.Attribute("ref").Value)) LetterDescs.Add(e.Attribute("ref").Value, new());
|
||||
LetterDescs[e.Attribute("ref").Value].Add(e);
|
||||
|
||||
if (e.Element("autopsic") != null && e.Element("autopsic").HasAttributes && e.Element("autopsic").Attribute("value") != null)
|
||||
OldNewIndex.Add(e.Attribute("ref").Value, e.Element("autopsic").Attribute("value").Value);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SaveHamannFile(XElement element, string basefilepath, string oldfile) {
|
||||
var filename = "hamann_" + ".xml";
|
||||
|
||||
void SaveFile(XDocument element, string basefilepath, string oldfile) {
|
||||
var filenameold = oldfile.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).LastOrDefault();
|
||||
if (filenameold == null) return;
|
||||
var filename = oldfile + "_transform_" + ".xml";
|
||||
var path = Path.Combine(basefilepath, filename);
|
||||
|
||||
if (!Directory.Exists(basefilepath))
|
||||
Directory.CreateDirectory(basefilepath);
|
||||
using (var targetStream = System.IO.File.Create(path))
|
||||
using (var targetStream = System.IO.File.Create(path)) {
|
||||
element.Save(targetStream, SaveOptions.DisableFormatting);
|
||||
|
||||
}
|
||||
}
|
||||
25
Transformation-2023-9-15/Transformation-2023-9-15.sln
Normal file
25
Transformation-2023-9-15/Transformation-2023-9-15.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transformation-2023-9-15", "Transformation-2023-9-15.csproj", "{7149D531-B686-413A-AFC8-12DCE97C7119}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7149D531-B686-413A-AFC8-12DCE97C7119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7149D531-B686-413A-AFC8-12DCE97C7119}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7149D531-B686-413A-AFC8-12DCE97C7119}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7149D531-B686-413A-AFC8-12DCE97C7119}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DCF91CEF-437A-4F52-BA90-CF5EE71C1B96}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in New Issue
Block a user