Skip to content

Commit ac638e3

Browse files
committed
// commit
1 parent cbea449 commit ac638e3

2 files changed

Lines changed: 23 additions & 31 deletions

File tree

Helper/XmlValueHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ public static class XmlValueHelper
44
{
55
public static string CleanXmlValue(this string[] value)
66
{
7-
return CleanXmlValue(string.Join(" ", value));
7+
return value == null ? string.Empty : CleanXmlValue(string.Join(" ", value));
88
}
99

1010
public static string CleanXmlValue(this string value)
1111
{
12-
return value.Replace("\t", "").Replace("\n", "").Replace("\r", "");
12+
return value.Replace("\t", "").Replace("\n", "").Replace("\r", "").Trim();
1313
}
1414
}
1515
}

Xml/Processor/XmlScriptProcessor.cs

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -888,65 +888,57 @@ private static void GenerateSelections_QueryGroup(queryGroup queryGroup, ref Dic
888888

889889
// Erzeuge erste Abfrage
890890
var qs = new List<query>(queryGroup.query);
891-
var selection = GenerateSelections_Compile(all, $"{prefix}{qs[0].Text.CleanXmlValue()}", qs[0].name).First()
892-
.CorporaAndDocumentGuids
893-
.ToDictionary(x => x.Key,
894-
x =>
895-
new
896-
HashSet
897-
<Guid
898-
>(x
899-
.Value));
891+
var selections = GenerateSelections_Compile(all, $"{prefix}{qs[0].Text.CleanXmlValue()}", qs[0].name);
892+
var merged = selections == null ? new Dictionary<Guid, HashSet<Guid>>() : selections.JoinToDictionary();
893+
900894
qs.RemoveAt(0); // Entferne erste Abfrage aus der Liste
901895

902896
// Führe alle Folgeabfragen aus.
903897
foreach (var query in qs)
904898
{
905-
var temp = GenerateSelections_Compile(all, $"{prefix}{query.Text.CleanXmlValue()}", "").First()
906-
.CorporaAndDocumentGuids
907-
.ToDictionary(x => x.Key,
908-
x =>
909-
new
910-
HashSet
911-
<Guid
912-
>(x
913-
.Value));
899+
selections = GenerateSelections_Compile(all, $"{prefix}{query.Text.CleanXmlValue()}", "");
900+
var temp = selections == null ? new Dictionary<Guid, HashSet<Guid>>() : selections.JoinToDictionary();
901+
914902
switch (queryGroup.@operator)
915903
{
916904
default:
917905
// ReSharper disable once RedundantCaseLabel
918906
case "and": // Ergebnisse müssen mit allen Abfragen übereinstimmen
919-
var csels = selection.Keys.ToArray();
907+
if (temp.Count == 0)
908+
{
909+
merged.Clear();
910+
break;
911+
}
912+
var csels = merged.Keys.ToArray();
920913
foreach (var csel in csels)
921914
{
922915
if (!temp.ContainsKey(csel))
923916
{
924-
selection.Remove(csel);
917+
merged.Remove(csel);
925918
continue;
926919
}
927920

928-
var dsels = selection[csel];
929-
foreach (var dsel in dsels)
930-
if (!temp.ContainsKey(dsel))
931-
selection[csel].Remove(dsel);
921+
var dsels = merged[csel];
922+
foreach (var dsel in dsels.Where(dsel => !temp.ContainsKey(dsel)))
923+
merged[csel].Remove(dsel);
932924
}
933925

934926
break;
935927
case "or": // Ergebnis trifft auf die erste oder eine Folgeabfrage zu
936928
foreach (var csel in temp)
937929
{
938-
if (!selection.ContainsKey(csel.Key))
939-
selection.Add(csel.Key, new HashSet<Guid>());
930+
if (!merged.ContainsKey(csel.Key))
931+
merged.Add(csel.Key, new HashSet<Guid>());
940932
foreach (var dsel in csel.Value)
941-
if (!selection[csel.Key].Contains(dsel))
942-
selection[csel.Key].Add(dsel);
933+
if (!merged[csel.Key].Contains(dsel))
934+
merged[csel.Key].Add(dsel);
943935
}
944936

945937
break;
946938
}
947939
}
948940

949-
res.Add(key, new[] { all.Create(selection, key, false) });
941+
res.Add(key, new[] { all.Create(merged, key, false) });
950942
}
951943

952944
/// <summary>

0 commit comments

Comments
 (0)