mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 09:45:32 +00:00
Created FileList with ability to set used files
This commit is contained in:
50
HaDocumentNew/Settings/XMLRoots/CommentRoot.cs
Normal file
50
HaDocumentNew/Settings/XMLRoots/CommentRoot.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class CommentRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Register";
|
||||
public string Prefix { get; } = "register";
|
||||
public string[] XPathContainer { get; } = { ".//data//kommentare/kommcat", ".//kommentare/kommcat" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "kommentar") return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
var index = elem.Attribute("id");
|
||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||
return index.Value;
|
||||
else return null;
|
||||
};
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
var kat = element.Attribute("value");
|
||||
if (kat != null && !String.IsNullOrWhiteSpace(kat.Value))
|
||||
return (null, kat.Value);
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
var kommentare = new XElement("kommentare");
|
||||
kommentare.AddFirst(element);
|
||||
opus.AddFirst(kommentare);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("kommentare") == null)
|
||||
file.AddFirst(new XElement("kommentare"));
|
||||
file.Element("kommentare")!.AddFirst(document.Root);
|
||||
}
|
||||
|
||||
}
|
||||
49
HaDocumentNew/Settings/XMLRoots/DescriptionsRoot.cs
Normal file
49
HaDocumentNew/Settings/XMLRoots/DescriptionsRoot.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class DescriptionsRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Metadaten";
|
||||
public string Prefix { get; } = "metadaten";
|
||||
public string[] XPathContainer { get; } = { ".//data/descriptions", ".//descriptions" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "letterDesc") return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
// public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
// var index = elem.Attribute("ref");
|
||||
// if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||
// return index.Value;
|
||||
// else return null;
|
||||
// };
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
opus.AddFirst(element);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("descriptions") == null)
|
||||
file.AddFirst(new XElement("descriptions"));
|
||||
var elements = document.Root.Elements().Where(x => IsCollectedObject(x));
|
||||
var root = file.Element("descriptions");
|
||||
foreach (var element in elements) {
|
||||
root!.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
50
HaDocumentNew/Settings/XMLRoots/DocumentRoot.cs
Normal file
50
HaDocumentNew/Settings/XMLRoots/DocumentRoot.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
public class DocumentRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Brieftext";
|
||||
public string Prefix { get; } = "brieftext";
|
||||
public string[] XPathContainer { get; } = { ".//data/document", ".//document" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "letterText") return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
var index = elem.Attribute("index");
|
||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||
return index.Value;
|
||||
else return null;
|
||||
};
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
opus.AddFirst(element);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("document") == null)
|
||||
file.AddFirst(new XElement("document"));
|
||||
var elements = document.Root.Elements().Where(x => IsCollectedObject(x));
|
||||
var root = file.Element("document");
|
||||
foreach (var element in elements) {
|
||||
root!.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
50
HaDocumentNew/Settings/XMLRoots/EditsRoot.cs
Normal file
50
HaDocumentNew/Settings/XMLRoots/EditsRoot.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
public class EditsRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Texteingriffe";
|
||||
public string Prefix { get; } = "texteingriffe";
|
||||
public string[] XPathContainer { get; } = { ".//data/edits", ".//edits" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "editreason") return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
var index = elem.Attribute("index");
|
||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||
return index.Value;
|
||||
else return null;
|
||||
};
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
opus.AddFirst(element);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("edits") == null)
|
||||
file.AddFirst(new XElement("edits"));
|
||||
var elements = document.Root.Elements().Where(x => IsCollectedObject(x));
|
||||
var root = file.Element("edits");
|
||||
foreach (var element in elements) {
|
||||
root!.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
49
HaDocumentNew/Settings/XMLRoots/MarginalsRoot.cs
Normal file
49
HaDocumentNew/Settings/XMLRoots/MarginalsRoot.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MarginalsRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Stellenkommentar";
|
||||
public string Prefix { get; } = "stellenkommentar";
|
||||
public string[] XPathContainer { get; } = { ".//data/marginalien", ".//marginalien" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "marginal") return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
var index = elem.Attribute("index");
|
||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||
return index.Value;
|
||||
else return null;
|
||||
};
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
opus.AddFirst(element);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("marginalien") == null)
|
||||
file.AddFirst(new XElement("marginalien"));
|
||||
var elements = document.Root.Elements().Where(x => IsCollectedObject(x));
|
||||
var root = file.Element("marginalien");
|
||||
foreach (var element in elements) {
|
||||
root!.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
48
HaDocumentNew/Settings/XMLRoots/ReferencesRoot.cs
Normal file
48
HaDocumentNew/Settings/XMLRoots/ReferencesRoot.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
public class ReferencesRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Personen / Orte";
|
||||
public string Prefix { get; } = "personenorte";
|
||||
public string[] XPathContainer { get; } = { ".//data/definitions", ".//definitions" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "personDefs" || elem.Name == "structureDefs" || elem.Name == "handDefs" || elem.Name == "locationDefs")
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
return elem.Name.ToString();
|
||||
};
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
opus.AddFirst(element);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("definitions") == null)
|
||||
file.AddFirst(new XElement("definitions"));
|
||||
var elements = document.Root.Elements().Where(x => IsCollectedObject(x));
|
||||
var root = file.Element("definitions");
|
||||
foreach (var element in elements) {
|
||||
root!.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
49
HaDocumentNew/Settings/XMLRoots/TraditionsRoot.cs
Normal file
49
HaDocumentNew/Settings/XMLRoots/TraditionsRoot.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace HaDocument.Settings.XMLRoots;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
public class TraditionsRoot : HaWeb.XMLParser.IXMLRoot {
|
||||
public string Type { get; } = "Überlieferung";
|
||||
public string Prefix { get; } = "ueberlieferung";
|
||||
public string[] XPathContainer { get; } = { ".//data/traditions", ".//traditions" };
|
||||
|
||||
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
|
||||
if (elem.Name == "letterTradition") return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
public Func<XElement, string?> GetKey { get; } = (elem) => {
|
||||
var index = elem.Attribute("ref");
|
||||
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
|
||||
return index.Value;
|
||||
else return null;
|
||||
};
|
||||
|
||||
public List<(string, string?)>? GenerateFields(XMLRootDocument document) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public (string?, string?) GenerateIdentificationString(XElement element) {
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
public bool Replaces(XMLRootDocument doc1, XMLRootDocument doc2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public XElement CreateHamannDocument(XElement element) {
|
||||
var opus = new XElement("opus");
|
||||
opus.AddFirst(element);
|
||||
return opus;
|
||||
}
|
||||
|
||||
public void MergeIntoFile(XElement file, XMLRootDocument document) {
|
||||
if (file.Element("traditions") == null)
|
||||
file.AddFirst(new XElement("traditions"));
|
||||
var elements = document.Root.Elements().Where(x => IsCollectedObject(x));
|
||||
var root = file.Element("traditions");
|
||||
foreach (var element in elements) {
|
||||
root!.Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user