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;
|
||||
var
|
||||
charIndex: Integer;
|
||||
wordIndex: Integer;
|
||||
|
||||
begin
|
||||
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
|
||||
begin
|
||||
if Result = ReservedWords[wordIndex] then
|
||||
@ -331,6 +349,7 @@ begin
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -158,6 +158,8 @@ const
|
||||
'virtual', 'while', 'with', 'write', 'writeonly', 'xor'
|
||||
);
|
||||
|
||||
SafeChars = ['A'..'Z', 'a'..'z', '0'..'9', '_', '-'];
|
||||
|
||||
|
||||
type
|
||||
TTypeConversion = (tcNone, tcBoolean, tcFloat, tcDateTime);
|
||||
|
@ -19,7 +19,8 @@ type
|
||||
|
||||
TXMLDataBindingOutputType = (otSingle, otMultiple);
|
||||
TXMLDataBindingItemType = (itInterface, itEnumeration, itEnumerationMember,
|
||||
itProperty, itUnresolved, itAlias);
|
||||
itProperty, itUnresolved,
|
||||
itComplexTypeAlias, itSimpleTypeAlias);
|
||||
TXMLDataBindingInterfaceType = (ifElement, ifComplexType);
|
||||
TXMLDataBindingPropertyType = (ptSimple, ptItem);
|
||||
TXMLDataBindingOccurance = (boMinOccurs, boMaxOccurs);
|
||||
@ -300,7 +301,7 @@ type
|
||||
end;
|
||||
|
||||
|
||||
TXMLDataBindingAliasItem = class(TXMLDataBindingItem)
|
||||
TXMLDataBindingComplexTypeAliasItem = class(TXMLDataBindingItem)
|
||||
private
|
||||
FItem: TXMLDataBindingItem;
|
||||
protected
|
||||
@ -312,6 +313,16 @@ type
|
||||
end;
|
||||
|
||||
|
||||
TXMLDataBindingSimpleTypeAliasItem = class(TXMLDataBindingItem)
|
||||
private
|
||||
FDataType: IXMLTypeDef;
|
||||
protected
|
||||
function GetItemType(): TXMLDataBindingItemType; override;
|
||||
public
|
||||
property DataType: IXMLTypeDef read FDataType write FDataType;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils,
|
||||
@ -587,7 +598,12 @@ begin
|
||||
for complexTypeIndex := 0 to Pred(schemaDef.ComplexTypes.Count) do
|
||||
begin
|
||||
complexType := schemaDef.ComplexTypes[complexTypeIndex];
|
||||
|
||||
interfaceItem := TXMLDataBindingInterface.Create(Self, complexType, complexType.Name);
|
||||
|
||||
if complexType.DerivationMethod <> dmNone then
|
||||
interfaceItem.BaseName := complexType.BaseTypeName;
|
||||
|
||||
ASchema.AddItem(interfaceItem);
|
||||
|
||||
for elementIndex := 0 to Pred(complexType.ElementDefs.Count) do
|
||||
@ -664,7 +680,8 @@ var
|
||||
attributeIndex: Integer;
|
||||
enumerationObject: TXMLDataBindingEnumeration;
|
||||
interfaceObject: TXMLDataBindingInterface;
|
||||
aliasItem: TXMLDataBindingAliasItem;
|
||||
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
|
||||
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
|
||||
|
||||
begin
|
||||
Result := nil;
|
||||
@ -682,8 +699,9 @@ begin
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
if (not AElement.DataType.IsAnonymous) and
|
||||
AElement.DataType.IsComplex then
|
||||
if not AElement.DataType.IsAnonymous then
|
||||
begin
|
||||
if AElement.DataType.IsComplex then
|
||||
begin
|
||||
{ Find data type. If not found, mark as "resolve later". }
|
||||
Result := FindInterface(ASchema, AElement.DataTypeName, ifComplexType);
|
||||
@ -698,9 +716,18 @@ begin
|
||||
begin
|
||||
{ The element is global, but only references a complex type. Keep track
|
||||
to properly resolve references to the element. }
|
||||
aliasItem := TXMLDataBindingAliasItem.Create(Self, AElement, AElement.Name);
|
||||
aliasItem.Item := Result;
|
||||
ASchema.AddItem(aliasItem);
|
||||
complexAliasItem := TXMLDataBindingComplexTypeAliasItem.Create(Self, AElement, AElement.Name);
|
||||
complexAliasItem.Item := Result;
|
||||
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;
|
||||
|
||||
@ -840,7 +867,8 @@ begin
|
||||
itInterface:
|
||||
AAbort := (TXMLDataBindingInterface(AItem).InterfaceType = findInfo^.InterfaceType);
|
||||
|
||||
itAlias:
|
||||
itComplexTypeAlias,
|
||||
itSimpleTypeAlias:
|
||||
AAbort := (findInfo^.InterfaceType = ifElement);
|
||||
end;
|
||||
end;
|
||||
@ -914,18 +942,34 @@ procedure TXMLDataBindingGenerator.ResolveAlias(ASchema: TXMLDataBindingSchema);
|
||||
var
|
||||
itemIndex: Integer;
|
||||
item: TXMLDataBindingItem;
|
||||
aliasItem: TXMLDataBindingAliasItem;
|
||||
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
|
||||
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
|
||||
|
||||
begin
|
||||
for itemIndex := Pred(ASchema.ItemCount) downto 0 do
|
||||
begin
|
||||
item := ASchema.Items[itemIndex];
|
||||
|
||||
if item.ItemType = itAlias then
|
||||
case item.ItemType of
|
||||
itComplexTypeAlias:
|
||||
begin
|
||||
aliasItem := TXMLDataBindingAliasItem(item);
|
||||
if Assigned(aliasItem.Item) then
|
||||
ReplaceItem(aliasItem, aliasItem.Item);
|
||||
{ Replace alias element with the actual complex type }
|
||||
complexAliasItem := TXMLDataBindingComplexTypeAliasItem(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;
|
||||
@ -1372,12 +1416,42 @@ end;
|
||||
procedure TXMLDataBindingInterface.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
var
|
||||
propertyIndex: Integer;
|
||||
propertyItem: TXMLDataBindingProperty;
|
||||
itemProperty: TXMLDataBindingItemProperty;
|
||||
simpleProperty: TXMLDataBindingSimpleProperty;
|
||||
|
||||
begin
|
||||
inherited;
|
||||
|
||||
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);
|
||||
end else
|
||||
Properties[propertyIndex].ReplaceItem(AOldItem, ANewItem);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -1535,8 +1609,8 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{ TXMLDataBindingAliasItem }
|
||||
procedure TXMLDataBindingAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
{ TXMLDataBindingComplexTypeAliasItem }
|
||||
procedure TXMLDataBindingComplexTypeAliasItem.ReplaceItem(const AOldItem, ANewItem: TXMLDataBindingItem);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
@ -1545,9 +1619,16 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TXMLDataBindingAliasItem.GetItemType(): TXMLDataBindingItemType;
|
||||
function TXMLDataBindingComplexTypeAliasItem.GetItemType(): TXMLDataBindingItemType;
|
||||
begin
|
||||
Result := itAlias;
|
||||
Result := itComplexTypeAlias;
|
||||
end;
|
||||
|
||||
|
||||
{ TXMLDataBindingSimpleTypeAliasItem }
|
||||
function TXMLDataBindingSimpleTypeAliasItem.GetItemType: TXMLDataBindingItemType;
|
||||
begin
|
||||
Result := itSimpleTypeAlias;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -100,7 +100,7 @@ Conditionals=
|
||||
DebugSourceDirs=
|
||||
UsePackages=0
|
||||
[Parameters]
|
||||
RunParams="P:\xtx\xtx\xsd\Offerte.xsd" "P:\xtx\xtx\xsd\"
|
||||
RunParams="Z:\SAM\Mitsubishi\Copernica\Koppelingbeschijving.xsd" "C:\Temp\Koppelingbeschrijving.pas"
|
||||
HostApplication=
|
||||
Launcher=
|
||||
UseLauncher=0
|
||||
@ -139,21 +139,6 @@ C:\Program Files\Borland\Indy\D7\dclIndy70.bpl=Internet Direct (Indy) for D7 Pro
|
||||
[HistoryLists\hlUnitAliases]
|
||||
Count=1
|
||||
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]
|
||||
Count=6
|
||||
Count=1
|
||||
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',
|
||||
XMLDataBindingGenerator in 'Units\XMLDataBindingGenerator.pas',
|
||||
XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas',
|
||||
DelphiXMLDataBindingResources in 'Units\DelphiXMLDataBindingResources.pas',
|
||||
xml_ExternalLeadFeed in '..\xml_ExternalLeadFeed.pas',
|
||||
xml_Offerte in '..\..\xtx\xtx\xsd\xml_Offerte.pas';
|
||||
|
||||
DelphiXMLDataBindingResources in 'Units\DelphiXMLDataBindingResources.pas';
|
||||
|
||||
begin
|
||||
CoInitialize(nil);
|
||||
|
Loading…
Reference in New Issue
Block a user