diff --git a/XSDVisualiser.Desktop/Views/LeftTreeView.axaml.cs b/XSDVisualiser.Desktop/Views/LeftTreeView.axaml.cs index ec07aa5..99101c6 100644 --- a/XSDVisualiser.Desktop/Views/LeftTreeView.axaml.cs +++ b/XSDVisualiser.Desktop/Views/LeftTreeView.axaml.cs @@ -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>(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(System.StringComparer.Ordinal); + dict[name] = set; + } + set.Add(value); + } + if (dict.Count == 0) return string.Empty; + + var parts = new System.Collections.Generic.List(dict.Count); + foreach (var kvp in dict) + { + var joinedValues = string.Join(",", kvp.Value); + parts.Add($"{kvp.Key}={joinedValues}"); + } + return string.Join(";", parts); + } } }