Added support for changing string properties to enumerations
This commit is contained in:
parent
17043551f9
commit
3d5c2943fc
@ -48,7 +48,6 @@ object MainForm: TMainForm
|
||||
Anchors = [akLeft, akTop, akBottom]
|
||||
Caption = ' Output '
|
||||
TabOrder = 1
|
||||
ExplicitHeight = 204
|
||||
DesignSize = (
|
||||
422
|
||||
225)
|
||||
@ -83,6 +82,10 @@ object MainForm: TMainForm
|
||||
TabOrder = 2
|
||||
object spFile: TTabSheet
|
||||
TabVisible = False
|
||||
ExplicitLeft = 0
|
||||
ExplicitTop = 0
|
||||
ExplicitWidth = 0
|
||||
ExplicitHeight = 0
|
||||
object lblFile: TLabel
|
||||
Left = 4
|
||||
Top = 7
|
||||
@ -188,7 +191,6 @@ object MainForm: TMainForm
|
||||
Default = True
|
||||
TabOrder = 3
|
||||
OnClick = btnGenerateClick
|
||||
ExplicitTop = 258
|
||||
end
|
||||
object btnClose: TButton
|
||||
Left = 355
|
||||
@ -200,7 +202,6 @@ object MainForm: TMainForm
|
||||
Caption = '&Close'
|
||||
TabOrder = 4
|
||||
OnClick = btnCloseClick
|
||||
ExplicitTop = 258
|
||||
end
|
||||
object btnHints: TButton
|
||||
Left = 7
|
||||
@ -212,7 +213,6 @@ object MainForm: TMainForm
|
||||
Caption = 'Generate blank &Hints file'
|
||||
TabOrder = 2
|
||||
OnClick = btnHintsClick
|
||||
ExplicitTop = 258
|
||||
end
|
||||
object DefaultEditStyle: TcxDefaultEditStyleController
|
||||
Style.HotTrack = False
|
||||
|
@ -80,6 +80,7 @@ uses
|
||||
FileCtrl,
|
||||
SysUtils,
|
||||
Windows,
|
||||
Generics.Collections,
|
||||
|
||||
MSXMLDOM,
|
||||
MSXML2_TLB,
|
||||
@ -409,35 +410,96 @@ end;
|
||||
|
||||
|
||||
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
|
||||
itemIndex: Integer;
|
||||
enumeration: IXMLEnumeration;
|
||||
schemaItem: TXMLDataBindingItem;
|
||||
enumerationItem: TXMLDataBindingEnumeration;
|
||||
hintMemberIndex: Integer;
|
||||
memberName: String;
|
||||
memberIndex: Integer;
|
||||
propertyItem: TXMLDataBindingSimpleProperty;
|
||||
newMembers: TList<TXMLDataBindingEnumerationMember>;
|
||||
newPropertyItem: TXMLDataBindingItemProperty;
|
||||
|
||||
begin
|
||||
for itemIndex := 0 to Pred(Hints.Enumerations.Count) do
|
||||
begin
|
||||
enumeration := Hints.Enumerations[itemIndex];
|
||||
|
||||
if FindNode(enumeration.Schema, enumeration.XPath, schemaItem) and
|
||||
(schemaItem.ItemType = itEnumeration) then
|
||||
if FindNode(enumeration.Schema, enumeration.XPath, schemaItem) then
|
||||
begin
|
||||
case schemaItem.ItemType of
|
||||
itEnumeration:
|
||||
begin
|
||||
enumerationItem := TXMLDataBindingEnumeration(schemaItem);
|
||||
|
||||
for hintMemberIndex := 0 to Pred(enumeration.Count) do
|
||||
if enumeration.HasReplaceMembers and enumeration.ReplaceMembers then
|
||||
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
|
||||
if enumerationItem.Members[memberIndex].Name = memberName then
|
||||
propertyItem := TXMLDataBindingSimpleProperty(schemaItem);
|
||||
if propertyItem.DataType.Name = 'string' then
|
||||
begin
|
||||
enumerationItem.Members[memberIndex].TranslatedName := enumeration[hintMemberIndex].Text;
|
||||
Break;
|
||||
enumerationItem := TXMLDataBindingEnumeration.Create(Self, schemaItem.SchemaItem, nil, schemaItem.Name);
|
||||
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;
|
||||
|
@ -1,16 +1,18 @@
|
||||
{
|
||||
X2Software XML Data Binding
|
||||
|
||||
Generated on: 29-9-2009 14:31:13
|
||||
Generated from: P:\test\XMLDataBinding\XSD\DataBindingHints.xsd
|
||||
Generated on: 22/04/2020 11:59:03
|
||||
Generated from: P:\x2xmldatabinding\XSD\DataBindingHints.xsd
|
||||
}
|
||||
unit DataBindingHintsXML;
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes,
|
||||
SysUtils,
|
||||
XMLDoc,
|
||||
XMLIntf;
|
||||
XMLIntf,
|
||||
XMLDataBindingUtils;
|
||||
|
||||
type
|
||||
{ Forward declarations for DataBindingHints }
|
||||
@ -30,7 +32,8 @@ type
|
||||
Contains hints and mappings for the data binding output
|
||||
}
|
||||
IXMLDataBindingHints = interface(IXMLNode)
|
||||
['{434CBC09-8E33-4970-9C4A-535B4C898185}']
|
||||
['{8122E348-4BE1-4436-AD2A-DAFED0CFA0C4}']
|
||||
procedure XSDValidateDocument(AStrict: Boolean = False);
|
||||
function GetHasEnumerations: Boolean;
|
||||
function GetEnumerations: IXMLEnumerations;
|
||||
function GetHasDocumentElements: Boolean;
|
||||
@ -50,8 +53,18 @@ type
|
||||
property Properties: IXMLProperties read GetProperties;
|
||||
end;
|
||||
|
||||
IXMLEnumerationsEnumerator = interface
|
||||
['{725760E4-70A5-47A6-B91B-C240F1FADA60}']
|
||||
function GetCurrent: IXMLEnumeration;
|
||||
function MoveNext: Boolean;
|
||||
property Current: IXMLEnumeration read GetCurrent;
|
||||
end;
|
||||
|
||||
|
||||
IXMLEnumerations = interface(IXMLNodeCollection)
|
||||
['{115ECCB0-407B-476E-AA99-63F584F883F7}']
|
||||
['{509EAF84-A4BF-4F15-B77C-98B58792A9C3}']
|
||||
function GetEnumerator: IXMLEnumerationsEnumerator;
|
||||
|
||||
function Get_Enumeration(Index: Integer): IXMLEnumeration;
|
||||
function Add: IXMLEnumeration;
|
||||
function Insert(Index: Integer): IXMLEnumeration;
|
||||
@ -59,8 +72,21 @@ type
|
||||
property Enumeration[Index: Integer]: IXMLEnumeration read Get_Enumeration; default;
|
||||
end;
|
||||
|
||||
IXMLEnumerationEnumerator = interface
|
||||
['{8A1AF158-2AF3-49FB-9CFC-46897D8AF28C}']
|
||||
function GetCurrent: IXMLMember;
|
||||
function MoveNext: Boolean;
|
||||
property Current: IXMLMember read GetCurrent;
|
||||
end;
|
||||
|
||||
|
||||
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 Add: IXMLMember;
|
||||
function Insert(Index: Integer): IXMLMember;
|
||||
@ -69,29 +95,50 @@ type
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
function GetHasReplaceMembers: Boolean;
|
||||
function GetReplaceMembers: Boolean;
|
||||
|
||||
procedure SetSchema(const Value: WideString);
|
||||
procedure SetXPath(const Value: WideString);
|
||||
procedure SetReplaceMembers(const Value: Boolean);
|
||||
|
||||
property Schema: WideString read GetSchema write SetSchema;
|
||||
property XPath: WideString read GetXPath write SetXPath;
|
||||
property HasReplaceMembers: Boolean read GetHasReplaceMembers;
|
||||
property ReplaceMembers: Boolean read GetReplaceMembers write SetReplaceMembers;
|
||||
end;
|
||||
|
||||
IXMLMember = interface(IXMLNode)
|
||||
['{2575F0F6-EDCA-4CC6-B532-94833BCFAB64}']
|
||||
['{C58EF7F8-E182-47A3-B591-550A51AA0751}']
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetName: WideString;
|
||||
function GetValue: WideString;
|
||||
|
||||
procedure SetName(const Value: WideString);
|
||||
procedure SetValue(const Value: WideString);
|
||||
|
||||
property Name: WideString read GetName write SetName;
|
||||
property Value: WideString read GetValue write SetValue;
|
||||
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
|
||||
a Document Element.
|
||||
}
|
||||
IXMLDocumentElements = interface(IXMLNodeCollection)
|
||||
['{8D3A5543-68FF-4101-9874-639A39E33950}']
|
||||
['{D991E86F-3D42-4B05-BB90-10AF42324FE1}']
|
||||
function GetEnumerator: IXMLDocumentElementsEnumerator;
|
||||
|
||||
function Get_DocumentElement(Index: Integer): IXMLDocumentElement;
|
||||
function Add: IXMLDocumentElement;
|
||||
function Insert(Index: Integer): IXMLDocumentElement;
|
||||
@ -100,7 +147,10 @@ type
|
||||
end;
|
||||
|
||||
IXMLDocumentElement = interface(IXMLNode)
|
||||
['{3DFD0655-26DA-4237-ACEC-BB7CB3354DD2}']
|
||||
['{0FD90406-67B2-4076-870C-47DA8E8582ED}']
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
|
||||
@ -111,8 +161,18 @@ type
|
||||
property XPath: WideString read GetXPath write SetXPath;
|
||||
end;
|
||||
|
||||
IXMLInterfacesEnumerator = interface
|
||||
['{A1433E41-A316-4DBD-ADC2-7EA490CEFCB3}']
|
||||
function GetCurrent: IXMLInterfaceName;
|
||||
function MoveNext: Boolean;
|
||||
property Current: IXMLInterfaceName read GetCurrent;
|
||||
end;
|
||||
|
||||
|
||||
IXMLInterfaces = interface(IXMLNodeCollection)
|
||||
['{E70E67E3-C108-4015-B996-962D800BE555}']
|
||||
['{6A2EDBB5-36FE-4CA6-B3B9-1AC7A016E372}']
|
||||
function GetEnumerator: IXMLInterfacesEnumerator;
|
||||
|
||||
function Get_InterfaceName(Index: Integer): IXMLInterfaceName;
|
||||
function Add: IXMLInterfaceName;
|
||||
function Insert(Index: Integer): IXMLInterfaceName;
|
||||
@ -121,19 +181,35 @@ type
|
||||
end;
|
||||
|
||||
IXMLInterfaceName = interface(IXMLNode)
|
||||
['{2B8126E7-2F89-4E5D-89E3-4F5F7AEE35E9}']
|
||||
['{F0057FA9-92D8-47C5-AC29-6A045595B7F0}']
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
function GetValue: WideString;
|
||||
|
||||
procedure SetSchema(const Value: WideString);
|
||||
procedure SetXPath(const Value: WideString);
|
||||
procedure SetValue(const Value: WideString);
|
||||
|
||||
property Schema: WideString read GetSchema write SetSchema;
|
||||
property XPath: WideString read GetXPath write SetXPath;
|
||||
property Value: WideString read GetValue write SetValue;
|
||||
end;
|
||||
|
||||
IXMLPropertiesEnumerator = interface
|
||||
['{4FDE9618-2177-4D53-8B14-5E81E397E084}']
|
||||
function GetCurrent: IXMLPropertyName;
|
||||
function MoveNext: Boolean;
|
||||
property Current: IXMLPropertyName read GetCurrent;
|
||||
end;
|
||||
|
||||
|
||||
IXMLProperties = interface(IXMLNodeCollection)
|
||||
['{88260AE1-1C40-4F0F-AA44-C61EDAA53B38}']
|
||||
['{38320F29-9D8C-4158-B0F6-8E1D1FD31EB9}']
|
||||
function GetEnumerator: IXMLPropertiesEnumerator;
|
||||
|
||||
function Get_PropertyName(Index: Integer): IXMLPropertyName;
|
||||
function Add: IXMLPropertyName;
|
||||
function Insert(Index: Integer): IXMLPropertyName;
|
||||
@ -142,7 +218,10 @@ type
|
||||
end;
|
||||
|
||||
IXMLPropertyName = interface(IXMLNode)
|
||||
['{DB714E5D-E62B-44C4-B7D4-0623887BCDF6}']
|
||||
['{F99D3125-B2DE-4A4A-88D0-DBCB50C75C59}']
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
|
||||
@ -155,10 +234,11 @@ type
|
||||
|
||||
|
||||
{ Classes for DataBindingHints }
|
||||
TXMLDataBindingHints = class(TXMLNode, IXMLDataBindingHints)
|
||||
TXMLDataBindingHints = class(TX2XMLNode, IXMLDataBindingHints)
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
protected
|
||||
procedure XSDValidateDocument(AStrict: Boolean = False);
|
||||
function GetHasEnumerations: Boolean;
|
||||
function GetEnumerations: IXMLEnumerations;
|
||||
function GetHasDocumentElements: Boolean;
|
||||
@ -169,48 +249,86 @@ type
|
||||
function GetProperties: IXMLProperties;
|
||||
end;
|
||||
|
||||
TXMLEnumerations = class(TXMLNodeCollection, IXMLEnumerations)
|
||||
TXMLEnumerationsEnumerator = class(TXMLNodeCollectionEnumerator, IXMLEnumerationsEnumerator)
|
||||
protected
|
||||
function GetCurrent: IXMLEnumeration;
|
||||
end;
|
||||
|
||||
|
||||
TXMLEnumerations = class(TX2XMLNodeCollection, IXMLEnumerations)
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
protected
|
||||
function GetEnumerator: IXMLEnumerationsEnumerator;
|
||||
|
||||
function Get_Enumeration(Index: Integer): IXMLEnumeration;
|
||||
function Add: IXMLEnumeration;
|
||||
function Insert(Index: Integer): IXMLEnumeration;
|
||||
end;
|
||||
|
||||
TXMLEnumeration = class(TXMLNodeCollection, IXMLEnumeration)
|
||||
TXMLEnumerationEnumerator = class(TXMLNodeCollectionEnumerator, IXMLEnumerationEnumerator)
|
||||
protected
|
||||
function GetCurrent: IXMLMember;
|
||||
end;
|
||||
|
||||
|
||||
TXMLEnumeration = class(TX2XMLNodeCollection, IXSDValidate, IXSDValidateStrict, IXMLEnumeration)
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
protected
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetEnumerator: IXMLEnumerationEnumerator;
|
||||
|
||||
function Get_Member(Index: Integer): IXMLMember;
|
||||
function Add: IXMLMember;
|
||||
function Insert(Index: Integer): IXMLMember;
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
function GetHasReplaceMembers: Boolean;
|
||||
function GetReplaceMembers: Boolean;
|
||||
|
||||
procedure SetSchema(const Value: WideString);
|
||||
procedure SetXPath(const Value: WideString);
|
||||
procedure SetReplaceMembers(const Value: Boolean);
|
||||
end;
|
||||
|
||||
TXMLMember = class(TXMLNode, IXMLMember)
|
||||
TXMLMember = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLMember)
|
||||
protected
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetName: WideString;
|
||||
function GetValue: WideString;
|
||||
|
||||
procedure SetName(const Value: WideString);
|
||||
procedure SetValue(const Value: WideString);
|
||||
end;
|
||||
|
||||
TXMLDocumentElements = class(TXMLNodeCollection, IXMLDocumentElements)
|
||||
TXMLDocumentElementsEnumerator = class(TXMLNodeCollectionEnumerator, IXMLDocumentElementsEnumerator)
|
||||
protected
|
||||
function GetCurrent: IXMLDocumentElement;
|
||||
end;
|
||||
|
||||
|
||||
TXMLDocumentElements = class(TX2XMLNodeCollection, IXMLDocumentElements)
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
protected
|
||||
function GetEnumerator: IXMLDocumentElementsEnumerator;
|
||||
|
||||
function Get_DocumentElement(Index: Integer): IXMLDocumentElement;
|
||||
function Add: IXMLDocumentElement;
|
||||
function Insert(Index: Integer): IXMLDocumentElement;
|
||||
end;
|
||||
|
||||
TXMLDocumentElement = class(TXMLNode, IXMLDocumentElement)
|
||||
TXMLDocumentElement = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLDocumentElement)
|
||||
protected
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
|
||||
@ -218,35 +336,59 @@ type
|
||||
procedure SetXPath(const Value: WideString);
|
||||
end;
|
||||
|
||||
TXMLInterfaces = class(TXMLNodeCollection, IXMLInterfaces)
|
||||
TXMLInterfacesEnumerator = class(TXMLNodeCollectionEnumerator, IXMLInterfacesEnumerator)
|
||||
protected
|
||||
function GetCurrent: IXMLInterfaceName;
|
||||
end;
|
||||
|
||||
|
||||
TXMLInterfaces = class(TX2XMLNodeCollection, IXMLInterfaces)
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
protected
|
||||
function GetEnumerator: IXMLInterfacesEnumerator;
|
||||
|
||||
function Get_InterfaceName(Index: Integer): IXMLInterfaceName;
|
||||
function Add: IXMLInterfaceName;
|
||||
function Insert(Index: Integer): IXMLInterfaceName;
|
||||
end;
|
||||
|
||||
TXMLInterfaceName = class(TXMLNode, IXMLInterfaceName)
|
||||
TXMLInterfaceName = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLInterfaceName)
|
||||
protected
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
function GetValue: WideString;
|
||||
|
||||
procedure SetSchema(const Value: WideString);
|
||||
procedure SetXPath(const Value: WideString);
|
||||
procedure SetValue(const Value: WideString);
|
||||
end;
|
||||
|
||||
TXMLProperties = class(TXMLNodeCollection, IXMLProperties)
|
||||
TXMLPropertiesEnumerator = class(TXMLNodeCollectionEnumerator, IXMLPropertiesEnumerator)
|
||||
protected
|
||||
function GetCurrent: IXMLPropertyName;
|
||||
end;
|
||||
|
||||
|
||||
TXMLProperties = class(TX2XMLNodeCollection, IXMLProperties)
|
||||
public
|
||||
procedure AfterConstruction; override;
|
||||
protected
|
||||
function GetEnumerator: IXMLPropertiesEnumerator;
|
||||
|
||||
function Get_PropertyName(Index: Integer): IXMLPropertyName;
|
||||
function Add: IXMLPropertyName;
|
||||
function Insert(Index: Integer): IXMLPropertyName;
|
||||
end;
|
||||
|
||||
TXMLPropertyName = class(TXMLNode, IXMLPropertyName)
|
||||
TXMLPropertyName = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLPropertyName)
|
||||
protected
|
||||
procedure XSDValidate;
|
||||
procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);
|
||||
|
||||
function GetSchema: WideString;
|
||||
function GetXPath: WideString;
|
||||
|
||||
@ -259,6 +401,7 @@ type
|
||||
function GetDataBindingHints(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingHints;
|
||||
function LoadDataBindingHints(const AFileName: String): 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;
|
||||
|
||||
|
||||
@ -268,7 +411,7 @@ const
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils;
|
||||
Variants;
|
||||
|
||||
{ Document functions }
|
||||
function GetDataBindingHints(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingHints;
|
||||
@ -291,6 +434,24 @@ begin
|
||||
Result := GetDataBindingHints(doc);
|
||||
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;
|
||||
begin
|
||||
Result := NewXMLDocument.GetDocBinding('DataBindingHints', TXMLDataBindingHints, TargetNamespace) as IXMLDataBindingHints
|
||||
@ -308,6 +469,14 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TXMLDataBindingHints.XSDValidateDocument(AStrict: Boolean);
|
||||
begin
|
||||
if AStrict then
|
||||
XMLDataBindingUtils.XSDValidateStrict(Self)
|
||||
else
|
||||
XMLDataBindingUtils.XSDValidate(Self);
|
||||
end;
|
||||
|
||||
function TXMLDataBindingHints.GetHasEnumerations: Boolean;
|
||||
begin
|
||||
Result := Assigned(ChildNodes.FindNode('Enumerations'));
|
||||
@ -352,6 +521,11 @@ begin
|
||||
Result := (ChildNodes['Properties'] as IXMLProperties);
|
||||
end;
|
||||
|
||||
function TXMLEnumerationsEnumerator.GetCurrent: IXMLEnumeration;
|
||||
begin
|
||||
Result := (inherited GetCurrent as IXMLEnumeration);
|
||||
end;
|
||||
|
||||
procedure TXMLEnumerations.AfterConstruction;
|
||||
begin
|
||||
RegisterChildNode('Enumeration', TXMLEnumeration);
|
||||
@ -362,6 +536,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TXMLEnumerations.GetEnumerator: IXMLEnumerationsEnumerator;
|
||||
begin
|
||||
Result := TXMLEnumerationsEnumerator.Create(Self);
|
||||
end;
|
||||
|
||||
function TXMLEnumerations.Get_Enumeration(Index: Integer): IXMLEnumeration;
|
||||
begin
|
||||
Result := (List[Index] as IXMLEnumeration);
|
||||
@ -377,6 +556,11 @@ begin
|
||||
Result := (AddItem(Index) as IXMLEnumeration);
|
||||
end;
|
||||
|
||||
function TXMLEnumerationEnumerator.GetCurrent: IXMLMember;
|
||||
begin
|
||||
Result := (inherited GetCurrent as IXMLMember);
|
||||
end;
|
||||
|
||||
procedure TXMLEnumeration.AfterConstruction;
|
||||
begin
|
||||
RegisterChildNode('Member', TXMLMember);
|
||||
@ -387,6 +571,21 @@ begin
|
||||
inherited;
|
||||
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;
|
||||
begin
|
||||
Result := (List[Index] as IXMLMember);
|
||||
@ -412,14 +611,40 @@ begin
|
||||
Result := AttributeNodes['XPath'].Text;
|
||||
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);
|
||||
begin
|
||||
SetAttribute('Schema', Value);
|
||||
SetAttribute('Schema', GetValidXMLText(Value));
|
||||
end;
|
||||
|
||||
procedure TXMLEnumeration.SetXPath(const Value: WideString);
|
||||
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;
|
||||
|
||||
function TXMLMember.GetName: WideString;
|
||||
@ -427,9 +652,24 @@ begin
|
||||
Result := AttributeNodes['Name'].Text;
|
||||
end;
|
||||
|
||||
function TXMLMember.GetValue: WideString;
|
||||
begin
|
||||
Result := VarToStr(GetNodeValue);
|
||||
end;
|
||||
|
||||
procedure TXMLMember.SetName(const Value: WideString);
|
||||
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;
|
||||
|
||||
procedure TXMLDocumentElements.AfterConstruction;
|
||||
@ -442,6 +682,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TXMLDocumentElements.GetEnumerator: IXMLDocumentElementsEnumerator;
|
||||
begin
|
||||
Result := TXMLDocumentElementsEnumerator.Create(Self);
|
||||
end;
|
||||
|
||||
function TXMLDocumentElements.Get_DocumentElement(Index: Integer): IXMLDocumentElement;
|
||||
begin
|
||||
Result := (List[Index] as IXMLDocumentElement);
|
||||
@ -457,6 +702,16 @@ begin
|
||||
Result := (AddItem(Index) as IXMLDocumentElement);
|
||||
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;
|
||||
begin
|
||||
Result := AttributeNodes['Schema'].Text;
|
||||
@ -469,12 +724,17 @@ end;
|
||||
|
||||
procedure TXMLDocumentElement.SetSchema(const Value: WideString);
|
||||
begin
|
||||
SetAttribute('Schema', Value);
|
||||
SetAttribute('Schema', GetValidXMLText(Value));
|
||||
end;
|
||||
|
||||
procedure TXMLDocumentElement.SetXPath(const Value: WideString);
|
||||
begin
|
||||
SetAttribute('XPath', Value);
|
||||
SetAttribute('XPath', GetValidXMLText(Value));
|
||||
end;
|
||||
|
||||
function TXMLInterfacesEnumerator.GetCurrent: IXMLInterfaceName;
|
||||
begin
|
||||
Result := (inherited GetCurrent as IXMLInterfaceName);
|
||||
end;
|
||||
|
||||
procedure TXMLInterfaces.AfterConstruction;
|
||||
@ -487,6 +747,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TXMLInterfaces.GetEnumerator: IXMLInterfacesEnumerator;
|
||||
begin
|
||||
Result := TXMLInterfacesEnumerator.Create(Self);
|
||||
end;
|
||||
|
||||
function TXMLInterfaces.Get_InterfaceName(Index: Integer): IXMLInterfaceName;
|
||||
begin
|
||||
Result := (List[Index] as IXMLInterfaceName);
|
||||
@ -502,6 +767,16 @@ begin
|
||||
Result := (AddItem(Index) as IXMLInterfaceName);
|
||||
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;
|
||||
begin
|
||||
Result := AttributeNodes['Schema'].Text;
|
||||
@ -512,14 +787,29 @@ begin
|
||||
Result := AttributeNodes['XPath'].Text;
|
||||
end;
|
||||
|
||||
function TXMLInterfaceName.GetValue: WideString;
|
||||
begin
|
||||
Result := VarToStr(GetNodeValue);
|
||||
end;
|
||||
|
||||
procedure TXMLInterfaceName.SetSchema(const Value: WideString);
|
||||
begin
|
||||
SetAttribute('Schema', Value);
|
||||
SetAttribute('Schema', GetValidXMLText(Value));
|
||||
end;
|
||||
|
||||
procedure TXMLInterfaceName.SetXPath(const Value: WideString);
|
||||
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;
|
||||
|
||||
procedure TXMLProperties.AfterConstruction;
|
||||
@ -532,6 +822,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TXMLProperties.GetEnumerator: IXMLPropertiesEnumerator;
|
||||
begin
|
||||
Result := TXMLPropertiesEnumerator.Create(Self);
|
||||
end;
|
||||
|
||||
function TXMLProperties.Get_PropertyName(Index: Integer): IXMLPropertyName;
|
||||
begin
|
||||
Result := (List[Index] as IXMLPropertyName);
|
||||
@ -547,6 +842,16 @@ begin
|
||||
Result := (AddItem(Index) as IXMLPropertyName);
|
||||
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;
|
||||
begin
|
||||
Result := AttributeNodes['Schema'].Text;
|
||||
@ -559,12 +864,12 @@ end;
|
||||
|
||||
procedure TXMLPropertyName.SetSchema(const Value: WideString);
|
||||
begin
|
||||
SetAttribute('Schema', Value);
|
||||
SetAttribute('Schema', GetValidXMLText(Value));
|
||||
end;
|
||||
|
||||
procedure TXMLPropertyName.SetXPath(const Value: WideString);
|
||||
begin
|
||||
SetAttribute('XPath', Value);
|
||||
SetAttribute('XPath', GetValidXMLText(Value));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ type
|
||||
function FindInterface(ASchema: TXMLDataBindingSchema; const AName: String; AType: TXMLDataBindingInterfaceType): TXMLDataBindingInterface;
|
||||
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 ResolveAlias(ASchema: TXMLDataBindingSchema);
|
||||
@ -113,7 +113,7 @@ type
|
||||
private
|
||||
FOwner: TXMLDataBindingGenerator;
|
||||
protected
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); virtual;
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); virtual;
|
||||
|
||||
property Owner: TXMLDataBindingGenerator read FOwner;
|
||||
public
|
||||
@ -136,7 +136,7 @@ type
|
||||
function GetIncludes(Index: Integer): TXMLDataBindingSchema;
|
||||
function GetTargetNamespace: String;
|
||||
protected
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); override;
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
|
||||
|
||||
procedure AddInclude(ASchema: TXMLDataBindingSchema);
|
||||
procedure AddItem(AItem: TXMLDataBindingItem);
|
||||
@ -177,12 +177,11 @@ type
|
||||
protected
|
||||
function GetItemType: TXMLDataBindingItemType; virtual; abstract;
|
||||
procedure SetName(const Value: String);
|
||||
|
||||
property SchemaItem: IXMLSchemaItem read FSchemaItem;
|
||||
public
|
||||
constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; const AName: String);
|
||||
|
||||
property Schema: TXMLDataBindingSchema read FSchema write FSchema;
|
||||
property SchemaItem: IXMLSchemaItem read FSchemaItem;
|
||||
property TargetNamespace: String read FTargetNamespace write FTargetNamespace;
|
||||
|
||||
property DocumentElement: Boolean read FDocumentElement write FDocumentElement;
|
||||
@ -211,7 +210,7 @@ type
|
||||
protected
|
||||
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);
|
||||
public
|
||||
@ -251,9 +250,11 @@ type
|
||||
protected
|
||||
function GetItemType: TXMLDataBindingItemType; override;
|
||||
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;
|
||||
|
||||
procedure ReplaceMembers(AMembers: TEnumerable<TXMLDataBindingEnumerationMember>);
|
||||
|
||||
property MemberCount: Integer read GetMemberCount;
|
||||
property Members[Index: Integer]: TXMLDataBindingEnumerationMember read GetMembers;
|
||||
end;
|
||||
@ -309,7 +310,7 @@ type
|
||||
function GetIsReadOnly: Boolean; override;
|
||||
function GetPropertyType: TXMLDataBindingPropertyType; override;
|
||||
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); override;
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
|
||||
public
|
||||
constructor Create(AOwner: TXMLDataBindingGenerator; ASchemaItem: IXMLSchemaItem; const AName: String; AItem: TXMLDataBindingItem);
|
||||
|
||||
@ -335,7 +336,7 @@ type
|
||||
protected
|
||||
function GetItemType: TXMLDataBindingItemType; override;
|
||||
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem); override;
|
||||
procedure ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean); override;
|
||||
public
|
||||
property Item: TXMLDataBindingItem read FItem write FItem;
|
||||
end;
|
||||
@ -1233,13 +1234,13 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TXMLDataBindingGenerator.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
procedure TXMLDataBindingGenerator.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
|
||||
var
|
||||
schemaIndex: Integer;
|
||||
|
||||
begin
|
||||
for schemaIndex := Pred(SchemaCount) downto 0 do
|
||||
Schemas[schemaIndex].ReplaceItem(AOldItem, ANewItem);
|
||||
Schemas[schemaIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
|
||||
end;
|
||||
|
||||
|
||||
@ -1304,7 +1305,7 @@ begin
|
||||
interfaceItem.BaseName := complexAliasItem.Item.Name;
|
||||
ASchema.AddItem(interfaceItem);
|
||||
|
||||
ReplaceItem(complexAliasItem, interfaceItem);
|
||||
ReplaceItem(complexAliasItem, interfaceItem, True);
|
||||
FreeAndNil(complexAliasItem);
|
||||
end;
|
||||
end;
|
||||
@ -1314,7 +1315,7 @@ begin
|
||||
{ Remove the alias element - TXMLDataBindingInterfaceItem.ReplaceItem
|
||||
will take care of fixing it's properties. }
|
||||
simpleAliasItem := TXMLDataBindingSimpleTypeAliasItem(item);
|
||||
ReplaceItem(simpleAliasItem, nil);
|
||||
ReplaceItem(simpleAliasItem, nil, True);
|
||||
FreeAndNil(simpleAliasItem);
|
||||
end;
|
||||
end;
|
||||
@ -1353,7 +1354,7 @@ begin
|
||||
end;
|
||||
|
||||
if Assigned(referenceItem) then
|
||||
ReplaceItem(AItem, referenceItem)
|
||||
ReplaceItem(AItem, referenceItem, True)
|
||||
else
|
||||
raise EXMLDataBindingUnresolvedItem.CreateFmt('Unresolved %s: %s',
|
||||
[GetEnumName(TypeInfo(TXMLDataBindingInterfaceType), Ord(AItem.InterfaceType)),
|
||||
@ -1639,7 +1640,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TXMLDataBindingGeneratorItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
procedure TXMLDataBindingGeneratorItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
@ -1663,7 +1664,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TXMLDataBindingSchema.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
procedure TXMLDataBindingSchema.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
|
||||
var
|
||||
itemIndex: Integer;
|
||||
|
||||
@ -1672,9 +1673,13 @@ begin
|
||||
|
||||
for itemIndex := Pred(ItemCount) downto 0 do
|
||||
if Items[itemIndex] = AOldItem then
|
||||
begin
|
||||
if ARemoveOnly then
|
||||
FItems.Extract(AOldItem)
|
||||
else
|
||||
Items[itemIndex].ReplaceItem(AOldItem, ANewItem);
|
||||
FItems[itemIndex] := ANewItem;
|
||||
end else
|
||||
Items[itemIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
|
||||
end;
|
||||
|
||||
|
||||
@ -1829,7 +1834,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
|
||||
var
|
||||
propertyIndex: Integer;
|
||||
propertyItem: TXMLDataBindingProperty;
|
||||
@ -1846,8 +1851,12 @@ begin
|
||||
propertyItem := Properties[propertyIndex];
|
||||
|
||||
if propertyItem = AOldItem then
|
||||
begin
|
||||
if ARemoveOnly then
|
||||
FProperties.Extract(propertyItem)
|
||||
else
|
||||
FProperties[propertyIndex] := ANewItem as TXMLDataBindingProperty;
|
||||
end else
|
||||
begin
|
||||
if (AOldItem.ItemType = itSimpleTypeAlias) and
|
||||
(propertyItem.PropertyType = ptItem) then
|
||||
@ -1862,9 +1871,9 @@ begin
|
||||
{ FProperties owns itemProperty and will free it }
|
||||
FProperties[propertyIndex] := simpleProperty;
|
||||
end else
|
||||
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem);
|
||||
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
|
||||
end else
|
||||
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem);
|
||||
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem, ARemoveOnly);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1961,8 +1970,11 @@ begin
|
||||
|
||||
FMembers := TObjectList<TXMLDataBindingEnumerationMember>.Create;
|
||||
|
||||
if Assigned(AEnumerations) then
|
||||
begin
|
||||
for memberIndex := 0 to Pred(AEnumerations.Count) do
|
||||
FMembers.Add(TXMLDataBindingEnumerationMember.Create(Owner, Self, AEnumerations.Items[memberIndex].Value));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -1974,6 +1986,18 @@ begin
|
||||
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;
|
||||
begin
|
||||
Result := itEnumeration;
|
||||
@ -2048,7 +2072,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TXMLDataBindingItemProperty.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
procedure TXMLDataBindingItemProperty.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
@ -2085,7 +2109,7 @@ end;
|
||||
|
||||
|
||||
{ TXMLDataBindingComplexTypeAliasItem }
|
||||
procedure TXMLDataBindingComplexTypeAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
procedure TXMLDataBindingComplexTypeAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem; ARemoveOnly: Boolean);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
|
@ -59,6 +59,7 @@
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<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>
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base_Win64)'!=''">
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
@ -68,6 +69,7 @@
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<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>
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<Version>7.0</Version>
|
||||
@ -80,9 +82,14 @@
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
<Debugger_RunParams>"P:\sam\xsd\MBCPOS\masterupdatefile_v_2_7.xsd"</Debugger_RunParams>
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
|
||||
<BT_BuildType>Debug</BT_BuildType>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
|
||||
</PropertyGroup>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
@ -125,6 +132,10 @@
|
||||
<Source>
|
||||
<Source Name="MainSource">X2XMLDataBinding.dpr</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>
|
||||
<Platforms>
|
||||
<Platform value="Win32">True</Platform>
|
||||
|
Binary file not shown.
@ -1,10 +1,10 @@
|
||||
[Stats]
|
||||
EditorSecs=37
|
||||
DesignerSecs=5
|
||||
EditorSecs=92
|
||||
DesignerSecs=13
|
||||
InspectorSecs=1
|
||||
CompileSecs=620
|
||||
OtherSecs=5
|
||||
CompileSecs=1741
|
||||
OtherSecs=40
|
||||
StartTime=09/04/2020 10:52:32
|
||||
RealKeys=0
|
||||
EffectiveKeys=0
|
||||
DebugSecs=20
|
||||
DebugSecs=71
|
||||
|
@ -25,6 +25,7 @@
|
||||
</xs:sequence>
|
||||
<xs:attribute name="Schema" 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:element>
|
||||
</xs:sequence>
|
||||
|
Loading…
Reference in New Issue
Block a user