diff --git a/XSDVisualiser.Desktop/Views/RightDetailsView.axaml b/XSDVisualiser.Desktop/Views/RightDetailsView.axaml
index a2f06c1..76a68ff 100644
--- a/XSDVisualiser.Desktop/Views/RightDetailsView.axaml
+++ b/XSDVisualiser.Desktop/Views/RightDetailsView.axaml
@@ -58,71 +58,10 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/XSDVisualiser/Models/XsdSchemaModel.cs b/XSDVisualiser/Models/XsdSchemaModel.cs
index 1ffae00..897784f 100644
--- a/XSDVisualiser/Models/XsdSchemaModel.cs
+++ b/XSDVisualiser/Models/XsdSchemaModel.cs
@@ -117,68 +117,24 @@ namespace XSDVisualiser.Models
}
///
- /// SimpleType constraints (facets).
+ /// SimpleType constraints (formerly called facets).
///
public class ConstraintSet
{
[XmlAttribute]
public string? BaseTypeName { get; set; }
- [XmlArray("Enumerations")]
- [XmlArrayItem("Value")]
- public List Enumerations { get; set; } = new();
-
- [XmlArray("Patterns")]
- [XmlArrayItem("Regex")]
- public List Patterns { get; set; } = new();
-
- [XmlElement]
- public NumericBounds? Numeric { get; set; }
-
- [XmlElement]
- public LengthBounds? Length { get; set; }
-
- // Generic catch-all list of facets for dynamic display and tooling
- [XmlArray("Facets")]
- [XmlArrayItem("Facet")]
- public List AllFacets { get; set; } = new();
+ // Generic catch-all list of constraints for dynamic display and tooling
+ [XmlArray("Constraints")]
+ [XmlArrayItem("Constraint")]
+ public List Constraints { get; set; } = new();
}
- public class FacetEntry
+ public class ConstraintEntry
{
[XmlAttribute]
public string? Name { get; set; }
[XmlAttribute]
public string? Value { get; set; }
}
-
- public class NumericBounds
- {
- [XmlAttribute]
- public string? MinInclusive { get; set; }
- [XmlAttribute]
- public string? MaxInclusive { get; set; }
- [XmlAttribute]
- public string? MinExclusive { get; set; }
- [XmlAttribute]
- public string? MaxExclusive { get; set; }
- }
-
- public class LengthBounds
- {
- [XmlAttribute]
- public int Length { get; set; }
- [XmlIgnore]
- public bool LengthSpecified { get; set; }
-
- [XmlAttribute]
- public int MinLength { get; set; }
- [XmlIgnore]
- public bool MinLengthSpecified { get; set; }
-
- [XmlAttribute]
- public int MaxLength { get; set; }
- [XmlIgnore]
- public bool MaxLengthSpecified { get; set; }
- }
}
diff --git a/XSDVisualiser/Parsing/XsdSchemaParser.cs b/XSDVisualiser/Parsing/XsdSchemaParser.cs
index 363aeaf..13f6338 100644
--- a/XSDVisualiser/Parsing/XsdSchemaParser.cs
+++ b/XSDVisualiser/Parsing/XsdSchemaParser.cs
@@ -310,7 +310,6 @@ namespace XSDVisualiser.Core
break;
case XmlSchemaSimpleTypeList list:
{
- cons.Patterns.Add("(list)");
if (!list.ItemTypeName.IsEmpty)
{
var baseType = ResolveType(list.ItemTypeName);
@@ -325,7 +324,6 @@ namespace XSDVisualiser.Core
}
case XmlSchemaSimpleTypeUnion union:
{
- cons.Patterns.Add("(union)");
foreach (var memberType in union.BaseMemberTypes)
{
if (memberType is { } mst)
@@ -345,111 +343,33 @@ namespace XSDVisualiser.Core
private static void Merge(ConstraintSet target, ConstraintSet? source)
{
if (source == null) return;
- foreach (var e in source.Enumerations.Where(e => !target.Enumerations.Contains(e))) target.Enumerations.Add(e);
- foreach (var p in source.Patterns.Where(p => !target.Patterns.Contains(p))) target.Patterns.Add(p);
- // Merge generic facets
- if (source.AllFacets != null)
+ // Merge generic constraints (name + value de-duplication)
+ if (source.Constraints != null)
{
- foreach (var sf in source.AllFacets)
+ foreach (var sc in source.Constraints)
{
var exists = false;
- foreach (var tf in target.AllFacets)
+ foreach (var tc in target.Constraints)
{
- if (string.Equals(tf.Name, sf.Name, StringComparison.Ordinal) && string.Equals(tf.Value, sf.Value, StringComparison.Ordinal))
+ if (string.Equals(tc.Name, sc.Name, StringComparison.Ordinal) && string.Equals(tc.Value, sc.Value, StringComparison.Ordinal))
{
exists = true; break;
}
}
- if (!exists) target.AllFacets.Add(new FacetEntry { Name = sf.Name, Value = sf.Value });
+ if (!exists)
+ {
+ target.Constraints.Add(new ConstraintEntry { Name = sc.Name, Value = sc.Value });
+ }
}
}
-
- if (source.Numeric != null)
- {
- target.Numeric ??= new NumericBounds();
- target.Numeric.MinInclusive ??= source.Numeric.MinInclusive;
- target.Numeric.MaxInclusive ??= source.Numeric.MaxInclusive;
- target.Numeric.MinExclusive ??= source.Numeric.MinExclusive;
- target.Numeric.MaxExclusive ??= source.Numeric.MaxExclusive;
- }
-
- if (source.Length == null) return;
-
- target.Length ??= new LengthBounds();
- if (source.Length.LengthSpecified && !target.Length.LengthSpecified)
- {
- target.Length.Length = source.Length.Length;
- target.Length.LengthSpecified = true;
- }
- if (source.Length.MinLengthSpecified && !target.Length.MinLengthSpecified)
- {
- target.Length.MinLength = source.Length.MinLength;
- target.Length.MinLengthSpecified = true;
- }
-
- if (!source.Length.MaxLengthSpecified || target.Length.MaxLengthSpecified) return;
-
- target.Length.MaxLength = source.Length.MaxLength;
- target.Length.MaxLengthSpecified = true;
}
private static void MergeFacets(ConstraintSet cons, XmlSchemaObjectCollection facets)
{
foreach (var f in facets)
{
- // Map known facets to strongly-typed buckets for backward compatibility
- switch (f)
- {
- case XmlSchemaEnumerationFacet enumFacet:
- cons.Enumerations.Add(enumFacet.Value);
- break;
- case XmlSchemaPatternFacet patternFacet:
- cons.Patterns.Add(patternFacet.Value);
- break;
- case XmlSchemaMinInclusiveFacet minInc:
- cons.Numeric ??= new NumericBounds();
- cons.Numeric.MinInclusive = minInc.Value;
- break;
- case XmlSchemaMaxInclusiveFacet maxInc:
- cons.Numeric ??= new NumericBounds();
- cons.Numeric.MaxInclusive = maxInc.Value;
- break;
- case XmlSchemaMinExclusiveFacet minEx:
- cons.Numeric ??= new NumericBounds();
- cons.Numeric.MinExclusive = minEx.Value;
- break;
- case XmlSchemaMaxExclusiveFacet maxEx:
- cons.Numeric ??= new NumericBounds();
- cons.Numeric.MaxExclusive = maxEx.Value;
- break;
- case XmlSchemaLengthFacet len:
- cons.Length ??= new LengthBounds();
- if (int.TryParse(len.Value, out var l))
- {
- cons.Length.Length = l;
- cons.Length.LengthSpecified = true;
- }
- break;
- case XmlSchemaMinLengthFacet minLen:
- cons.Length ??= new LengthBounds();
- if (int.TryParse(minLen.Value, out var ml))
- {
- cons.Length.MinLength = ml;
- cons.Length.MinLengthSpecified = true;
- }
- break;
- case XmlSchemaMaxLengthFacet maxLen:
- cons.Length ??= new LengthBounds();
- if (int.TryParse(maxLen.Value, out var xl))
- {
- cons.Length.MaxLength = xl;
- cons.Length.MaxLengthSpecified = true;
- }
- break;
- }
-
- // Always capture all facets generically for dynamic display
+ // Capture all constraints generically for dynamic display
if (f is XmlSchemaFacet baseFacet)
{
var name = GetFacetName(f);
@@ -457,7 +377,7 @@ namespace XSDVisualiser.Core
if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(value))
{
var exists = false;
- foreach (var entry in cons.AllFacets)
+ foreach (var entry in cons.Constraints)
{
if (string.Equals(entry.Name, name, StringComparison.Ordinal) && string.Equals(entry.Value, value, StringComparison.Ordinal))
{
@@ -466,7 +386,7 @@ namespace XSDVisualiser.Core
}
if (!exists)
{
- cons.AllFacets.Add(new FacetEntry { Name = name, Value = value });
+ cons.Constraints.Add(new ConstraintEntry { Name = name, Value = value });
}
}
}