mirror of
				https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
				synced 2025-10-30 17:55:32 +00:00 
			
		
		
		
	Created FileList with ability to set used files
This commit is contained in:
		
							
								
								
									
										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); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 schnulller
					schnulller