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

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:
Mark van Renswoude 2008-07-31 14:56:36 +00:00
parent 7ed849490c
commit 65d792471d
4 changed files with 109 additions and 92 deletions

View File

@ -785,6 +785,10 @@ begin
begin
propertyItem := AItem.Properties[propertyIndex];
if propertyItem.PropertyType = ptItem then
begin
itemProperty := TXMLDataBindingItemProperty(propertyItem);
if (not AItem.IsCollection) and Assigned(propertyItem.Collection) then
begin
WritePrototype;
@ -794,22 +798,19 @@ begin
begin
AStream.WriteLnNamedFmt(' RegisterChildNode(''%<ItemSourceName>:s'', %<ItemClass>:s);',
['ItemSourceName', propertyItem.Name,
'ItemClass', PrefixClass + propertyItem.TranslatedName]);
'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 + propertyItem.TranslatedName,
'ItemInterface', PrefixInterface + itemProperty.Item.TranslatedName,
'ItemSourceName', propertyItem.Name]);
end;
end else if (propertyItem.PropertyType = ptItem) and
((not AItem.IsCollection) or
end else if ((not AItem.IsCollection) or
(propertyItem <> AItem.CollectionItem)) then
begin
{ Item property }
itemProperty := TXMLDataBindingItemProperty(propertyItem);
if Assigned(itemProperty.Item) and
(itemProperty.Item.ItemType = itInterface) then
begin
@ -828,6 +829,7 @@ begin
end;
end;
end;
end;
if AItem.IsCollection then
begin

View File

@ -38,12 +38,12 @@ const
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>:sFromStream(AStream: TStream): 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 +
' Result := ADocument.' + DocumentBinding + CrLf +
'end;' + CrLf +
@ -55,7 +55,7 @@ const
'' + CrLf +
'function Load%<Name>:sFromStream(AStream: TStream): IXML%<Name>:s;' + CrLf +
'var' + CrLf +
' doc: IXMLDocument;' + CrLf +
' doc: XMLIntf.IXMLDocument;' + CrLf +
'' + CrLf +
'begin' + CrLf +
' doc := NewXMLDocument;' + CrLf +
@ -194,7 +194,7 @@ type
const
SimpleTypeMapping: array[0..10] of TTypeMapping =
SimpleTypeMapping: array[0..11] of TTypeMapping =
(
(SchemaName: 'int'; DelphiName: 'Integer'; Conversion: tcNone),
(SchemaName: 'integer'; DelphiName: 'Integer'; Conversion: tcNone),
@ -206,6 +206,7 @@ const
(SchemaName: 'double'; DelphiName: 'Double'; Conversion: tcFloat),
(SchemaName: 'boolean'; DelphiName: 'Boolean'; Conversion: tcBoolean),
(SchemaName: 'string'; DelphiName: 'WideString'; Conversion: tcString),
(SchemaName: 'anyURI'; DelphiName: 'WideString'; Conversion: tcString),
(SchemaName: 'base64Binary'; DelphiName: 'WideString'; Conversion: tcBase64)
);

View File

@ -717,6 +717,7 @@ var
complexAliasItem: TXMLDataBindingComplexTypeAliasItem;
simpleAliasItem: TXMLDataBindingSimpleTypeAliasItem;
elementIndex: Integer;
simpleTypeDef: IXMLSimpleTypeDef;
begin
Result := nil;
@ -755,7 +756,9 @@ begin
complexAliasItem.Item := Result;
ASchema.AddItem(complexAliasItem);
end;
end else if AElement.DataType.Enumerations.Count > 0 then
end else if Supports(AElement.DataType, IXMLSimpleTypeDef, simpleTypeDef) then
begin
if simpleTypeDef.Enumerations.Count > 0 then
begin
{ References enumeration. }
Result := FindEnumeration(ASchema, AElement.DataTypeName);
@ -765,7 +768,7 @@ begin
Result := TXMLDataBindingUnresolvedItem.Create(Self, AElement, AElement.DataTypeName, ifEnumeration);
ASchema.AddItem(Result);
end;
end else if AElement.IsGlobal then
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);
@ -775,6 +778,7 @@ begin
Result := simpleAliasItem;
end;
end;
end;
if not Assigned(Result) then
begin
@ -1239,7 +1243,11 @@ begin
// #ToDo1 (MvR) 7-4-2008: check if an item with the "List" postfix
// exists in the schema, as it could cause
// 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;
@ -1248,6 +1256,7 @@ begin
collectionItem := TXMLDataBindingInterface.Create(Self, propertyItem.SchemaItem, collectionName);
collectionItem.CollectionItem := propertyItem;
ASchema.InsertItem(collectionItem, interfaceItem);
end;
propertyItem.Collection := collectionItem;
end;

View File

@ -1,6 +1,6 @@
-$A8
-$B-
-$C+
-$C-
-$D+
-$E-
-$F-
@ -12,7 +12,7 @@
-$L+
-$M-
-$N+
-$O+
-$O-
-$P+
-$Q-
-$R-
@ -22,7 +22,7 @@
-$V+
-$W-
-$X+
-$YD
-$Y+
-$Z1
-GD
-cg
@ -32,8 +32,13 @@
-M
-$M16384,1048576
-K$00400000
-LE"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
-N"lib"
-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_CODE
-w-UNSAFE_CAST