Merged last changes into trunk
This commit is contained in:
parent
e402505cbb
commit
0c38a497f9
@ -318,11 +318,29 @@ end;
|
|||||||
|
|
||||||
function TDelphiXMLDataBindingGenerator.DelphiSafeName(const AName: String): String;
|
function TDelphiXMLDataBindingGenerator.DelphiSafeName(const AName: String): String;
|
||||||
var
|
var
|
||||||
|
charIndex: Integer;
|
||||||
wordIndex: Integer;
|
wordIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := AName;
|
Result := AName;
|
||||||
|
|
||||||
|
|
||||||
|
{ Remove unsafe characters }
|
||||||
|
for charIndex := Length(Result) downto 1 do
|
||||||
|
begin
|
||||||
|
if not (Result[charIndex] in SafeChars) then
|
||||||
|
Delete(Result, charIndex, 1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
if Length(Result) > 0 then
|
||||||
|
begin
|
||||||
|
{ Number as the first character is not allowed }
|
||||||
|
if Result[1] in ['0'..'9'] then
|
||||||
|
Result := '_' + Result;
|
||||||
|
|
||||||
|
|
||||||
|
{ Check for reserved words }
|
||||||
for wordIndex := Low(ReservedWords) to High(ReservedWords) do
|
for wordIndex := Low(ReservedWords) to High(ReservedWords) do
|
||||||
begin
|
begin
|
||||||
if Result = ReservedWords[wordIndex] then
|
if Result = ReservedWords[wordIndex] then
|
||||||
@ -331,6 +349,7 @@ begin
|
|||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,6 +158,8 @@ const
|
|||||||
'virtual', 'while', 'with', 'write', 'writeonly', 'xor'
|
'virtual', 'while', 'with', 'write', 'writeonly', 'xor'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SafeChars = ['A'..'Z', 'a'..'z', '0'..'9', '_', '-'];
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TTypeConversion = (tcNone, tcBoolean, tcFloat, tcDateTime);
|
TTypeConversion = (tcNone, tcBoolean, tcFloat, tcDateTime);
|
||||||
|
@ -19,7 +19,8 @@ type
|
|||||||
|
|
||||||
TXMLDataBindingOutputType = (otSingle, otMultiple);
|
TXMLDataBindingOutputType = (otSingle, otMultiple);
|
||||||
TXMLDataBindingItemType = (itInterface, itEnumeration, itEnumerationMember,
|
TXMLDataBindingItemType = (itInterface, itEnumeration, itEnumerationMember,
|
||||||
itProperty, itUnresolved, itAlias);
|
itProperty, itUnresolved,
|
||||||
|
itComplexTypeAlias, itSimpleTypeAlias);
|
||||||
TXMLDataBindingInterfaceType = (ifElement, ifComplexType);
|
TXMLDataBindingInterfaceType = (ifElement, ifComplexType);
|
||||||
TXMLDataBindingPropertyType = (ptSimple, ptItem);
|
TXMLDataBindingPropertyType = (ptSimple, ptItem);
|
||||||
TXMLDataBindingOccurance = (boMinOccurs, boMaxOccurs);
|
TXMLDataBindingOccurance = (boMinOccurs, boMaxOccurs);
|
||||||
@ -300,7 +301,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
TXMLDataBindingAliasItem = class(TXMLDataBindingItem)
|
TXMLDataBindingComplexTypeAliasItem = class(TXMLDataBindingItem)
|
||||||
private
|
private
|
||||||
FItem: TXMLDataBindingItem;
|
FItem: TXMLDataBindingItem;
|
||||||
protected
|
protected
|
||||||
@ -312,6 +313,16 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
TXMLDataBindingSimpleTypeAliasItem = class(TXMLDataBindingItem)
|
||||||
|
private
|
||||||
|
FDataType: IXMLTypeDef;
|
||||||
|
protected
|
||||||
|
function GetItemType(): TXMLDataBindingItemType; override;
|
||||||
|
public
|
||||||
|
property DataType: IXMLTypeDef read FDataType write FDataType;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
SysUtils,
|
SysUtils,
|
||||||
@ -587,7 +598,12 @@ begin
|
|||||||
for complexTypeIndex := 0 to Pred(schemaDef.ComplexTypes.Count) do
|
for complexTypeIndex := 0 to Pred(schemaDef.ComplexTypes.Count) do
|
||||||
begin
|
begin
|
||||||
complexType := schemaDef.ComplexTypes[complexTypeIndex];
|
complexType := schemaDef.ComplexTypes[complexTypeIndex];
|
||||||
|
|
||||||
interfaceItem := TXMLDataBindingInterface.Create(Self, complexType, complexType.Name);
|
interfaceItem := TXMLDataBindingInterface.Create(Self, complexType, complexType.Name);
|
||||||
|
|
||||||
|
if complexType.DerivationMethod <> dmNone then
|
||||||
|
interfaceItem.BaseName := complexType.BaseTypeName;
|
||||||
|
|
||||||
ASchema.AddItem(interfaceItem);
|
ASchema.AddItem(interfaceItem);
|
||||||
|
|
||||||
for elementIndex := 0 to Pred(complexType.ElementDefs.Count) do
|
for elementIndex := 0 to Pred(complexType.ElementDefs.Count) do
|
||||||
@ -664,7 +680,8 @@ var
|
|||||||
attributeIndex: Integer;
|
attributeIndex: Integer;
|
||||||
enumerationObject: TXMLDataBindingEnumeration;
|
enumerationObject: TXMLDataBindingEnumeration;
|
||||||
interfaceObject: TXMLDataBindingInterface;
|
interfaceObject: TXMLDataBindingInterface;
|
||||||
aliasItem: TXMLDataBindingAliasItem;
|
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
|
||||||
|
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
@ -682,8 +699,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if (not AElement.DataType.IsAnonymous) and
|
if not AElement.DataType.IsAnonymous then
|
||||||
AElement.DataType.IsComplex then
|
begin
|
||||||
|
if AElement.DataType.IsComplex then
|
||||||
begin
|
begin
|
||||||
{ Find data type. If not found, mark as "resolve later". }
|
{ Find data type. If not found, mark as "resolve later". }
|
||||||
Result := FindInterface(ASchema, AElement.DataTypeName, ifComplexType);
|
Result := FindInterface(ASchema, AElement.DataTypeName, ifComplexType);
|
||||||
@ -698,9 +716,18 @@ begin
|
|||||||
begin
|
begin
|
||||||
{ The element is global, but only references a complex type. Keep track
|
{ The element is global, but only references a complex type. Keep track
|
||||||
to properly resolve references to the element. }
|
to properly resolve references to the element. }
|
||||||
aliasItem := TXMLDataBindingAliasItem.Create(Self, AElement, AElement.Name);
|
complexAliasItem := TXMLDataBindingComplexTypeAliasItem.Create(Self, AElement, AElement.Name);
|
||||||
aliasItem.Item := Result;
|
complexAliasItem.Item := Result;
|
||||||
ASchema.AddItem(aliasItem);
|
ASchema.AddItem(complexAliasItem);
|
||||||
|
end;
|
||||||
|
end else if AElement.IsGlobal then
|
||||||
|
begin
|
||||||
|
{ The element is global, but only references a simple type. }
|
||||||
|
simpleAliasItem := TXMLDataBindingSimpleTypeAliasItem.Create(Self, AElement, AElement.Name);
|
||||||
|
simpleAliasItem.DataType := AElement.DataType;
|
||||||
|
ASchema.AddItem(simpleAliasItem);
|
||||||
|
|
||||||
|
Result := simpleAliasItem;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -840,7 +867,8 @@ begin
|
|||||||
itInterface:
|
itInterface:
|
||||||
AAbort := (TXMLDataBindingInterface(AItem).InterfaceType = findInfo^.InterfaceType);
|
AAbort := (TXMLDataBindingInterface(AItem).InterfaceType = findInfo^.InterfaceType);
|
||||||
|
|
||||||
itAlias:
|
itComplexTypeAlias,
|
||||||
|
itSimpleTypeAlias:
|
||||||
AAbort := (findInfo^.InterfaceType = ifElement);
|
AAbort := (findInfo^.InterfaceType = ifElement);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -914,18 +942,34 @@ procedure TXMLDataBindingGenerator.ResolveAlias(ASchema: TXMLDataBindingSchema);
|
|||||||
var
|
var
|
||||||
itemIndex: Integer;
|
itemIndex: Integer;
|
||||||
item: TXMLDataBindingItem;
|
item: TXMLDataBindingItem;
|
||||||
aliasItem: TXMLDataBindingAliasItem;
|
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
|
||||||
|
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
for itemIndex := Pred(ASchema.ItemCount) downto 0 do
|
for itemIndex := Pred(ASchema.ItemCount) downto 0 do
|
||||||
begin
|
begin
|
||||||
item := ASchema.Items[itemIndex];
|
item := ASchema.Items[itemIndex];
|
||||||
|
|
||||||
if item.ItemType = itAlias then
|
case item.ItemType of
|
||||||
|
itComplexTypeAlias:
|
||||||
begin
|
begin
|
||||||
aliasItem := TXMLDataBindingAliasItem(item);
|
{ Replace alias element with the actual complex type }
|
||||||
if Assigned(aliasItem.Item) then
|
complexAliasItem := TXMLDataBindingComplexTypeAliasItem(item);
|
||||||
ReplaceItem(aliasItem, aliasItem.Item);
|
if Assigned(complexAliasItem.Item) then
|
||||||
|
begin
|
||||||
|
ReplaceItem(complexAliasItem, complexAliasItem.Item);
|
||||||
|
FreeAndNil(complexAliasItem);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
itSimpleTypeAlias:
|
||||||
|
begin
|
||||||
|
{ Remove the alias element - TXMLDataBindingInterfaceItem.ReplaceItem
|
||||||
|
will take care of fixing it's properties. }
|
||||||
|
simpleAliasItem := TXMLDataBindingSimpleTypeAliasItem(item);
|
||||||
|
ReplaceItem(simpleAliasItem, nil);
|
||||||
|
FreeAndNil(simpleAliasItem);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1372,12 +1416,42 @@ end;
|
|||||||
procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||||
var
|
var
|
||||||
propertyIndex: Integer;
|
propertyIndex: Integer;
|
||||||
|
propertyItem: TXMLDataBindingProperty;
|
||||||
|
itemProperty: TXMLDataBindingItemProperty;
|
||||||
|
simpleProperty: TXMLDataBindingSimpleProperty;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
for propertyIndex := Pred(PropertyCount) downto 0 do
|
for propertyIndex := Pred(PropertyCount) downto 0 do
|
||||||
|
begin
|
||||||
|
propertyItem := Properties[propertyIndex];
|
||||||
|
|
||||||
|
if propertyItem = AOldItem then
|
||||||
|
FProperties.Extract(AOldItem)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if (AOldItem.ItemType = itSimpleTypeAlias) and
|
||||||
|
(propertyItem.PropertyType = ptItem) then
|
||||||
|
begin
|
||||||
|
itemProperty := TXMLDataBindingItemProperty(propertyItem);
|
||||||
|
|
||||||
|
if itemProperty.Item = AOldItem then
|
||||||
|
begin
|
||||||
|
{ Replace item property with simple property }
|
||||||
|
simpleProperty := TXMLDataBindingSimpleProperty.Create(Owner,
|
||||||
|
itemProperty.SchemaItem,
|
||||||
|
itemProperty.Name,
|
||||||
|
TXMLDataBindingSimpleTypeAliasItem(AOldItem).DataType);
|
||||||
|
|
||||||
|
{ FProperties owns itemProperty and will free it }
|
||||||
|
FProperties[propertyIndex] := simpleProperty;
|
||||||
|
end else
|
||||||
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem);
|
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem);
|
||||||
|
end else
|
||||||
|
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1535,8 +1609,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TXMLDataBindingAliasItem }
|
{ TXMLDataBindingComplexTypeAliasItem }
|
||||||
procedure TXMLDataBindingAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
procedure TXMLDataBindingComplexTypeAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
@ -1545,9 +1619,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TXMLDataBindingAliasItem.GetItemType(): TXMLDataBindingItemType;
|
function TXMLDataBindingComplexTypeAliasItem.GetItemType(): TXMLDataBindingItemType;
|
||||||
begin
|
begin
|
||||||
Result := itAlias;
|
Result := itComplexTypeAlias;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TXMLDataBindingSimpleTypeAliasItem }
|
||||||
|
function TXMLDataBindingSimpleTypeAliasItem.GetItemType: TXMLDataBindingItemType;
|
||||||
|
begin
|
||||||
|
Result := itSimpleTypeAlias;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -100,7 +100,7 @@ Conditionals=
|
|||||||
DebugSourceDirs=
|
DebugSourceDirs=
|
||||||
UsePackages=0
|
UsePackages=0
|
||||||
[Parameters]
|
[Parameters]
|
||||||
RunParams="P:\xtx\xtx\xsd\Offerte.xsd" "P:\xtx\xtx\xsd\"
|
RunParams="Z:\SAM\Mitsubishi\Copernica\Koppelingbeschijving.xsd" "C:\Temp\Koppelingbeschrijving.pas"
|
||||||
HostApplication=
|
HostApplication=
|
||||||
Launcher=
|
Launcher=
|
||||||
UseLauncher=0
|
UseLauncher=0
|
||||||
@ -139,21 +139,6 @@ C:\Program Files\Borland\Indy\D7\dclIndy70.bpl=Internet Direct (Indy) for D7 Pro
|
|||||||
[HistoryLists\hlUnitAliases]
|
[HistoryLists\hlUnitAliases]
|
||||||
Count=1
|
Count=1
|
||||||
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||||
[HistoryLists\hlSearchPath]
|
|
||||||
Count=3
|
|
||||||
Item0=P:\xtx\xtx\xsd
|
|
||||||
Item1=..\..
|
|
||||||
Item2=F:\Development\VDarts\Packages
|
|
||||||
[HistoryLists\hlUnitOutputDirectory]
|
[HistoryLists\hlUnitOutputDirectory]
|
||||||
Count=6
|
Count=1
|
||||||
Item0=Lib
|
Item0=Lib
|
||||||
Item1=P:\Algemeen\lib
|
|
||||||
Item2=..\..\Lib\D7
|
|
||||||
Item3=..\..\Dcu
|
|
||||||
Item4=..\..\..\Dcu
|
|
||||||
Item5=Dcu
|
|
||||||
[HistoryLists\hlBPLOutput]
|
|
||||||
Count=3
|
|
||||||
Item0=..\..\Lib\D7
|
|
||||||
Item1=Lib\D7
|
|
||||||
Item2=..\Lib\D7
|
|
||||||
|
@ -6,10 +6,7 @@ uses
|
|||||||
DelphiXMLDataBindingGenerator in 'Units\DelphiXMLDataBindingGenerator.pas',
|
DelphiXMLDataBindingGenerator in 'Units\DelphiXMLDataBindingGenerator.pas',
|
||||||
XMLDataBindingGenerator in 'Units\XMLDataBindingGenerator.pas',
|
XMLDataBindingGenerator in 'Units\XMLDataBindingGenerator.pas',
|
||||||
XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas',
|
XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas',
|
||||||
DelphiXMLDataBindingResources in 'Units\DelphiXMLDataBindingResources.pas',
|
DelphiXMLDataBindingResources in 'Units\DelphiXMLDataBindingResources.pas';
|
||||||
xml_ExternalLeadFeed in '..\xml_ExternalLeadFeed.pas',
|
|
||||||
xml_Offerte in '..\..\xtx\xtx\xsd\xml_Offerte.pas';
|
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
CoInitialize(nil);
|
CoInitialize(nil);
|
||||||
|
Loading…
Reference in New Issue
Block a user