mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
1. Beta-Version mit Korrekturanmerkungen
This commit is contained in:
40
HaWeb/Settings/NodeRules/StructureCollection.cs
Normal file
40
HaWeb/Settings/NodeRules/StructureCollection.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using HaWeb.Models;
|
||||
using System.Xml.Linq;
|
||||
using HaWeb.XMLTests;
|
||||
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 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;
|
||||
var currpage = String.Empty;
|
||||
var currline = String.Empty;
|
||||
foreach (var el in e.Item1.Descendants()) {
|
||||
if (el.Name == "page" && el.Attribute("index") != null) currpage = el.Attribute("index")!.Value;
|
||||
if (el.Name == "line" && el.Attribute("index") != null) {
|
||||
currline = el.Attribute("index")!.Value;
|
||||
yield return (
|
||||
id + "-" + currpage + "-" + currline,
|
||||
e.Item1,
|
||||
e.Item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<(string, XElement, XMLRootDocument, bool)> GenerateBacklinkString(IEnumerable<(XElement, XMLRootDocument)> list) {
|
||||
foreach (var e in list) {
|
||||
var letter = e.Item1.Attribute("letter") != null ? e.Item1.Attribute("letter")!.Value : "NA";
|
||||
var page = e.Item1.Attribute("page") != null ? e.Item1.Attribute("page")!.Value : "NA";
|
||||
var line = e.Item1.Attribute("line") != null ? e.Item1.Attribute("line")!.Value : "NA";
|
||||
var partialmatch = e.Item1.Name == "marginal" ? false : true;
|
||||
yield return (
|
||||
letter + "-" + page + "-" + line,
|
||||
e.Item1,
|
||||
e.Item2,
|
||||
partialmatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user