Setup Git Repository Parsing

This commit is contained in:
Simon Martens
2023-09-10 01:09:20 +02:00
parent 4e3c65dc6f
commit 8fd0050cf3
69 changed files with 1228 additions and 1461 deletions

View File

@@ -6,11 +6,14 @@ using HaWeb.XMLTests;
public class AppNode : INodeRule
{
public string Name => "app";
public string XPath => "//app";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "ueberlieferung" },
XPath = "//app"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
("ref", "//appDef", "index")
("ref", new HamannXPath() { Documents = new[] { "personenorte" }, XPath = "//appDef" }, "index")
};
}

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class AutopsicNode : INodeRule
{
public string Name => "autopsic";
public string XPath => "//autopsic";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "metadaten" },
XPath = "//autopsic"
};
public string[]? Attributes { get; } = { "value" };
public string? uniquenessAttribute => "value" ;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,11 +6,14 @@ using HaWeb.XMLTests;
public class EditNode : INodeRule
{
public string Name => "edit";
public string XPath => "//edit";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "brieftext", "texteingriffe", "ueberlieferung" },
XPath = "//edit"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
("ref", "//editreason", "index")
("ref", new HamannXPath() { Documents = new[] { "texteingriffe" }, XPath = "//editreason" }, "index")
};
}

View File

@@ -6,11 +6,14 @@ using HaWeb.XMLTests;
public class HandNode : INodeRule
{
public string Name => "hand";
public string XPath => "//hand";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "ueberlieferung", "brieftext", "texteingriffe" },
XPath = "//hand"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
("ref", "//handDef", "index")
("ref", new HamannXPath() { Documents = new[] { "personenorte" }, XPath = "//handDef" }, "index")
};
}

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class KommentarNode : INodeRule
{
public string Name => "kommentar";
public string XPath => "//kommentar";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "register" },
XPath = "//kommentar"
};
public string[]? Attributes { get; } = { "id" };
public string? uniquenessAttribute => "id" ;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class LetterDescNode : INodeRule
{
public string Name => "letterDesc";
public string XPath => "//letterDesc";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "metadaten" },
XPath = "//letterDesc"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => "ref" ;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class LetterTextNode : INodeRule
{
public string Name => "letterText";
public string XPath => "//letterText";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "brieftext" },
XPath = "//letterText"
};
public string[]? Attributes { get; } = { "index" };
public string? uniquenessAttribute => "index" ;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class LetterTraditionNode : INodeRule
{
public string Name => "letterTradition";
public string XPath => "//letterTradition";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "ueberlieferung" },
XPath = "//letterTradition"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => "ref" ;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,12 +6,15 @@ using HaWeb.XMLTests;
public class LinkNode : INodeRule
{
public string Name => "link";
public string XPath => "//link";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "ueberlieferung", "stellenkommentar", "register", "texteingriffe" },
XPath = "//link"
};
public string[]? Attributes { get; } = null;
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
("ref", "//kommentar", "id"),
("subref", "//subsection", "id")
("ref", new HamannXPath() { Documents = new[] { "register" }, XPath = "//kommentar" }, "id"),
("subref", new HamannXPath() { Documents = new[] { "register" }, XPath = "//subsection" }, "id"),
};
}

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class MarginalNode : INodeRule
{
public string Name => "marginal";
public string XPath => "//marginal";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "stellenkommentar" },
XPath = "//marginal"
};
public string[]? Attributes { get; } = { "index", "letter", "page", "line" };
public string? uniquenessAttribute => "index";
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,11 +6,14 @@ using HaWeb.XMLTests;
public class Receiver : INodeRule
{
public string Name => "receiver";
public string XPath => "//receiver";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "metadaten" },
XPath = "//receiver"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
("ref", "//personDef", "index")
("ref", new HamannXPath() { Documents = new[] { "personenorte" }, XPath = "//personDef" }, "index")
};
}

View File

@@ -6,11 +6,14 @@ using HaWeb.XMLTests;
public class SenderNode : INodeRule
{
public string Name => "sender";
public string XPath => "//sender";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "metadaten" },
XPath = "//sender"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
("ref", "//personDef", "index")
("ref", new HamannXPath() { Documents = new[] { "personenorte" }, XPath = "//personDef" }, "index")
};
}

View File

@@ -5,8 +5,15 @@ namespace HaWeb.Settings.NodeRules;
public class StructureCollection : ICollectionRule {
public string Name { get; } = "structure";
public string[] Bases { get; } = { "//letterText", "//letterTradition" };
public string[] Backlinks { get; } = { "//intlink", "//marginal" };
public HamannXPath[] Bases { get; } = {
new HamannXPath() { Documents = new[] { "brieftext" }, XPath = "//letterText" },
new HamannXPath() { Documents = new[] { "ueberlieferung" }, XPath = "//letterTradition"}
};
public HamannXPath[] Backlinks { get; } = {
new HamannXPath() { Documents = new[] { "stellenkommentar", "ueberlieferung", "texteingriffe", "register" }, XPath = "//intlink" },
new HamannXPath() { Documents = new[] { "stellenkommentar" }, XPath = "//marginal"}
};
public IEnumerable<(string, XElement, XMLRootDocument)> GenerateIdentificationStrings(IEnumerable<(XElement, XMLRootDocument)> list) {
foreach (var e in list) {
var id = e.Item1.Name == "letterText" ? e.Item1.Attribute("index")!.Value : e.Item1.Attribute("ref")!.Value;

View File

@@ -6,10 +6,13 @@ using HaWeb.XMLTests;
public class SubsectionNode : INodeRule
{
public string Name => "subsection";
public string XPath => "//subsection";
public HamannXPath XPath => new HamannXPath() {
Documents = new[] { "register" },
XPath = "//subsection"
};
public string[]? Attributes { get; } = { "id" };
public string? uniquenessAttribute => "id" ;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};
}

View File

@@ -6,7 +6,7 @@ using HaWeb.XMLParser;
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 string[] XPathContainer { get; } = { "/opus/data//kommentare/kommcat", "/opus//kommentare/kommcat" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "kommentar") return true;
@@ -39,7 +39,7 @@ public class CommentRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("kommentare") == null)
file.AddFirst(new XElement("kommentare"));
file.Element("kommentare")!.AddFirst(document.GetElement());
file.Element("kommentare")!.AddFirst(document.Element);
}
}

