Fixed: incorrect type for certain collection items
Fixed: use XMLIntf.IXMLDocument in case of a conflicting 'Document' element (Google KML)
This commit is contained in:
parent
7ed849490c
commit
65d792471d
@ -780,50 +780,52 @@ begin
|
|||||||
|
|
||||||
|
|
||||||
hasPrototype := False;
|
hasPrototype := False;
|
||||||
|
|
||||||
for propertyIndex := 0 to Pred(AItem.PropertyCount) do
|
for propertyIndex := 0 to Pred(AItem.PropertyCount) do
|
||||||
begin
|
begin
|
||||||
propertyItem := AItem.Properties[propertyIndex];
|
propertyItem := AItem.Properties[propertyIndex];
|
||||||
|
|
||||||
if (not AItem.IsCollection) and Assigned(propertyItem.Collection) then
|
if propertyItem.PropertyType = ptItem then
|
||||||
begin
|
begin
|
||||||
WritePrototype;
|
|
||||||
|
|
||||||
{ Inline collection }
|
|
||||||
if ASection = dxsImplementation then
|
|
||||||
begin
|
|
||||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
|
|
||||||
['ItemSourceName', propertyItem.Name,
|
|
||||||
'ItemClass', PrefixClass + propertyItem.TranslatedName]);
|
|
||||||
|
|
||||||
AStream.WriteLnNamedFmt(' %<FieldName>:s := CreateCollection(%<CollectionClass>:s, %<ItemInterface>:s, ''%<ItemSourceName>:s'') as %<CollectionInterface>:s;',
|
|
||||||
['FieldName', PrefixField + propertyItem.TranslatedName,
|
|
||||||
'CollectionClass', PrefixClass + propertyItem.Collection.TranslatedName,
|
|
||||||
'CollectionInterface', PrefixInterface + propertyItem.Collection.TranslatedName,
|
|
||||||
'ItemInterface', PrefixInterface + propertyItem.TranslatedName,
|
|
||||||
'ItemSourceName', propertyItem.Name]);
|
|
||||||
end;
|
|
||||||
end else if (propertyItem.PropertyType = ptItem) and
|
|
||||||
((not AItem.IsCollection) or
|
|
||||||
(propertyItem <> AItem.CollectionItem)) then
|
|
||||||
begin
|
|
||||||
{ Item property }
|
|
||||||
itemProperty := TXMLDataBindingItemProperty(propertyItem);
|
itemProperty := TXMLDataBindingItemProperty(propertyItem);
|
||||||
|
|
||||||
if Assigned(itemProperty.Item) and
|
if (not AItem.IsCollection) and Assigned(propertyItem.Collection) then
|
||||||
(itemProperty.Item.ItemType = itInterface) then
|
|
||||||
begin
|
begin
|
||||||
case ASection of
|
WritePrototype;
|
||||||
dxsClass:
|
|
||||||
WritePrototype;
|
{ Inline collection }
|
||||||
|
if ASection = dxsImplementation then
|
||||||
dxsImplementation:
|
begin
|
||||||
begin
|
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
|
||||||
|
['ItemSourceName', propertyItem.Name,
|
||||||
|
'ItemClass', PrefixClass + itemProperty.Item.TranslatedName]);
|
||||||
|
|
||||||
|
AStream.WriteLnNamedFmt(' %<FieldName>:s := CreateCollection(%<CollectionClass>:s, %<ItemInterface>:s, ''%<ItemSourceName>:s'') as %<CollectionInterface>:s;',
|
||||||
|
['FieldName', PrefixField + propertyItem.TranslatedName,
|
||||||
|
'CollectionClass', PrefixClass + propertyItem.Collection.TranslatedName,
|
||||||
|
'CollectionInterface', PrefixInterface + propertyItem.Collection.TranslatedName,
|
||||||
|
'ItemInterface', PrefixInterface + itemProperty.Item.TranslatedName,
|
||||||
|
'ItemSourceName', propertyItem.Name]);
|
||||||
|
end;
|
||||||
|
end else if ((not AItem.IsCollection) or
|
||||||
|
(propertyItem <> AItem.CollectionItem)) then
|
||||||
|
begin
|
||||||
|
{ Item property }
|
||||||
|
if Assigned(itemProperty.Item) and
|
||||||
|
(itemProperty.Item.ItemType = itInterface) then
|
||||||
|
begin
|
||||||
|
case ASection of
|
||||||
|
dxsClass:
|
||||||
WritePrototype;
|
WritePrototype;
|
||||||
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', TXML%<Name>:s);',
|
|
||||||
['SourceName', propertyItem.Name,
|
dxsImplementation:
|
||||||
'Name', itemProperty.Item.TranslatedName]);
|
begin
|
||||||
end;
|
WritePrototype;
|
||||||
|
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<SourceName>:s'', TXML%<Name>:s);',
|
||||||
|
['SourceName', propertyItem.Name,
|
||||||
|
'Name', itemProperty.Item.TranslatedName]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -38,36 +38,36 @@ const
|
|||||||
|
|
||||||
DocumentBinding = 'GetDocBinding(''%<SourceName>:s'', TXML%<Name>:s, TargetNamespace) as IXML%<Name>:s';
|
DocumentBinding = 'GetDocBinding(''%<SourceName>:s'', TXML%<Name>:s, TargetNamespace) as IXML%<Name>:s';
|
||||||
|
|
||||||
DocumentFunctionsInterface = ' function Get%<Name>:s(ADocument: IXMLDocument): IXML%<Name>:s;' + CrLf +
|
DocumentFunctionsInterface = ' function Get%<Name>:s(ADocument: XMLIntf.IXMLDocument): IXML%<Name>:s;' + CrLf +
|
||||||
' function Load%<Name>:s(const AFileName: String): IXML%<Name>:s;' + CrLf +
|
' function Load%<Name>:s(const AFileName: String): IXML%<Name>:s;' + CrLf +
|
||||||
' function Load%<Name>:sFromStream(AStream: TStream): IXML%<Name>:s;' + CrLf +
|
' function Load%<Name>:sFromStream(AStream: TStream): IXML%<Name>:s;' + CrLf +
|
||||||
' function New%<Name>:s: IXML%<Name>:s;' + CrLf;
|
' function New%<Name>:s: IXML%<Name>:s;' + CrLf;
|
||||||
|
|
||||||
DocumentFunctionsImplementation = 'function Get%<Name>:s(ADocument: IXMLDocument): IXML%<Name>:s;' + CrLf +
|
DocumentFunctionsImplementation = 'function Get%<Name>:s(ADocument: XMLIntf.IXMLDocument): IXML%<Name>:s;' + CrLf +
|
||||||
'begin' + CrLf +
|
'begin' + CrLf +
|
||||||
' Result := ADocument.' + DocumentBinding + CrLf +
|
' Result := ADocument.' + DocumentBinding + CrLf +
|
||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf +
|
'' + CrLf +
|
||||||
'function Load%<Name>:s(const AFileName: String): IXML%<Name>:s;' + CrLf +
|
'function Load%<Name>:s(const AFileName: String): IXML%<Name>:s;' + CrLf +
|
||||||
'begin' + CrLf +
|
'begin' + CrLf +
|
||||||
' Result := LoadXMLDocument(AFileName).' + DocumentBinding + CrLf +
|
' Result := LoadXMLDocument(AFileName).' + DocumentBinding + CrLf +
|
||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf +
|
'' + CrLf +
|
||||||
'function Load%<Name>:sFromStream(AStream: TStream): IXML%<Name>:s;' + CrLf +
|
'function Load%<Name>:sFromStream(AStream: TStream): IXML%<Name>:s;' + CrLf +
|
||||||
'var' + CrLf +
|
'var' + CrLf +
|
||||||
' doc: IXMLDocument;' + CrLf +
|
' doc: XMLIntf.IXMLDocument;' + CrLf +
|
||||||
'' + CrLf +
|
'' + CrLf +
|
||||||
'begin' + CrLf +
|
'begin' + CrLf +
|
||||||
' doc := NewXMLDocument;' + CrLf +
|
' doc := NewXMLDocument;' + CrLf +
|
||||||
' doc.LoadFromStream(AStream);' + CrLf +
|
' doc.LoadFromStream(AStream);' + CrLf +
|
||||||
' Result := Get%<Name>:s(doc);' + CrLf +
|
' Result := Get%<Name>:s(doc);' + CrLf +
|
||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf +
|
'' + CrLf +
|
||||||
'function New%<Name>:s: IXML%<Name>:s;' + CrLf +
|
'function New%<Name>:s: IXML%<Name>:s;' + CrLf +
|
||||||
'begin' + CrLf +
|
'begin' + CrLf +
|
||||||
' Result := NewXMLDocument.' + DocumentBinding + CrLf +
|
' Result := NewXMLDocument.' + DocumentBinding + CrLf +
|
||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf;
|
'' + CrLf;
|
||||||
|
|
||||||
|
|
||||||
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;';
|
||||||
@ -194,7 +194,7 @@ type
|
|||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
SimpleTypeMapping: array[0..10] of TTypeMapping =
|
SimpleTypeMapping: array[0..11] of TTypeMapping =
|
||||||
(
|
(
|
||||||
(SchemaName: 'int'; DelphiName: 'Integer'; Conversion: tcNone),
|
(SchemaName: 'int'; DelphiName: 'Integer'; Conversion: tcNone),
|
||||||
(SchemaName: 'integer'; DelphiName: 'Integer'; Conversion: tcNone),
|
(SchemaName: 'integer'; DelphiName: 'Integer'; Conversion: tcNone),
|
||||||
@ -206,6 +206,7 @@ const
|
|||||||
(SchemaName: 'double'; DelphiName: 'Double'; Conversion: tcFloat),
|
(SchemaName: 'double'; DelphiName: 'Double'; Conversion: tcFloat),
|
||||||
(SchemaName: 'boolean'; DelphiName: 'Boolean'; Conversion: tcBoolean),
|
(SchemaName: 'boolean'; DelphiName: 'Boolean'; Conversion: tcBoolean),
|
||||||
(SchemaName: 'string'; DelphiName: 'WideString'; Conversion: tcString),
|
(SchemaName: 'string'; DelphiName: 'WideString'; Conversion: tcString),
|
||||||
|
(SchemaName: 'anyURI'; DelphiName: 'WideString'; Conversion: tcString),
|
||||||
(SchemaName: 'base64Binary'; DelphiName: 'WideString'; Conversion: tcBase64)
|
(SchemaName: 'base64Binary'; DelphiName: 'WideString'; Conversion: tcBase64)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -717,6 +717,7 @@ var
|
|||||||
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
|
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
|
||||||
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
|
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
|
||||||
elementIndex: Integer;
|
elementIndex: Integer;
|
||||||
|
simpleTypeDef: IXMLSimpleTypeDef;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := nil;
|
Result := nil;
|
||||||
@ -755,24 +756,27 @@ begin
|
|||||||
complexAliasItem.Item := Result;
|
complexAliasItem.Item := Result;
|
||||||
ASchema.AddItem(complexAliasItem);
|
ASchema.AddItem(complexAliasItem);
|
||||||
end;
|
end;
|
||||||
end else if AElement.DataType.Enumerations.Count > 0 then
|
end else if Supports(AElement.DataType, IXMLSimpleTypeDef, simpleTypeDef) then
|
||||||
begin
|
begin
|
||||||
{ References enumeration. }
|
if simpleTypeDef.Enumerations.Count > 0 then
|
||||||
Result := FindEnumeration(ASchema, AElement.DataTypeName);
|
|
||||||
|
|
||||||
if not Assigned(Result) then
|
|
||||||
begin
|
begin
|
||||||
Result := TXMLDataBindingUnresolvedItem.Create(Self, AElement, AElement.DataTypeName, ifEnumeration);
|
{ References enumeration. }
|
||||||
ASchema.AddItem(Result);
|
Result := FindEnumeration(ASchema, AElement.DataTypeName);
|
||||||
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;
|
if not Assigned(Result) then
|
||||||
|
begin
|
||||||
|
Result := TXMLDataBindingUnresolvedItem.Create(Self, AElement, AElement.DataTypeName, ifEnumeration);
|
||||||
|
ASchema.AddItem(Result);
|
||||||
|
end;
|
||||||
|
end else if simpleTypeDef.IsBuiltInType and 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;
|
end;
|
||||||
|
|
||||||
@ -1239,16 +1243,21 @@ begin
|
|||||||
// #ToDo1 (MvR) 7-4-2008: check if an item with the "List" postfix
|
// #ToDo1 (MvR) 7-4-2008: check if an item with the "List" postfix
|
||||||
// exists in the schema, as it could cause
|
// exists in the schema, as it could cause
|
||||||
// conflicts.
|
// conflicts.
|
||||||
|
// #ToDo1 (MvR) 30-7-2008: temporary implementation; have to check
|
||||||
|
// for proper functioning later.
|
||||||
|
collectionItem := FindInterface(ASchema, propertyItem.TranslatedName + CollectionPostfix, ifElement);
|
||||||
|
if not Assigned(collectionItem) then
|
||||||
|
begin
|
||||||
|
case propertyItem.PropertyType of
|
||||||
|
ptSimple: collectionName := propertyItem.TranslatedName + CollectionPostfix;
|
||||||
|
ptItem: collectionName := propertyItem.TranslatedName + CollectionPostfix;
|
||||||
|
end;
|
||||||
|
|
||||||
case propertyItem.PropertyType of
|
collectionItem := TXMLDataBindingInterface.Create(Self, propertyItem.SchemaItem, collectionName);
|
||||||
ptSimple: collectionName := propertyItem.TranslatedName + CollectionPostfix;
|
collectionItem.CollectionItem := propertyItem;
|
||||||
ptItem: collectionName := propertyItem.TranslatedName + CollectionPostfix;
|
ASchema.InsertItem(collectionItem, interfaceItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
collectionItem := TXMLDataBindingInterface.Create(Self, propertyItem.SchemaItem, collectionName);
|
|
||||||
collectionItem.CollectionItem := propertyItem;
|
|
||||||
ASchema.InsertItem(collectionItem, interfaceItem);
|
|
||||||
|
|
||||||
propertyItem.Collection := collectionItem;
|
propertyItem.Collection := collectionItem;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-$A8
|
-$A8
|
||||||
-$B-
|
-$B-
|
||||||
-$C+
|
-$C-
|
||||||
-$D+
|
-$D+
|
||||||
-$E-
|
-$E-
|
||||||
-$F-
|
-$F-
|
||||||
@ -12,7 +12,7 @@
|
|||||||
-$L+
|
-$L+
|
||||||
-$M-
|
-$M-
|
||||||
-$N+
|
-$N+
|
||||||
-$O+
|
-$O-
|
||||||
-$P+
|
-$P+
|
||||||
-$Q-
|
-$Q-
|
||||||
-$R-
|
-$R-
|
||||||
@ -22,7 +22,7 @@
|
|||||||
-$V+
|
-$V+
|
||||||
-$W-
|
-$W-
|
||||||
-$X+
|
-$X+
|
||||||
-$YD
|
-$Y+
|
||||||
-$Z1
|
-$Z1
|
||||||
-GD
|
-GD
|
||||||
-cg
|
-cg
|
||||||
@ -32,8 +32,13 @@
|
|||||||
-M
|
-M
|
||||||
-$M16384,1048576
|
-$M16384,1048576
|
||||||
-K$00400000
|
-K$00400000
|
||||||
-LE"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
-N"lib"
|
||||||
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
-LE"c:\program files\borland\delphi7\Projects\Bpl"
|
||||||
|
-LN"c:\program files\borland\delphi7\Projects\Bpl"
|
||||||
|
-U"c:\program files\borland\delphi7\Lib\Debug"
|
||||||
|
-O"c:\program files\borland\delphi7\Lib\Debug"
|
||||||
|
-I"c:\program files\borland\delphi7\Lib\Debug"
|
||||||
|
-R"c:\program files\borland\delphi7\Lib\Debug"
|
||||||
-w-UNSAFE_TYPE
|
-w-UNSAFE_TYPE
|
||||||
-w-UNSAFE_CODE
|
-w-UNSAFE_CODE
|
||||||
-w-UNSAFE_CAST
|
-w-UNSAFE_CAST
|
||||||
|
Loading…
Reference in New Issue
Block a user