Merge pull request #5 from selectline-software/NestedCompositorsAndRequiredElements

Elements in choices with nested compositors (sequences or choices) are now recognized as optional
This commit is contained in:
Mark van Renswoude 2022-06-16 10:07:08 +02:00 committed by GitHub
commit 1d5af8a7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -790,13 +790,23 @@ end;
function TXMLDataBindingGenerator.IsChoice(AElement: IXMLElementDef): Boolean;
var
compositor: IXMLElementCompositor;
parent: IXMLNode;
begin
Result := False;
if Supports(AElement.ParentNode, IXMLElementCompositor, compositor) then
Result := (compositor.CompositorType = ctChoice) and
(compositor.ElementDefs.Count > 1);
parent := AElement.ParentNode;
while Supports(parent, IXMLElementCompositor, compositor) do
begin
if compositor.CompositorType = ctSequence then
begin
parent := compositor.ParentNode;
end else
begin
Result := (compositor.CompositorType = ctChoice) and
(compositor.ElementDefs.Count + compositor.Compositors.Count > 1);
Exit;
end;
end;
end;