Bugfix: doppelte Marginalien

This commit is contained in:
Simon Martens
2023-10-26 13:04:49 +02:00
parent d85611182f
commit bc9521d53e
5 changed files with 54 additions and 3 deletions

View File

@@ -0,0 +1,42 @@
using HaWeb.Models;
using System.Xml.Linq;
using HaWeb.XMLTests;
namespace HaWeb.Settings.NodeRules;
public class MarginalCollectionRules : ICollectionRule {
public string Name { get; } = "marginal";
public HamannXPath[] Bases { get; } = {
new HamannXPath() { Documents = new[] { "stellenkommentar" }, XPath = "//marginal"}
};
public HamannXPath[] Backlinks { get; } = {};
public IEnumerable<(string, XElement, XMLRootDocument)> GenerateIdentificationStrings(IEnumerable<(XElement, XMLRootDocument)> list) {
foreach (var e in list) {
var id = e.Item1.Attribute("letter")!.Value;
id += "-";
id += e.Item1.Attribute("page")!.Value;
id += "-";
id += e.Item1.Attribute("line")!.Value;
if (e.Item1.HasAttributes && e.Item1.Attribute("sort") != null) {
id += "-";
id += e.Item1.Attribute("sort")!.Value;
}
yield return (
id,
e.Item1,
e.Item2
);
}
}
public IEnumerable<(string, XElement, XMLRootDocument, bool)> GenerateBacklinkString(IEnumerable<(XElement, XMLRootDocument)> list) => null;
public bool CheckDatatypes(XElement element) {
if (element.HasAttributes && element.Attribute("sort") != null ) {
return Int32.TryParse(element.Attribute("sort").Value, out var _);
} else {
return true;
}
}
}