53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System.Xml.Serialization;
|
|
|
|
namespace XSDVisualiser.Core;
|
|
|
|
/// <summary>
|
|
/// Represents an element or complex content node in the schema.
|
|
/// </summary>
|
|
public class SchemaNode
|
|
{
|
|
[XmlAttribute] public string? Name { get; set; }
|
|
|
|
[XmlAttribute] public string? Namespace { get; set; }
|
|
|
|
[XmlAttribute] public string? TypeName { get; set; }
|
|
|
|
[XmlAttribute] public string? BuiltInType { get; set; }
|
|
|
|
[XmlAttribute] public bool IsNillable { get; set; }
|
|
|
|
[XmlElement] public Occurs Cardinality { get; set; } = new();
|
|
|
|
[XmlElement] public ConstraintSet? Constraints { get; set; }
|
|
|
|
[XmlArray("Attributes")]
|
|
[XmlArrayItem("Attribute")]
|
|
public List<AttributeInfo> Attributes { get; set; } = new();
|
|
|
|
[XmlArray("Children")]
|
|
[XmlArrayItem("Element")]
|
|
public List<SchemaNode> Children { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Content model for this node: sequence | choice | all | simple. For synthetic group nodes, may be "group".
|
|
/// </summary>
|
|
[XmlAttribute] public string? ContentModel { get; set; }
|
|
|
|
/// <summary>
|
|
/// Human-readable documentation extracted from xsd:annotation/xsd:documentation.
|
|
/// Prefer element-level documentation; falls back to type-level documentation.
|
|
/// </summary>
|
|
[XmlElement]
|
|
public string? Documentation { get; set; }
|
|
|
|
/// <summary>
|
|
/// Returns a human-readable name for UI elements (prefers Name, then TypeName).
|
|
/// </summary>
|
|
public override string ToString()
|
|
{
|
|
if (!string.IsNullOrEmpty(Name)) return Name!;
|
|
if (!string.IsNullOrEmpty(TypeName)) return TypeName!;
|
|
return base.ToString();
|
|
}
|
|
} |