1
0
mirror of synced 2024-11-14 19:13:50 +00:00

Added support for changing string properties to enumerations

This commit is contained in:
Mark van Renswoude 2020-04-22 12:26:47 +02:00
parent 17043551f9
commit 3d5c2943fc
8 changed files with 490 additions and 87 deletions

View File

@ -48,7 +48,6 @@ object MainForm: TMainForm
Anchors = [akLeft, akTop, akBottom] Anchors = [akLeft, akTop, akBottom]
Caption = ' Output ' Caption = ' Output '
TabOrder = 1 TabOrder = 1
ExplicitHeight = 204
DesignSize = ( DesignSize = (
422 422
225) 225)
@ -83,6 +82,10 @@ object MainForm: TMainForm
TabOrder = 2 TabOrder = 2
object spFile: TTabSheet object spFile: TTabSheet
TabVisible = False TabVisible = False
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object lblFile: TLabel object lblFile: TLabel
Left = 4 Left = 4
Top = 7 Top = 7
@ -188,7 +191,6 @@ object MainForm: TMainForm
Default = True Default = True
TabOrder = 3 TabOrder = 3
OnClick = btnGenerateClick OnClick = btnGenerateClick
ExplicitTop = 258
end end
object btnClose: TButton object btnClose: TButton
Left = 355 Left = 355
@ -200,7 +202,6 @@ object MainForm: TMainForm
Caption = '&Close' Caption = '&Close'
TabOrder = 4 TabOrder = 4
OnClick = btnCloseClick OnClick = btnCloseClick
ExplicitTop = 258
end end
object btnHints: TButton object btnHints: TButton
Left = 7 Left = 7
@ -212,7 +213,6 @@ object MainForm: TMainForm
Caption = 'Generate blank &Hints file' Caption = 'Generate blank &Hints file'
TabOrder = 2 TabOrder = 2
OnClick = btnHintsClick OnClick = btnHintsClick
ExplicitTop = 258
end end
object DefaultEditStyle: TcxDefaultEditStyleController object DefaultEditStyle: TcxDefaultEditStyleController
Style.HotTrack = False Style.HotTrack = False

View File

@ -80,6 +80,7 @@ uses
FileCtrl, FileCtrl,
SysUtils, SysUtils,
Windows, Windows,
Generics.Collections,
MSXMLDOM, MSXMLDOM,
MSXML2_TLB, MSXML2_TLB,
@ -409,35 +410,96 @@ end;
procedure THintsDelphiXMLDataBindingGenerator.ProcessEnumerations; procedure THintsDelphiXMLDataBindingGenerator.ProcessEnumerations;
procedure ProcessEnumeration(ABindingEnumeration: TXMLDataBindingEnumeration; AHintEnumeration: IXMLEnumeration);
var
hintMemberIndex: Integer;
memberName: String;
memberIndex: Integer;
begin
for hintMemberIndex := 0 to Pred(AHintEnumeration.Count) do
begin
memberName := AHintEnumeration.Member[hintMemberIndex].Name;
for memberIndex := 0 to Pred(ABindingEnumeration.MemberCount) do
begin
if ABindingEnumeration.Members[memberIndex].Name = memberName then
begin
ABindingEnumeration.Members[memberIndex].TranslatedName := AHintEnumeration[hintMemberIndex].Text;
Break;
end;
end;
end;
end;
function GetNewMembers(ABindingEnumeration: TXMLDataBindingEnumeration; AHintEnumeration: IXMLEnumeration): TList<TXMLDataBindingEnumerationMember>;
var
hintMemberIndex: Integer;
member: TXMLDataBindingEnumerationMember;
begin
Result := TList<TXMLDataBindingEnumerationMember>.Create;
for hintMemberIndex := 0 to Pred(AHintEnumeration.Count) do
begin
member := TXMLDataBindingEnumerationMember.Create(Self, ABindingEnumeration, AHintEnumeration[hintMemberIndex].Name);
member.TranslatedName := AHintEnumeration[hintMemberIndex].Text;
Result.Add(member);
end;
end;
var var
itemIndex: Integer; itemIndex: Integer;
enumeration: IXMLEnumeration; enumeration: IXMLEnumeration;
schemaItem: TXMLDataBindingItem; schemaItem: TXMLDataBindingItem;
enumerationItem: TXMLDataBindingEnumeration; enumerationItem: TXMLDataBindingEnumeration;
hintMemberIndex: Integer; propertyItem: TXMLDataBindingSimpleProperty;
memberName: String; newMembers: TList<TXMLDataBindingEnumerationMember>;
memberIndex: Integer; newPropertyItem: TXMLDataBindingItemProperty;
begin begin
for itemIndex := 0 to Pred(Hints.Enumerations.Count) do for itemIndex := 0 to Pred(Hints.Enumerations.Count) do
begin begin
enumeration := Hints.Enumerations[itemIndex]; enumeration := Hints.Enumerations[itemIndex];
if FindNode(enumeration.Schema, enumeration.XPath, schemaItem) and if FindNode(enumeration.Schema, enumeration.XPath, schemaItem) then
(schemaItem.ItemType = itEnumeration) then begin
case schemaItem.ItemType of
itEnumeration:
begin begin
enumerationItem := TXMLDataBindingEnumeration(schemaItem); enumerationItem := TXMLDataBindingEnumeration(schemaItem);
for hintMemberIndex := 0 to Pred(enumeration.Count) do if enumeration.HasReplaceMembers and enumeration.ReplaceMembers then
begin begin
memberName := enumeration.Member[hintMemberIndex].Name; newMembers := GetNewMembers(enumerationItem, enumeration);
try
enumerationItem.ReplaceMembers(newMembers);
finally
FreeAndNil(newMembers);
end;
end else
ProcessEnumeration(TXMLDataBindingEnumeration(schemaItem), enumeration);
end;
for memberIndex := 0 to Pred(enumerationItem.MemberCount) do itProperty:
if TXMLDataBindingProperty(schemaItem).PropertyType = ptSimple then
begin begin
if enumerationItem.Members[memberIndex].Name = memberName then propertyItem := TXMLDataBindingSimpleProperty(schemaItem);
if propertyItem.DataType.Name = 'string' then
begin begin
enumerationItem.Members[memberIndex].TranslatedName := enumeration[hintMemberIndex].Text; enumerationItem := TXMLDataBindingEnumeration.Create(Self, schemaItem.SchemaItem, nil, schemaItem.Name);
Break; newPropertyItem := TXMLDataBindingItemProperty.Create(Self, propertyItem.SchemaItem, propertyItem.Name, enumerationItem);
newMembers := GetNewMembers(enumerationItem, enumeration);
try
enumerationItem.ReplaceMembers(newMembers);
ReplaceItem(schemaItem, newPropertyItem, False);
finally
FreeAndNil(newMembers);
end;
end; end;
end; end;
end; end;

