1. Beta-Version mit Korrekturanmerkungen

This commit is contained in:
Simon Martens
2023-05-11 17:15:04 +02:00
parent 0ef63bfde4
commit fdaffb2f91
20 changed files with 240 additions and 46 deletions

View File

@@ -0,0 +1,16 @@
namespace HaWeb.Settings.NodeRules;
using System.Collections.Generic;
using HaWeb.XMLTests;
public class AppNode : INodeRule
{
public string Name => "app";
public string XPath => "//app";
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
{
("ref", "//appDef", "index")
};
}

View File

@@ -0,0 +1,17 @@
namespace HaWeb.Settings.NodeRules;
using System.Collections.Generic;
using HaWeb.XMLTests;
public class LinkNode : INodeRule
{
public string Name => "link";
public string XPath => "//link";
public string[]? Attributes { get; } = null;
public string? uniquenessAttribute => null;
public List<(string, string, string)>? References { get; } = new List<(string, string, string)>()
{
("ref", "//kommentar", "id"),
("subref", "//subsection", "id")
};
}

View 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);
}
}
}