Added path to copy

This commit is contained in:
Frederik Jacobsen 2025-10-18 22:00:24 +02:00
parent dd3fafc363
commit 3dd2e2e00d

View File

@ -37,12 +37,13 @@ namespace XSDVisualiser.Desktop.Views
{
var sb = new StringBuilder();
// Header
sb.AppendLine("Depth\tName\tNamespace\tTypeName\tBuiltInType\tMinOccurs\tMaxOccurs\tContentModel\tIsNillable");
AppendNode(sb, root, 0);
sb.AppendLine("Depth\tPath\tName\tNamespace\tTypeName\tBuiltInType\tMinOccurs\tMaxOccurs\tContentModel\tIsNillable");
var initialPath = root.Name ?? string.Empty;
AppendNode(sb, root, 0, initialPath);
return sb.ToString();
}
private static void AppendNode(StringBuilder sb, SchemaNode node, int depth)
private static void AppendNode(StringBuilder sb, SchemaNode node, int depth, string path)
{
string San(string? s)
{
@ -60,6 +61,7 @@ namespace XSDVisualiser.Desktop.Views
var line = string.Join("\t", new[]
{
depth.ToString(CultureInfo.InvariantCulture),
San(path),
San(node.Name),
San(node.Namespace),
San(node.TypeName),
@ -75,7 +77,9 @@ namespace XSDVisualiser.Desktop.Views
{
foreach (var child in node.Children)
{
AppendNode(sb, child, depth + 1);
var nextPathSegment = child.Name ?? string.Empty;
var childPath = string.IsNullOrEmpty(San(path)) ? nextPathSegment : $"{path}/{nextPathSegment}";
AppendNode(sb, child, depth + 1, childPath);
}
}
}