View File

@ -1,16 +1,18 @@
{ {
X2Software XML Data Binding X2Software XML Data Binding
Generated on: 29-9-2009 14:31:13 Generated on: 22/04/2020 11:59:03
Generated from: P:\test\XMLDataBinding\XSD\DataBindingHints.xsd Generated from: P:\x2xmldatabinding\XSD\DataBindingHints.xsd
} }
unit DataBindingHintsXML; unit DataBindingHintsXML;
interface interface
uses uses
Classes, Classes,
SysUtils,
XMLDoc, XMLDoc,
XMLIntf; XMLIntf,
XMLDataBindingUtils;
type type
{ Forward declarations for DataBindingHints } { Forward declarations for DataBindingHints }
@ -30,7 +32,8 @@ type
Contains hints and mappings for the data binding output Contains hints and mappings for the data binding output
} }
IXMLDataBindingHints = interface(IXMLNode) IXMLDataBindingHints = interface(IXMLNode)
['{434CBC09-8E33-4970-9C4A-535B4C898185}'] ['{8122E348-4BE1-4436-AD2A-DAFED0CFA0C4}']
procedure XSDValidateDocument(AStrict: Boolean = False);
function GetHasEnumerations: Boolean; function GetHasEnumerations: Boolean;
function GetEnumerations: IXMLEnumerations; function GetEnumerations: IXMLEnumerations;
function GetHasDocumentElements: Boolean; function GetHasDocumentElements: Boolean;
@ -50,8 +53,18 @@ type
property Properties: IXMLProperties read GetProperties; property Properties: IXMLProperties read GetProperties;
end; end;
IXMLEnumerationsEnumerator = interface
['{725760E4-70A5-47A6-B91B-C240F1FADA60}']
function GetCurrent: IXMLEnumeration;
function MoveNext: Boolean;
property Current: IXMLEnumeration read GetCurrent;
end;
IXMLEnumerations = interface(IXMLNodeCollection) IXMLEnumerations = interface(IXMLNodeCollection)
['{115ECCB0-407B-476E-AA99-63F584F883F7}'] ['{509EAF84-A4BF-4F15-B77C-98B58792A9C3}']
function GetEnumerator: IXMLEnumerationsEnumerator;
function Get_Enumeration(Index: Integer): IXMLEnumeration; function Get_Enumeration(Index: Integer): IXMLEnumeration;
function Add: IXMLEnumeration; function Add: IXMLEnumeration;
function Insert(Index: Integer): IXMLEnumeration; function Insert(Index: Integer): IXMLEnumeration;
@ -59,8 +72,21 @@ type
property Enumeration[Index: Integer]: IXMLEnumeration read Get_Enumeration; default; property Enumeration[Index: Integer]: IXMLEnumeration read Get_Enumeration; default;
end; end;
IXMLEnumerationEnumerator = interface
['{8A1AF158-2AF3-49FB-9CFC-46897D8AF28C}']
function GetCurrent: IXMLMember;
function MoveNext: Boolean;
property Current: IXMLMember read GetCurrent;
end;
IXMLEnumeration = interface(IXMLNodeCollection) IXMLEnumeration = interface(IXMLNodeCollection)
['{4B776A26-325C-4589-8F5B-88E2EE86DEC6}'] ['{01A5E078-6EEB-40A0-BF72-972B467AD983}']
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetEnumerator: IXMLEnumerationEnumerator;
function Get_Member(Index: Integer): IXMLMember; function Get_Member(Index: Integer): IXMLMember;
function Add: IXMLMember; function Add: IXMLMember;
function Insert(Index: Integer): IXMLMember; function Insert(Index: Integer): IXMLMember;
@ -69,29 +95,50 @@ type
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
function GetHasReplaceMembers: Boolean;
function GetReplaceMembers: Boolean;
procedure SetSchema(const Value: WideString); procedure SetSchema(const Value: WideString);
procedure SetXPath(const Value: WideString); procedure SetXPath(const Value: WideString);
procedure SetReplaceMembers(const Value: Boolean);
property Schema: WideString read GetSchema write SetSchema; property Schema: WideString read GetSchema write SetSchema;
property XPath: WideString read GetXPath write SetXPath; property XPath: WideString read GetXPath write SetXPath;
property HasReplaceMembers: Boolean read GetHasReplaceMembers;
property ReplaceMembers: Boolean read GetReplaceMembers write SetReplaceMembers;
end; end;
IXMLMember = interface(IXMLNode) IXMLMember = interface(IXMLNode)
['{2575F0F6-EDCA-4CC6-B532-94833BCFAB64}'] ['{C58EF7F8-E182-47A3-B591-550A51AA0751}']
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetName: WideString; function GetName: WideString;
function GetValue: WideString;
procedure SetName(const Value: WideString); procedure SetName(const Value: WideString);
procedure SetValue(const Value: WideString);
property Name: WideString read GetName write SetName; property Name: WideString read GetName write SetName;
property Value: WideString read GetValue write SetValue;
end; end;
IXMLDocumentElementsEnumerator = interface
['{D58F3363-3E98-4EF9-9A9E-F57B7C4639D7}']
function GetCurrent: IXMLDocumentElement;
function MoveNext: Boolean;
property Current: IXMLDocumentElement read GetCurrent;
end;
{ {
If present, only elements which are included in this list will be marked as If present, only elements which are included in this list will be marked as
a Document Element. a Document Element.
} }
IXMLDocumentElements = interface(IXMLNodeCollection) IXMLDocumentElements = interface(IXMLNodeCollection)
['{8D3A5543-68FF-4101-9874-639A39E33950}'] ['{D991E86F-3D42-4B05-BB90-10AF42324FE1}']
function GetEnumerator: IXMLDocumentElementsEnumerator;
function Get_DocumentElement(Index: Integer): IXMLDocumentElement; function Get_DocumentElement(Index: Integer): IXMLDocumentElement;
function Add: IXMLDocumentElement; function Add: IXMLDocumentElement;
function Insert(Index: Integer): IXMLDocumentElement; function Insert(Index: Integer): IXMLDocumentElement;
@ -100,7 +147,10 @@ type
end; end;
IXMLDocumentElement = interface(IXMLNode) IXMLDocumentElement = interface(IXMLNode)
['{3DFD0655-26DA-4237-ACEC-BB7CB3354DD2}'] ['{0FD90406-67B2-4076-870C-47DA8E8582ED}']
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
@ -111,8 +161,18 @@ type
property XPath: WideString read GetXPath write SetXPath; property XPath: WideString read GetXPath write SetXPath;
end; end;
IXMLInterfacesEnumerator = interface
['{A1433E41-A316-4DBD-ADC2-7EA490CEFCB3}']
function GetCurrent: IXMLInterfaceName;
function MoveNext: Boolean;
property Current: IXMLInterfaceName read GetCurrent;
end;
IXMLInterfaces = interface(IXMLNodeCollection) IXMLInterfaces = interface(IXMLNodeCollection)
['{E70E67E3-C108-4015-B996-962D800BE555}'] ['{6A2EDBB5-36FE-4CA6-B3B9-1AC7A016E372}']
function GetEnumerator: IXMLInterfacesEnumerator;
function Get_InterfaceName(Index: Integer): IXMLInterfaceName; function Get_InterfaceName(Index: Integer): IXMLInterfaceName;
function Add: IXMLInterfaceName; function Add: IXMLInterfaceName;
function Insert(Index: Integer): IXMLInterfaceName; function Insert(Index: Integer): IXMLInterfaceName;
@ -121,19 +181,35 @@ type
end; end;
IXMLInterfaceName = interface(IXMLNode) IXMLInterfaceName = interface(IXMLNode)
['{2B8126E7-2F89-4E5D-89E3-4F5F7AEE35E9}'] ['{F0057FA9-92D8-47C5-AC29-6A045595B7F0}']
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
function GetValue: WideString;
procedure SetSchema(const Value: WideString); procedure SetSchema(const Value: WideString);
procedure SetXPath(const Value: WideString); procedure SetXPath(const Value: WideString);
procedure SetValue(const Value: WideString);
property Schema: WideString read GetSchema write SetSchema; property Schema: WideString read GetSchema write SetSchema;
property XPath: WideString read GetXPath write SetXPath; property XPath: WideString read GetXPath write SetXPath;
property Value: WideString read GetValue write SetValue;
end; end;
IXMLPropertiesEnumerator = interface
['{4FDE9618-2177-4D53-8B14-5E81E397E084}']
function GetCurrent: IXMLPropertyName;
function MoveNext: Boolean;
property Current: IXMLPropertyName read GetCurrent;
end;
IXMLProperties = interface(IXMLNodeCollection) IXMLProperties = interface(IXMLNodeCollection)
['{88260AE1-1C40-4F0F-AA44-C61EDAA53B38}'] ['{38320F29-9D8C-4158-B0F6-8E1D1FD31EB9}']
function GetEnumerator: IXMLPropertiesEnumerator;
function Get_PropertyName(Index: Integer): IXMLPropertyName; function Get_PropertyName(Index: Integer): IXMLPropertyName;
function Add: IXMLPropertyName; function Add: IXMLPropertyName;
function Insert(Index: Integer): IXMLPropertyName; function Insert(Index: Integer): IXMLPropertyName;
@ -142,7 +218,10 @@ type
end; end;
IXMLPropertyName = interface(IXMLNode) IXMLPropertyName = interface(IXMLNode)
['{DB714E5D-E62B-44C4-B7D4-0623887BCDF6}'] ['{F99D3125-B2DE-4A4A-88D0-DBCB50C75C59}']
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
@ -155,10 +234,11 @@ type
{ Classes for DataBindingHints } { Classes for DataBindingHints }
TXMLDataBindingHints = class(TXMLNode, IXMLDataBindingHints) TXMLDataBindingHints = class(TX2XMLNode, IXMLDataBindingHints)
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
protected protected
procedure XSDValidateDocument(AStrict: Boolean = False);
function GetHasEnumerations: Boolean; function GetHasEnumerations: Boolean;
function GetEnumerations: IXMLEnumerations; function GetEnumerations: IXMLEnumerations;
function GetHasDocumentElements: Boolean; function GetHasDocumentElements: Boolean;
@ -169,48 +249,86 @@ type
function GetProperties: IXMLProperties; function GetProperties: IXMLProperties;
end; end;
TXMLEnumerations = class(TXMLNodeCollection, IXMLEnumerations) TXMLEnumerationsEnumerator = class(TXMLNodeCollectionEnumerator, IXMLEnumerationsEnumerator)
protected
function GetCurrent: IXMLEnumeration;
end;
TXMLEnumerations = class(TX2XMLNodeCollection, IXMLEnumerations)
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
protected protected
function GetEnumerator: IXMLEnumerationsEnumerator;
function Get_Enumeration(Index: Integer): IXMLEnumeration; function Get_Enumeration(Index: Integer): IXMLEnumeration;
function Add: IXMLEnumeration; function Add: IXMLEnumeration;
function Insert(Index: Integer): IXMLEnumeration; function Insert(Index: Integer): IXMLEnumeration;
end; end;
TXMLEnumeration = class(TXMLNodeCollection, IXMLEnumeration) TXMLEnumerationEnumerator = class(TXMLNodeCollectionEnumerator, IXMLEnumerationEnumerator)
protected
function GetCurrent: IXMLMember;
end;
TXMLEnumeration = class(TX2XMLNodeCollection, IXSDValidate, IXSDValidateStrict, IXMLEnumeration)
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
protected protected
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetEnumerator: IXMLEnumerationEnumerator;
function Get_Member(Index: Integer): IXMLMember; function Get_Member(Index: Integer): IXMLMember;
function Add: IXMLMember; function Add: IXMLMember;
function Insert(Index: Integer): IXMLMember; function Insert(Index: Integer): IXMLMember;
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
function GetHasReplaceMembers: Boolean;
function GetReplaceMembers: Boolean;
procedure SetSchema(const Value: WideString); procedure SetSchema(const Value: WideString);
procedure SetXPath(const Value: WideString); procedure SetXPath(const Value: WideString);
procedure SetReplaceMembers(const Value: Boolean);
end; end;
TXMLMember = class(TXMLNode, IXMLMember) TXMLMember = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLMember)
protected protected
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetName: WideString; function GetName: WideString;
function GetValue: WideString;
procedure SetName(const Value: WideString); procedure SetName(const Value: WideString);
procedure SetValue(const Value: WideString);
end; end;
TXMLDocumentElements = class(TXMLNodeCollection, IXMLDocumentElements) TXMLDocumentElementsEnumerator = class(TXMLNodeCollectionEnumerator, IXMLDocumentElementsEnumerator)
protected
function GetCurrent: IXMLDocumentElement;
end;
TXMLDocumentElements = class(TX2XMLNodeCollection, IXMLDocumentElements)
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
protected protected
function GetEnumerator: IXMLDocumentElementsEnumerator;
function Get_DocumentElement(Index: Integer): IXMLDocumentElement; function Get_DocumentElement(Index: Integer): IXMLDocumentElement;
function Add: IXMLDocumentElement; function Add: IXMLDocumentElement;
function Insert(Index: Integer): IXMLDocumentElement; function Insert(Index: Integer): IXMLDocumentElement;
end; end;
TXMLDocumentElement = class(TXMLNode, IXMLDocumentElement) TXMLDocumentElement = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLDocumentElement)
protected protected
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
@ -218,35 +336,59 @@ type
procedure SetXPath(const Value: WideString); procedure SetXPath(const Value: WideString);
end; end;
TXMLInterfaces = class(TXMLNodeCollection, IXMLInterfaces) TXMLInterfacesEnumerator = class(TXMLNodeCollectionEnumerator, IXMLInterfacesEnumerator)
protected
function GetCurrent: IXMLInterfaceName;
end;
TXMLInterfaces = class(TX2XMLNodeCollection, IXMLInterfaces)
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
protected protected
function GetEnumerator: IXMLInterfacesEnumerator;
function Get_InterfaceName(Index: Integer): IXMLInterfaceName; function Get_InterfaceName(Index: Integer): IXMLInterfaceName;
function Add: IXMLInterfaceName; function Add: IXMLInterfaceName;
function Insert(Index: Integer): IXMLInterfaceName; function Insert(Index: Integer): IXMLInterfaceName;
end; end;
TXMLInterfaceName = class(TXMLNode, IXMLInterfaceName) TXMLInterfaceName = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLInterfaceName)
protected protected
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
function GetValue: WideString;
procedure SetSchema(const Value: WideString); procedure SetSchema(const Value: WideString);
procedure SetXPath(const Value: WideString); procedure SetXPath(const Value: WideString);
procedure SetValue(const Value: WideString);
end; end;
TXMLProperties = class(TXMLNodeCollection, IXMLProperties) TXMLPropertiesEnumerator = class(TXMLNodeCollectionEnumerator, IXMLPropertiesEnumerator)
protected
function GetCurrent: IXMLPropertyName;
end;
TXMLProperties = class(TX2XMLNodeCollection, IXMLProperties)
public public
procedure AfterConstruction; override; procedure AfterConstruction; override;
protected protected
function GetEnumerator: IXMLPropertiesEnumerator;
function Get_PropertyName(Index: Integer): IXMLPropertyName; function Get_PropertyName(Index: Integer): IXMLPropertyName;
function Add: IXMLPropertyName; function Add: IXMLPropertyName;
function Insert(Index: Integer): IXMLPropertyName; function Insert(Index: Integer): IXMLPropertyName;
end; end;
TXMLPropertyName = class(TXMLNode, IXMLPropertyName) TXMLPropertyName = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLPropertyName)
protected protected
procedure XSDValidate;
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
function GetSchema: WideString; function GetSchema: WideString;
function GetXPath: WideString; function GetXPath: WideString;
@ -259,6 +401,7 @@ type
function GetDataBindingHints(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingHints; function GetDataBindingHints(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingHints;
function LoadDataBindingHints(const AFileName: String): IXMLDataBindingHints; function LoadDataBindingHints(const AFileName: String): IXMLDataBindingHints;
function LoadDataBindingHintsFromStream(AStream: TStream): IXMLDataBindingHints; function LoadDataBindingHintsFromStream(AStream: TStream): IXMLDataBindingHints;
function LoadDataBindingHintsFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding = nil; AOwnsEncoding: Boolean = True{$IFEND}): IXMLDataBindingHints;
function NewDataBindingHints: IXMLDataBindingHints; function NewDataBindingHints: IXMLDataBindingHints;
@ -268,7 +411,7 @@ const
implementation implementation
uses uses
SysUtils; Variants;
{ Document functions } { Document functions }
function GetDataBindingHints(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingHints; function GetDataBindingHints(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingHints;
@ -291,6 +434,24 @@ begin
Result := GetDataBindingHints(doc); Result := GetDataBindingHints(doc);
end; end;
function LoadDataBindingHintsFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding; AOwnsEncoding: Boolean{$IFEND}): IXMLDataBindingHints;
var
stream: TStringStream;
begin
{$IF CompilerVersion >= 20}
if Assigned(AEncoding) then
stream := TStringStream.Create(AString, AEncoding, AOwnsEncoding)
else
{$IFEND}
stream := TStringStream.Create(AString);
try
Result := LoadDataBindingHintsFromStream(stream);
finally
FreeAndNil(stream);
end;
end;
function NewDataBindingHints: IXMLDataBindingHints; function NewDataBindingHints: IXMLDataBindingHints;
begin begin
Result := NewXMLDocument.GetDocBinding('DataBindingHints', TXMLDataBindingHints, TargetNamespace) as IXMLDataBindingHints Result := NewXMLDocument.GetDocBinding('DataBindingHints', TXMLDataBindingHints, TargetNamespace) as IXMLDataBindingHints
@ -308,6 +469,14 @@ begin
inherited; inherited;
end; end;
procedure TXMLDataBindingHints.XSDValidateDocument(AStrict: Boolean);
begin
if AStrict then
XMLDataBindingUtils.XSDValidateStrict(Self)
else
XMLDataBindingUtils.XSDValidate(Self);
end;
function TXMLDataBindingHints.GetHasEnumerations: Boolean; function TXMLDataBindingHints.GetHasEnumerations: Boolean;
begin begin
Result := Assigned(ChildNodes.FindNode('Enumerations')); Result := Assigned(ChildNodes.FindNode('Enumerations'));
@ -352,6 +521,11 @@ begin
Result := (ChildNodes['Properties'] as IXMLProperties); Result := (ChildNodes['Properties'] as IXMLProperties);
end; end;
function TXMLEnumerationsEnumerator.GetCurrent: IXMLEnumeration;
begin
Result := (inherited GetCurrent as IXMLEnumeration);
end;
procedure TXMLEnumerations.AfterConstruction; procedure TXMLEnumerations.AfterConstruction;
begin begin
RegisterChildNode('Enumeration', TXMLEnumeration); RegisterChildNode('Enumeration', TXMLEnumeration);
@ -362,6 +536,11 @@ begin
inherited; inherited;
end; end;
function TXMLEnumerations.GetEnumerator: IXMLEnumerationsEnumerator;
begin
Result := TXMLEnumerationsEnumerator.Create(Self);
end;
function TXMLEnumerations.Get_Enumeration(Index: Integer): IXMLEnumeration; function TXMLEnumerations.Get_Enumeration(Index: Integer): IXMLEnumeration;
begin begin
Result := (List[Index] as IXMLEnumeration); Result := (List[Index] as IXMLEnumeration);
@ -377,6 +556,11 @@ begin
Result := (AddItem(Index) as IXMLEnumeration); Result := (AddItem(Index) as IXMLEnumeration);
end; end;
function TXMLEnumerationEnumerator.GetCurrent: IXMLMember;
begin
Result := (inherited GetCurrent as IXMLMember);
end;
procedure TXMLEnumeration.AfterConstruction; procedure TXMLEnumeration.AfterConstruction;
begin begin
RegisterChildNode('Member', TXMLMember); RegisterChildNode('Member', TXMLMember);
@ -387,6 +571,21 @@ begin
inherited; inherited;
end; end;
procedure TXMLEnumeration.XSDValidate;
begin
CreateRequiredAttributes(Self, ['Schema', 'XPath']);
end;
procedure TXMLEnumeration.XSDValidateStrict(AResult: IXSDValidateStrictResult);
begin
ValidateRequiredAttributes(AResult, Self, ['Schema', 'XPath']);
end;
function TXMLEnumeration.GetEnumerator: IXMLEnumerationEnumerator;
begin
Result := TXMLEnumerationEnumerator.Create(Self);
end;
function TXMLEnumeration.Get_Member(Index: Integer): IXMLMember; function TXMLEnumeration.Get_Member(Index: Integer): IXMLMember;
begin begin
Result := (List[Index] as IXMLMember); Result := (List[Index] as IXMLMember);
@ -412,14 +611,40 @@ begin
Result := AttributeNodes['XPath'].Text; Result := AttributeNodes['XPath'].Text;
end; end;
function TXMLEnumeration.GetHasReplaceMembers: Boolean;
begin
Result := Assigned(AttributeNodes.FindNode('ReplaceMembers'));
end;
function TXMLEnumeration.GetReplaceMembers: Boolean;
begin
Result := AttributeNodes['ReplaceMembers'].NodeValue;
end;
procedure TXMLEnumeration.SetSchema(const Value: WideString); procedure TXMLEnumeration.SetSchema(const Value: WideString);
begin begin
SetAttribute('Schema', Value); SetAttribute('Schema', GetValidXMLText(Value));
end; end;
procedure TXMLEnumeration.SetXPath(const Value: WideString); procedure TXMLEnumeration.SetXPath(const Value: WideString);
begin begin
SetAttribute('XPath', Value); SetAttribute('XPath', GetValidXMLText(Value));
end;
procedure TXMLEnumeration.SetReplaceMembers(const Value: Boolean);
begin
SetAttribute('ReplaceMembers', BoolToXML(Value));
end;
procedure TXMLMember.XSDValidate;
begin
CreateRequiredAttributes(Self, ['Name']);
end;
procedure TXMLMember.XSDValidateStrict(AResult: IXSDValidateStrictResult);
begin
ValidateRequiredAttributes(AResult, Self, ['Name']);
end; end;
function TXMLMember.GetName: WideString; function TXMLMember.GetName: WideString;
@ -427,9 +652,24 @@ begin
Result := AttributeNodes['Name'].Text; Result := AttributeNodes['Name'].Text;
end; end;
function TXMLMember.GetValue: WideString;
begin
Result := VarToStr(GetNodeValue);
end;
procedure TXMLMember.SetName(const Value: WideString); procedure TXMLMember.SetName(const Value: WideString);
begin begin
SetAttribute('Name', Value); SetAttribute('Name', GetValidXMLText(Value));
end;
procedure TXMLMember.SetValue(const Value: WideString);
begin
SetNodeValue(GetValidXMLText(Value));
end;
function TXMLDocumentElementsEnumerator.GetCurrent: IXMLDocumentElement;
begin
Result := (inherited GetCurrent as IXMLDocumentElement);
end; end;
procedure TXMLDocumentElements.AfterConstruction; procedure TXMLDocumentElements.AfterConstruction;
@ -442,6 +682,11 @@ begin
inherited; inherited;
end; end;
function TXMLDocumentElements.GetEnumerator: IXMLDocumentElementsEnumerator;
begin
Result := TXMLDocumentElementsEnumerator.Create(Self);
end;
function TXMLDocumentElements.Get_DocumentElement(Index: Integer): IXMLDocumentElement; function TXMLDocumentElements.Get_DocumentElement(Index: Integer): IXMLDocumentElement;
begin begin
Result := (List[Index] as IXMLDocumentElement); Result := (List[Index] as IXMLDocumentElement);
@ -457,6 +702,16 @@ begin
Result := (AddItem(Index) as IXMLDocumentElement); Result := (AddItem(Index) as IXMLDocumentElement);
end; end;
procedure TXMLDocumentElement.XSDValidate;
begin
CreateRequiredAttributes(Self, ['Schema', 'XPath']);
end;
procedure TXMLDocumentElement.XSDValidateStrict(AResult: IXSDValidateStrictResult);
begin
ValidateRequiredAttributes(AResult, Self, ['Schema', 'XPath']);
end;
function TXMLDocumentElement.GetSchema: WideString; function TXMLDocumentElement.GetSchema: WideString;
begin begin
Result := AttributeNodes['Schema'].Text; Result := AttributeNodes['Schema'].Text;
@ -469,12 +724,17 @@ end;
procedure TXMLDocumentElement.SetSchema(const Value: WideString); procedure TXMLDocumentElement.SetSchema(const Value: WideString);
begin begin
SetAttribute('Schema', Value); SetAttribute('Schema', GetValidXMLText(Value));
end; end;
procedure TXMLDocumentElement.SetXPath(const Value: WideString); procedure TXMLDocumentElement.SetXPath(const Value: WideString);
begin begin
SetAttribute('XPath', Value); SetAttribute('XPath', GetValidXMLText(Value));
end;
function TXMLInterfacesEnumerator.GetCurrent: IXMLInterfaceName;
begin
Result := (inherited GetCurrent as IXMLInterfaceName);
end; end;
procedure TXMLInterfaces.AfterConstruction; procedure TXMLInterfaces.AfterConstruction;
@ -487,6 +747,11 @@ begin
inherited; inherited;
end; end;
function TXMLInterfaces.GetEnumerator: IXMLInterfacesEnumerator;
begin
Result := TXMLInterfacesEnumerator.Create(Self);
end;
function TXMLInterfaces.Get_InterfaceName(Index: Integer): IXMLInterfaceName; function TXMLInterfaces.Get_InterfaceName(Index: Integer): IXMLInterfaceName;
begin begin
Result := (List[Index] as IXMLInterfaceName); Result := (List[Index] as IXMLInterfaceName);
@ -502,6 +767,16 @@ begin
Result := (AddItem(Index) as IXMLInterfaceName); Result := (AddItem(Index) as IXMLInterfaceName);
end; end;
procedure TXMLInterfaceName.XSDValidate;
begin
CreateRequiredAttributes(Self, ['Schema', 'XPath']);
end;
procedure TXMLInterfaceName.XSDValidateStrict(AResult: IXSDValidateStrictResult);
begin
ValidateRequiredAttributes(AResult, Self, ['Schema', 'XPath']);
end;
function TXMLInterfaceName.GetSchema: WideString; function TXMLInterfaceName.GetSchema: WideString;
begin begin
Result := AttributeNodes['Schema'].Text; Result := AttributeNodes['Schema'].Text;
@ -512,14 +787,29 @@ begin
Result := AttributeNodes['XPath'].Text; Result := AttributeNodes['XPath'].Text;
end; end;
function TXMLInterfaceName.GetValue: WideString;
begin
Result := VarToStr(GetNodeValue);
end;
procedure TXMLInterfaceName.SetSchema(const Value: WideString); procedure TXMLInterfaceName.SetSchema(const Value: WideString);
begin begin
SetAttribute('Schema', Value); SetAttribute('Schema', GetValidXMLText(Value));
end; end;
procedure TXMLInterfaceName.SetXPath(const Value: WideString); procedure TXMLInterfaceName.SetXPath(const Value: WideString);
begin begin
SetAttribute('XPath', Value); SetAttribute('XPath', GetValidXMLText(Value));
end;
procedure TXMLInterfaceName.SetValue(const Value: WideString);
begin
SetNodeValue(GetValidXMLText(Value));
end;
function TXMLPropertiesEnumerator.GetCurrent: IXMLPropertyName;
begin
Result := (inherited GetCurrent as IXMLPropertyName);
end; end;
procedure TXMLProperties.AfterConstruction; procedure TXMLProperties.AfterConstruction;
@ -532,6 +822,11 @@ begin
inherited; inherited;
end; end;
function TXMLProperties.GetEnumerator: IXMLPropertiesEnumerator;
begin
Result := TXMLPropertiesEnumerator.Create(Self);
end;
function TXMLProperties.Get_PropertyName(Index: Integer): IXMLPropertyName; function TXMLProperties.Get_PropertyName(Index: Integer): IXMLPropertyName;
begin begin
Result := (List[Index] as IXMLPropertyName); Result := (List[Index] as IXMLPropertyName);
@ -547,6 +842,16 @@ begin
Result := (AddItem(Index) as IXMLPropertyName); Result := (AddItem(Index) as IXMLPropertyName);
end; end;
procedure TXMLPropertyName.XSDValidate;
begin
CreateRequiredAttributes(Self, ['Schema', 'XPath']);
end;
procedure TXMLPropertyName.XSDValidateStrict(AResult: IXSDValidateStrictResult);
begin
ValidateRequiredAttributes(AResult, Self, ['Schema', 'XPath']);
end;
function TXMLPropertyName.GetSchema: WideString; function TXMLPropertyName.GetSchema: WideString;
begin begin
Result := AttributeNodes['Schema'].Text; Result := AttributeNodes['Schema'].Text;
@ -559,12 +864,12 @@ end;
procedure TXMLPropertyName.SetSchema(const Value: WideString); procedure TXMLPropertyName.SetSchema(const Value: WideString);
begin begin
SetAttribute('Schema', Value); SetAttribute('Schema', GetValidXMLText(Value));
end; end;
procedure TXMLPropertyName.SetXPath(const Value: WideString); procedure TXMLPropertyName.SetXPath(const Value: WideString);
begin begin
SetAttribute('XPath', Value); SetAttribute('XPath', GetValidXMLText(Value));
end; end;

View File

@ -77,7 +77,7 @@ type
function FindInterface(ASchema: TXMLDataBindingSchema; const AName: String; AType: TXMLDataBindingInterfaceType): TXMLDataBindingInterface; function FindInterface(ASchema: TXMLDataBindingSchema; const AName: String; AType: TXMLDataBindingInterfaceType): TXMLDataBindingInterface;
function FindEnumeration(ASchema: TXMLDataBindingSchema; const AName: String): TXMLDataBindingEnumeration; function FindEnumeration(ASchema: TXMLDataBindingSchema; const AName: String): TXMLDataBindingEnumeration;
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
procedure ResolveSchema(ASchema: TXMLDataBindingSchema); procedure ResolveSchema(ASchema: TXMLDataBindingSchema);
procedure ResolveAlias(ASchema: TXMLDataBindingSchema); procedure ResolveAlias(ASchema: TXMLDataBindingSchema);
@ -113,7 +113,7 @@ type
private private
FOwner: TXMLDataBindingGenerator; FOwner: TXMLDataBindingGenerator;
protected protected
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); virtual; procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); virtual;
property Owner: TXMLDataBindingGenerator read FOwner; property Owner: TXMLDataBindingGenerator read FOwner;
public public
@ -136,7 +136,7 @@ type
function GetIncludes(Index: Integer): TXMLDataBindingSchema; function GetIncludes(Index: Integer): TXMLDataBindingSchema;
function GetTargetNamespace: String; function GetTargetNamespace: String;
protected protected
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); override; procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
procedure AddInclude(ASchema: TXMLDataBindingSchema); procedure AddInclude(ASchema: TXMLDataBindingSchema);
procedure AddItem(AItem: TXMLDataBindingItem); procedure AddItem(AItem: TXMLDataBindingItem);
@ -177,12 +177,11 @@ type
protected protected
function GetItemType: TXMLDataBindingItemType; virtual; abstract; function GetItemType: TXMLDataBindingItemType; virtual; abstract;
procedure SetName(const Value: String); procedure SetName(const Value: String);
property SchemaItem: IXMLSchemaItem read FSchemaItem;
public public
constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; const AName: String); constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; const AName: String);
property Schema: TXMLDataBindingSchema read FSchema write FSchema; property Schema: TXMLDataBindingSchema read FSchema write FSchema;
property SchemaItem: IXMLSchemaItem read FSchemaItem;
property TargetNamespace: String read FTargetNamespace write FTargetNamespace; property TargetNamespace: String read FTargetNamespace write FTargetNamespace;
property DocumentElement: Boolean read FDocumentElement write FDocumentElement; property DocumentElement: Boolean read FDocumentElement write FDocumentElement;
@ -211,7 +210,7 @@ type
protected protected
function GetItemType: TXMLDataBindingItemType; override; function GetItemType: TXMLDataBindingItemType; override;
procedure ReplaceItem(const AOldItem: TXMLDataBindingItem; const ANewItem: TXMLDataBindingItem); override; procedure ReplaceItem(const AOldItem: TXMLDataBindingItem; const ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
procedure AddProperty(AProperty: TXMLDataBindingProperty); procedure AddProperty(AProperty: TXMLDataBindingProperty);
public public
@ -251,9 +250,11 @@ type
protected protected
function GetItemType: TXMLDataBindingItemType; override; function GetItemType: TXMLDataBindingItemType; override;
public public
constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; AEnumerations: IXMLEnumerationCollection; const AName: String); constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; AEnumerations: IXMLEnumerationCollection; const AName: String); overload;
destructor Destroy; override; destructor Destroy; override;
procedure ReplaceMembers(AMembers: TEnumerable<TXMLDataBindingEnumerationMember>);
property MemberCount: Integer read GetMemberCount; property MemberCount: Integer read GetMemberCount;
property Members[Index: Integer]: TXMLDataBindingEnumerationMember read GetMembers; property Members[Index: Integer]: TXMLDataBindingEnumerationMember read GetMembers;
end; end;
@ -309,7 +310,7 @@ type
function GetIsReadOnly: Boolean; override; function GetIsReadOnly: Boolean; override;
function GetPropertyType: TXMLDataBindingPropertyType; override; function GetPropertyType: TXMLDataBindingPropertyType; override;
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); override; procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
public public
constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; const AName: String; AItem: TXMLDataBindingItem); constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; const AName: String; AItem: TXMLDataBindingItem);
@ -335,7 +336,7 @@ type
protected protected
function GetItemType: TXMLDataBindingItemType; override; function GetItemType: TXMLDataBindingItemType; override;
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); override; procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
public public
property Item: TXMLDataBindingItem read FItem write FItem; property Item: TXMLDataBindingItem read FItem write FItem;
end; end;
@ -1233,13 +1234,13 @@ begin
end; end;
procedure TXMLDataBindingGenerator.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure TXMLDataBindingGenerator.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
var var
schemaIndex: Integer; schemaIndex: Integer;
begin begin
for schemaIndex := Pred(SchemaCount) downto 0 do for schemaIndex := Pred(SchemaCount) downto 0 do
Schemas[schemaIndex].ReplaceItem(AOldItem, ANewItem); Schemas[schemaIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
end; end;
@ -1304,7 +1305,7 @@ begin
interfaceItem.BaseName := complexAliasItem.Item.Name; interfaceItem.BaseName := complexAliasItem.Item.Name;
ASchema.AddItem(interfaceItem); ASchema.AddItem(interfaceItem);
ReplaceItem(complexAliasItem, interfaceItem); ReplaceItem(complexAliasItem, interfaceItem, True);
FreeAndNil(complexAliasItem); FreeAndNil(complexAliasItem);
end; end;
end; end;
@ -1314,7 +1315,7 @@ begin
{ Remove the alias element - TXMLDataBindingInterfaceItem.ReplaceItem { Remove the alias element - TXMLDataBindingInterfaceItem.ReplaceItem
will take care of fixing it's properties. } will take care of fixing it's properties. }
simpleAliasItem := TXMLDataBindingSimpleTypeAliasItem(item); simpleAliasItem := TXMLDataBindingSimpleTypeAliasItem(item);
ReplaceItem(simpleAliasItem, nil); ReplaceItem(simpleAliasItem, nil, True);
FreeAndNil(simpleAliasItem); FreeAndNil(simpleAliasItem);
end; end;
end; end;
@ -1353,7 +1354,7 @@ begin
end; end;
if Assigned(referenceItem) then if Assigned(referenceItem) then
ReplaceItem(AItem, referenceItem) ReplaceItem(AItem, referenceItem, True)
else else
raise EXMLDataBindingUnresolvedItem.CreateFmt('Unresolved %s: %s', raise EXMLDataBindingUnresolvedItem.CreateFmt('Unresolved %s: %s',
[GetEnumName(TypeInfo(TXMLDataBindingInterfaceType), Ord(AItem.InterfaceType)), [GetEnumName(TypeInfo(TXMLDataBindingInterfaceType), Ord(AItem.InterfaceType)),
@ -1639,7 +1640,7 @@ begin
end; end;
procedure TXMLDataBindingGeneratorItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure TXMLDataBindingGeneratorItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
begin begin
end; end;
@ -1663,7 +1664,7 @@ begin
end; end;
procedure TXMLDataBindingSchema.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure TXMLDataBindingSchema.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
var var
itemIndex: Integer; itemIndex: Integer;
@ -1672,9 +1673,13 @@ begin
for itemIndex := Pred(ItemCount) downto 0 do for itemIndex := Pred(ItemCount) downto 0 do
if Items[itemIndex] = AOldItem then if Items[itemIndex] = AOldItem then
begin
if ARemoveOnly then
FItems.Extract(AOldItem) FItems.Extract(AOldItem)
else else
Items[itemIndex].ReplaceItem(AOldItem, ANewItem); FItems[itemIndex] := ANewItem;
end else
Items[itemIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
end; end;
@ -1829,7 +1834,7 @@ begin
end; end;
procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
var var
propertyIndex: Integer; propertyIndex: Integer;
propertyItem: TXMLDataBindingProperty; propertyItem: TXMLDataBindingProperty;
@ -1846,8 +1851,12 @@ begin
propertyItem := Properties[propertyIndex]; propertyItem := Properties[propertyIndex];
if propertyItem = AOldItem then if propertyItem = AOldItem then
begin
if ARemoveOnly then
FProperties.Extract(propertyItem) FProperties.Extract(propertyItem)
else else
FProperties[propertyIndex] := ANewItem as TXMLDataBindingProperty;
end else
begin begin
if (AOldItem.ItemType = itSimpleTypeAlias) and if (AOldItem.ItemType = itSimpleTypeAlias) and
(propertyItem.PropertyType = ptItem) then (propertyItem.PropertyType = ptItem) then
@ -1862,9 +1871,9 @@ begin
{ FProperties owns itemProperty and will free it } { FProperties owns itemProperty and will free it }
FProperties[propertyIndex] := simpleProperty; FProperties[propertyIndex] := simpleProperty;
end else end else
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem); Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
end else end else
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem); Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
end; end;
end; end;
end; end;
@ -1961,8 +1970,11 @@ begin
FMembers := TObjectList<TXMLDataBindingEnumerationMember>.Create; FMembers := TObjectList<TXMLDataBindingEnumerationMember>.Create;
if Assigned(AEnumerations) then
begin
for memberIndex := 0 to Pred(AEnumerations.Count) do for memberIndex := 0 to Pred(AEnumerations.Count) do
FMembers.Add(TXMLDataBindingEnumerationMember.Create(Owner, Self, AEnumerations.Items[memberIndex].Value)); FMembers.Add(TXMLDataBindingEnumerationMember.Create(Owner, Self, AEnumerations.Items[memberIndex].Value));
end;
end; end;
@ -1974,6 +1986,18 @@ begin
end; end;
procedure TXMLDataBindingEnumeration.ReplaceMembers(AMembers: TEnumerable<TXMLDataBindingEnumerationMember>);
var
member: TXMLDataBindingEnumerationMember;
begin
FMembers.Clear;
for member in AMembers do
FMembers.Add(member);
end;
function TXMLDataBindingEnumeration.GetItemType: TXMLDataBindingItemType; function TXMLDataBindingEnumeration.GetItemType: TXMLDataBindingItemType;
begin begin
Result := itEnumeration; Result := itEnumeration;
@ -2048,7 +2072,7 @@ begin
end; end;
procedure TXMLDataBindingItemProperty.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure TXMLDataBindingItemProperty.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
begin begin
inherited; inherited;
@ -2085,7 +2109,7 @@ end;
{ TXMLDataBindingComplexTypeAliasItem } { TXMLDataBindingComplexTypeAliasItem }
procedure TXMLDataBindingComplexTypeAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); procedure TXMLDataBindingComplexTypeAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
begin begin
inherited; inherited;

View File

@ -59,6 +59,7 @@
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44> <UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150> <UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''"> <PropertyGroup Condition="'$(Base_Win64)'!=''">
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
@ -68,6 +69,7 @@
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44> <UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150> <UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''"> <PropertyGroup Condition="'$(Cfg_2)'!=''">
<Version>7.0</Version> <Version>7.0</Version>
@ -80,9 +82,14 @@
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale> <VerInfo_Locale>1033</VerInfo_Locale>
<BT_BuildType>Debug</BT_BuildType> <BT_BuildType>Debug</BT_BuildType>
<Debugger_RunParams>&quot;P:\sam\xsd\MBCPOS\masterupdatefile_v_2_7.xsd&quot;</Debugger_RunParams>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''"> <PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<BT_BuildType>Debug</BT_BuildType> <BT_BuildType>Debug</BT_BuildType>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality> <Borland.Personality>Delphi.Personality.12</Borland.Personality>
@ -125,6 +132,10 @@
<Source> <Source>
<Source Name="MainSource">X2XMLDataBinding.dpr</Source> <Source Name="MainSource">X2XMLDataBinding.dpr</Source>
</Source> </Source>
<Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k250.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp250.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Platforms> <Platforms>
<Platform value="Win32">True</Platform> <Platform value="Win32">True</Platform>

Binary file not shown.

View File

@ -1,10 +1,10 @@
[Stats] [Stats]
EditorSecs=37 EditorSecs=92
DesignerSecs=5 DesignerSecs=13
InspectorSecs=1 InspectorSecs=1
CompileSecs=620 CompileSecs=1741
OtherSecs=5 OtherSecs=40
StartTime=09/04/2020 10:52:32 StartTime=09/04/2020 10:52:32
RealKeys=0 RealKeys=0
EffectiveKeys=0 EffectiveKeys=0
DebugSecs=20 DebugSecs=71

View File

@ -25,6 +25,7 @@
</xs:sequence> </xs:sequence>
<xs:attribute name="Schema" type="xs:string" use="required"/> <xs:attribute name="Schema" type="xs:string" use="required"/>
<xs:attribute name="XPath" type="xs:string" use="required"/> <xs:attribute name="XPath" type="xs:string" use="required"/>
<xs:attribute name="ReplaceMembers" type="xs:boolean" use="optional"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>