Added constraint to TSV export
This commit is contained in:
parent
3dd2e2e00d
commit
cb06af6065
@ -37,7 +37,7 @@ namespace XSDVisualiser.Desktop.Views
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
// Header
|
||||
sb.AppendLine("Depth\tPath\tName\tNamespace\tTypeName\tBuiltInType\tMinOccurs\tMaxOccurs\tContentModel\tIsNillable");
|
||||
sb.AppendLine("Depth\tPath\tName\tNamespace\tTypeName\tBuiltInType\tMinOccurs\tMaxOccurs\tContentModel\tConstraints\tIsNillable");
|
||||
var initialPath = root.Name ?? string.Empty;
|
||||
AppendNode(sb, root, 0, initialPath);
|
||||
return sb.ToString();
|
||||
@ -69,6 +69,7 @@ namespace XSDVisualiser.Desktop.Views
|
||||
min,
|
||||
max,
|
||||
San(node.ContentModel),
|
||||
San(FormatConstraints(node)),
|
||||
node.IsNillable ? "true" : "false"
|
||||
});
|
||||
sb.AppendLine(line);
|
||||
@ -83,5 +84,34 @@ namespace XSDVisualiser.Desktop.Views
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatConstraints(SchemaNode node)
|
||||
{
|
||||
var cons = node.Constraints?.Constraints;
|
||||
if (cons == null || cons.Count == 0) return string.Empty;
|
||||
|
||||
var dict = new System.Collections.Generic.SortedDictionary<string, System.Collections.Generic.SortedSet<string>>(System.StringComparer.Ordinal);
|
||||
foreach (var c in cons)
|
||||
{
|
||||
var name = c.Name;
|
||||
var value = c.Value;
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) continue;
|
||||
if (!dict.TryGetValue(name, out var set))
|
||||
{
|
||||
set = new System.Collections.Generic.SortedSet<string>(System.StringComparer.Ordinal);
|
||||
dict[name] = set;
|
||||
}
|
||||
set.Add(value);
|
||||
}
|
||||
if (dict.Count == 0) return string.Empty;
|
||||
|
||||
var parts = new System.Collections.Generic.List<string>(dict.Count);
|
||||
foreach (var kvp in dict)
|
||||
{
|
||||
var joinedValues = string.Join(",", kvp.Value);
|
||||
parts.Add($"{kvp.Key}={joinedValues}");
|
||||
}
|
||||
return string.Join(";", parts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user