View File

@@ -6,7 +6,7 @@ using HaWeb.XMLParser;
public class DescriptionsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Metadaten";
public string Prefix { get; } = "metadaten";
public string[] XPathContainer { get; } = { ".//data/descriptions", ".//descriptions" };
public string[] XPathContainer { get; } = { "/opus/data/descriptions", "/opus/descriptions" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "letterDesc") return true;
@@ -34,7 +34,7 @@ public class DescriptionsRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("descriptions") == null)
file.AddFirst(new XElement("descriptions"));
var elements = document.GetElement().Elements().Where(x => IsCollectedObject(x));
var elements = document.Element.Elements().Where(x => IsCollectedObject(x));
var root = file.Element("descriptions");
foreach (var element in elements) {
root!.Add(element);

View File

@@ -7,7 +7,7 @@ using System.IO;
public class DocumentRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Brieftext";
public string Prefix { get; } = "brieftext";
public string[] XPathContainer { get; } = { ".//data/document", ".//document" };
public string[] XPathContainer { get; } = { "/opus/data/document", "/opus/document" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "letterText") return true;
@@ -35,7 +35,7 @@ public class DocumentRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("document") == null)
file.AddFirst(new XElement("document"));
var elements = document.GetElement().Elements().Where(x => IsCollectedObject(x));
var elements = document.Element.Elements().Where(x => IsCollectedObject(x));
var root = file.Element("document");
foreach (var element in elements) {
root!.Add(element);

View File

@@ -6,7 +6,7 @@ using HaWeb.XMLParser;
public class EditsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Texteingriffe";
public string Prefix { get; } = "texteingriffe";
public string[] XPathContainer { get; } = { ".//data/edits", ".//edits" };
public string[] XPathContainer { get; } = { "/opus/data/edits", "/opus/edits" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "editreason") return true;
@@ -34,7 +34,7 @@ public class EditsRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("edits") == null)
file.AddFirst(new XElement("edits"));
var elements = document.GetElement().Elements().Where(x => IsCollectedObject(x));
var elements = document.Element.Elements().Where(x => IsCollectedObject(x));
var root = file.Element("edits");
foreach (var element in elements) {
root!.Add(element);

View File

@@ -6,7 +6,7 @@ using HaWeb.XMLParser;
public class MarginalsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Stellenkommentar";
public string Prefix { get; } = "stellenkommentar";
public string[] XPathContainer { get; } = { ".//data/marginalien", ".//marginalien" };
public string[] XPathContainer { get; } = { "/opus/data/marginalien", "/opus/marginalien" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "marginal") return true;
@@ -34,7 +34,7 @@ public class MarginalsRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("marginalien") == null)
file.AddFirst(new XElement("marginalien"));
var elements = document.GetElement().Elements().Where(x => IsCollectedObject(x));
var elements = document.Element.Elements().Where(x => IsCollectedObject(x));
var root = file.Element("marginalien");
foreach (var element in elements) {
root!.Add(element);

View File

@@ -6,7 +6,7 @@ using HaWeb.XMLParser;
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 string[] XPathContainer { get; } = { "/opus/data/definitions", "/opus/definitions" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "personDefs" || elem.Name == "structureDefs" || elem.Name == "handDefs" || elem.Name == "locationDefs" || elem.Name == "appDefs")
@@ -35,7 +35,7 @@ public class ReferencesRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("definitions") == null)
file.AddFirst(new XElement("definitions"));
var elements = document.GetElement().Elements().Where(x => IsCollectedObject(x));
var elements = document.Element.Elements().Where(x => IsCollectedObject(x));
var root = file.Element("definitions");
foreach (var element in elements) {
root!.Add(element);

View File

@@ -6,7 +6,7 @@ using HaWeb.XMLParser;
public class TraditionsRoot : HaWeb.XMLParser.IXMLRoot {
public string Type { get; } = "Überlieferung";
public string Prefix { get; } = "ueberlieferung";
public string[] XPathContainer { get; } = { ".//data/traditions", ".//traditions" };
public string[] XPathContainer { get; } = { "/opus/data/traditions", "/opus/traditions" };
public Predicate<XElement> IsCollectedObject { get; } = (elem) => {
if (elem.Name == "letterTradition") return true;
@@ -34,7 +34,7 @@ public class TraditionsRoot : HaWeb.XMLParser.IXMLRoot {
public void MergeIntoFile(XElement file, XMLRootDocument document) {
if (file.Element("traditions") == null)
file.AddFirst(new XElement("traditions"));
var elements = document.GetElement().Elements().Where(x => IsCollectedObject(x));
var elements = document.Element.Elements().Where(x => IsCollectedObject(x));
var root = file.Element("traditions");
foreach (var element in elements) {
root!.Add(element);