diff --git a/Units/DelphiXMLDataBindingGenerator.pas b/Units/DelphiXMLDataBindingGenerator.pas index a81cb45..55df5ce 100644 --- a/Units/DelphiXMLDataBindingGenerator.pas +++ b/Units/DelphiXMLDataBindingGenerator.pas @@ -70,9 +70,10 @@ type procedure WriteValidate(AStream: TStreamHelper; AItem: TXMLDataBindingInterface; ASection: TDelphiXMLSection); function GetDelphiNodeType(AProperty: TXMLDataBindingProperty): TDelphiNodeType; - function DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String; - function XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String; - function NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String; + function GetDelphiElementType(AProperty: TXMLDataBindingProperty): TDelphiElementType; + function DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String; + function XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String; + function NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ATargetNamespace: string; const ALinesBefore: String = ''): String; property ProcessedItems: TX2OIHash read FProcessedItems; property UnitNames: TX2OSHash read FUnitNames; @@ -417,6 +418,7 @@ begin hasItem := False; nameSpace := ''; + // #ToDo1 -oMvR: 6-4-2012: bij de Hyundai XSD's wordt hiermee TargetNamespace incorrect de laatste schema namespace for schemaIndex := 0 to Pred(ASchemaList.Count) do begin schema := ASchemaList[schemaIndex]; @@ -751,9 +753,17 @@ begin if ASection = dxsImplementation then begin if propertyItem.PropertyType = ptItem then - AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', %:s);', - ['ItemSourceName', propertyItem.Name, - 'ItemClass', GetDataTypeName(propertyItem, False)]); + begin + if propertyItem.HasTargetNamespace then + AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', %:s, ''%:s'');', + ['ItemSourceName', propertyItem.Name, + 'ItemClass', GetDataTypeName(propertyItem, False), + 'Namespace', propertyItem.TargetNamespace]) + else + AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', %:s);', + ['ItemSourceName', propertyItem.Name, + 'ItemClass', GetDataTypeName(propertyItem, False)]); + end; AStream.WriteLnNamedFmt(' %:s := CreateCollection(%:s, %:s, ''%:s'') as %:s;', ['FieldName', PrefixField + propertyItem.TranslatedName, @@ -782,9 +792,16 @@ begin dxsImplementation: begin WritePrototype; - AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', TXML%:s);', - ['SourceName', propertyItem.Name, - 'Name', itemProperty.Item.TranslatedName]); + + if propertyItem.HasTargetNamespace then + AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', TXML%:s, ''%:s'');', + ['SourceName', propertyItem.Name, + 'Name', itemProperty.Item.TranslatedName, + 'Namespace', propertyItem.TargetNamespace]) + else + AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', TXML%:s);', + ['SourceName', propertyItem.Name, + 'Name', itemProperty.Item.TranslatedName]); end; end; end; @@ -799,9 +816,16 @@ begin if ASection = dxsImplementation then begin WritePrototype; - AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', %:s);', - ['SourceName', AItem.CollectionItem.Name, - 'DataClass', GetDataTypeName(AItem.CollectionItem, False)]); + if AItem.CollectionItem.HasTargetNamespace then + AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', %:s, ''%:s'');', + ['SourceName', AItem.CollectionItem.Name, + 'DataClass', GetDataTypeName(AItem.CollectionItem, False), + 'Namespace', AItem.CollectionItem.TargetNamespace]) + else + AStream.WriteLnNamedFmt(' RegisterChildNode(''%:s'', %:s);', + ['SourceName', AItem.CollectionItem.Name, + 'DataClass', GetDataTypeName(AItem.CollectionItem, False)]); + AStream.WriteLn; AStream.WriteLnFmt(' ItemTag := ''%s'';', [AItem.CollectionItem.Name]); AStream.WriteLnFmt(' ItemInterface := %s;', [GetDataTypeName(AItem.CollectionItem, True)]); @@ -962,9 +986,9 @@ begin sourceCode.Add('function TXML%:s.Get_%:s(Index: Integer): %:s;'); if GetDataTypeMapping(typeDef, typeMapping) and (typeMapping.Conversion = tcString) then - sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].Text', typeDef, dntCustom)) + sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].Text', typeDef, dntCustom, AItem.CollectionItem.TargetNamespace)) else - sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].NodeValue', typeDef, dntCustom)); + sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].NodeValue', typeDef, dntCustom, AItem.CollectionItem.TargetNamespace)); sourceCode.AddLn; @@ -1181,16 +1205,16 @@ begin if AProperty.IsAttribute then sourceCode.Add(PropertyImplMethodGetOptionalAttr) else - sourceCode.Add(PropertyImplMethodGetOptional); + sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(AProperty)]); if writeNil then - sourceCode.Add(PropertyImplMethodGetNil); + sourceCode.Add(PropertyImplMethodGetNil[GetDelphiElementType(AProperty)]); if writeTextProp then if AProperty.IsAttribute then sourceCode.Add(PropertyImplMethodGetTextAttr) else - sourceCode.Add(PropertyImplMethodGetText); + sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]); sourceCode.Add('function TXML%:s.Get%:s: %:s;'); @@ -1205,7 +1229,8 @@ begin sourceCode.Add(XMLToNativeDataType('Result', '%:s', TXMLDataBindingSimpleProperty(AProperty).DataType, - GetDelphiNodeType(AProperty))); + GetDelphiNodeType(AProperty), + AProperty.TargetNamespace)); ptItem: begin @@ -1222,7 +1247,12 @@ begin itInterface: begin sourceCode.Add('begin'); - sourceCode.Add(' Result := (ChildNodes[''%:s''] as IXML%:s);'); + + if AProperty.HasTargetNamespace then + sourceCode.Add(' Result := (ChildNodes.FindNode(''%:s'', ''%:s'') as IXML%:s);') + else + sourceCode.Add(' Result := (ChildNodes[''%:s''] as IXML%:s);'); + sourceCode.Add('end;'); end; @@ -1246,13 +1276,13 @@ begin WriteNewLine; if writeNil then - sourceCode.Add(PropertyImplMethodSetNil); + sourceCode.Add(PropertyImplMethodSetNil[GetDelphiElementType(AProperty)]); if writeTextProp then if AProperty.IsAttribute then sourceCode.Add(PropertyImplMethodSetTextAttr) else - sourceCode.Add(PropertyImplMethodSetText); + sourceCode.Add(PropertyImplMethodSetText[GetDelphiElementType(AProperty)]); sourceCode.Add('procedure TXML%:s.Set%:s(const Value: %:s);'); value := '%:s'; @@ -1260,7 +1290,8 @@ begin if Assigned(propertyItem) and (propertyItem.ItemType = itEnumeration) then begin sourceCode.Add(NativeDataTypeToXML(value, '%:sValues[Value]', nil, - GetDelphiNodeType(AProperty))); + GetDelphiNodeType(AProperty), + AProperty.TargetNamespace)); end else begin if AProperty.PropertyType <> ptSimple then @@ -1268,7 +1299,8 @@ begin sourceCode.Add(NativeDataTypeToXML(value, 'Value', TXMLDataBindingSimpleProperty(AProperty).DataType, - GetDelphiNodeType(AProperty))); + GetDelphiNodeType(AProperty), + AProperty.TargetNamespace)); end; sourceCode.AddLn; @@ -1288,7 +1320,8 @@ begin 'PropertyName', AProperty.TranslatedName, 'PropertyItemName', propertyItemName, 'DataType', dataTypeName, - 'FieldName', fieldName])); + 'FieldName', fieldName, + 'Namespace', AProperty.TargetNamespace])); finally FreeAndNil(sourceCode); end; @@ -1482,12 +1515,24 @@ begin Result := dntAttribute else if AProperty.IsNodeValue then Result := dntNodeValue + else if AProperty.HasTargetNamespace then + Result := dntElementNS else Result := dntElement; end; -function TDelphiXMLDataBindingGenerator.DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; const ALinesBefore: String = ''): String; +function TDelphiXMLDataBindingGenerator.GetDelphiElementType(AProperty: TXMLDataBindingProperty): TDelphiElementType; +begin + Result := GetDelphiNodeType(AProperty); + if Result <> dntElementNS then + Result := dntElement; +end; + + +function TDelphiXMLDataBindingGenerator.DataTypeConversion(const ADestination, ASource: String; ADataType: IXMLTypeDef; + AAccessor: TDelphiAccessor; ANodeType: TDelphiNodeType; + const ATargetNamespace: string; const ALinesBefore: String = ''): String; var typeMapping: TTypeMapping; conversion: String; @@ -1513,23 +1558,29 @@ begin Add(conversion); Add('end;'); + // #ToDo1 -oMvR: 6-4-2012: Namespace Result := Trim(Format(['Destination', ADestination, - 'Source', ASource])); + 'Source', ASource, + 'Namespace', ATargetNamespace])); finally Free; end; end; -function TDelphiXMLDataBindingGenerator.XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String): String; +function TDelphiXMLDataBindingGenerator.XMLToNativeDataType(const ADestination, ASource: String; ADataType: IXMLTypeDef; + ANodeType: TDelphiNodeType; const ATargetNamespace: string; + const ALinesBefore: String): String; begin - Result := DataTypeConversion(ADestination, ASource, ADataType, daGet, ANodeType, ALinesBefore); + Result := DataTypeConversion(ADestination, ASource, ADataType, daGet, ANodeType, ATargetNamespace, ALinesBefore); end; -function TDelphiXMLDataBindingGenerator.NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; ANodeType: TDelphiNodeType; const ALinesBefore: String): String; +function TDelphiXMLDataBindingGenerator.NativeDataTypeToXML(const ADestination, ASource: String; ADataType: IXMLTypeDef; + ANodeType: TDelphiNodeType; const ATargetNamespace: string; + const ALinesBefore: String): String; begin - Result := DataTypeConversion(ADestination, ASource, ADataType, daSet, ANodeType, ALinesBefore); + Result := DataTypeConversion(ADestination, ASource, ADataType, daSet, ANodeType, ATargetNamespace, ALinesBefore); end; diff --git a/Units/DelphiXMLDataBindingResources.pas b/Units/DelphiXMLDataBindingResources.pas index 9b75ffe..9c2649d 100644 --- a/Units/DelphiXMLDataBindingResources.pas +++ b/Units/DelphiXMLDataBindingResources.pas @@ -1,11 +1,14 @@ unit DelphiXMLDataBindingResources; +// #ToDo1 -oMvR: 6-4-2012: namespace support voor attributes + interface type TDelphiXMLSection = (dxsForward, dxsInterface, dxsClass, dxsImplementation); TDelphiXMLMember = (dxmPropertyGet, dxmPropertySet, dxmPropertyDeclaration); TDelphiAccessor = (daGet, daSet); - TDelphiNodeType = (dntElement, dntAttribute, dntNodeValue, dntCustom); + TDelphiNodeType = (dntElement, dntElementNS, dntAttribute, dntNodeValue, dntCustom); + TDelphiElementType = dntElement..dntElementNS; const @@ -111,11 +114,22 @@ const PropertyInterfaceText = ' property %:sText: WideString read Get%:sText write Set%:sText;'; PropertyInterface = ' property %:s: %:s read Get%:s write Set%:s;'; - PropertyImplMethodGetOptional = 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + - 'begin' + CrLf + - ' Result := Assigned(ChildNodes.FindNode(''%:s''));' + CrLf + - 'end;' + CrLf + - '' + CrLf; + PropertyImplMethodGetOptional: array[TDelphiElementType] of string = + ( + { dntElement } + 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + + 'begin' + CrLf + + ' Result := Assigned(ChildNodes.FindNode(''%:s''));' + CrLf + + 'end;' + CrLf + + '' + CrLf, + + { dntElementNS } + 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + + 'begin' + CrLf + + ' Result := Assigned(ChildNodes.FindNode(''%:s'', ''%:s''));' + CrLf + + 'end;' + CrLf + + '' + CrLf + ); PropertyImplMethodGetOptionalAttr = 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + 'begin' + CrLf + @@ -123,23 +137,56 @@ const 'end;' + CrLf + '' + CrLf; - PropertyImplMethodGetNil = 'function TXML%:s.Get%:sIsNil: Boolean;' + CrLf + - 'begin' + CrLf + - ' Result := GetNodeIsNil(ChildNodes[''%:s'']);' + CrLf + - 'end;' + CrLf + - '' + CrLf; + PropertyImplMethodGetNil: array[TDelphiElementType] of string = + ( + { dntElement } + 'function TXML%:s.Get%:sIsNil: Boolean;' + CrLf + + 'begin' + CrLf + + ' Result := GetNodeIsNil(ChildNodes[''%:s'']);' + CrLf + + 'end;' + CrLf + + '' + CrLf, - PropertyImplMethodSetNil = 'procedure TXML%:s.Set%:sIsNil(const Value: Boolean);' + CrLf + - 'begin' + CrLf + - ' SetNodeIsNil(ChildNodes[''%:s''], Value);' + CrLf + - 'end;' + CrLf + - '' + CrLf; + { dntElementNS } + 'function TXML%:s.Get%:sIsNil: Boolean;' + CrLf + + 'begin' + CrLf + + ' Result := GetNodeIsNil(ChildNodes.FindNode(''%:s'', ''%:s''));' + CrLf + + 'end;' + CrLf + + '' + CrLf + ); - PropertyImplMethodGetText = 'function TXML%:s.Get%:sText: WideString;' + CrLf + - 'begin' + CrLf + - ' Result := ChildNodes[''%:s''].Text;' + CrLf + - 'end;' + CrLf + - '' + CrLf; + PropertyImplMethodSetNil: array[TDelphiElementType] of string = + ( + { dntElement } + 'procedure TXML%:s.Set%:sIsNil(const Value: Boolean);' + CrLf + + 'begin' + CrLf + + ' SetNodeIsNil(ChildNodes[''%:s''], Value);' + CrLf + + 'end;' + CrLf + + '' + CrLf, + + { dntElementNS } + 'procedure TXML%:s.Set%:sIsNil(const Value: Boolean);' + CrLf + + 'begin' + CrLf + + ' SetNodeIsNil(ChildNodes.FindNode(''%:s'', ''%:s''), Value);' + CrLf + + 'end;' + CrLf + + '' + CrLf + ); + + PropertyImplMethodGetText: array[TDelphiElementType] of string = + ( + { dntElement } + 'function TXML%:s.Get%:sText: WideString;' + CrLf + + 'begin' + CrLf + + ' Result := ChildNodes[''%:s''].Text;' + CrLf + + 'end;' + CrLf + + '' + CrLf, + + { dntElement } + 'function TXML%:s.Get%:sText: WideString;' + CrLf + + 'begin' + CrLf + + ' Result := ChildNodes.FindNode(''%:s'', ''%:s'').Text;' + CrLf + + 'end;' + CrLf + + '' + CrLf + ); PropertyImplMethodGetTextAttr = 'function TXML%:s.Get%:sText: WideString;' + CrLf + 'begin' + CrLf + @@ -147,11 +194,22 @@ const 'end;' + CrLf + '' + CrLf; - PropertyImplMethodSetText = 'procedure TXML%:s.Set%:sText(const Value: WideString);' + CrLf + - 'begin' + CrLf + - ' ChildNodes[''%:s''].NodeValue := Value;' + CrLf + - 'end;' + CrLf + - '' + CrLf; + PropertyImplMethodSetText: array[TDelphiElementType] of string = + ( + { dntElement } + 'procedure TXML%:s.Set%:sText(const Value: WideString);' + CrLf + + 'begin' + CrLf + + ' ChildNodes[''%:s''].NodeValue := Value;' + CrLf + + 'end;' + CrLf + + '' + CrLf, + + { dntElementNS } + 'procedure TXML%:s.Set%:sText(const Value: WideString);' + CrLf + + 'begin' + CrLf + + ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := Value;' + CrLf + + 'end;' + CrLf + + '' + CrLf + ); PropertyImplMethodSetTextAttr = 'procedure TXML%:s.Set%:sText(const Value: WideString);' + CrLf + 'begin' + CrLf + @@ -272,6 +330,7 @@ const { daGet } ( { dntElement } ' %:s := ChildNodes[''%:s''].NodeValue;', + { dntElementNS } ' %:s := ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue;', { dntAttribute } ' %:s := AttributeNodes[''%:s''].NodeValue;', { dntNodeValue } ' %:s := GetNodeValue;', { dntCustom } ' %:s := %:s;' @@ -279,6 +338,7 @@ const { daSet } ( { dntElement } ' ChildNodes[''%:s''].NodeValue := %:s;', + { dntElementNS } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := %:s;', { dntAttribute } ' SetAttribute(''%:s'', %:s);', { dntNodeValue } ' SetNodeValue(%:s);', { dntCustom } ' %:s := %:s;' @@ -301,6 +361,17 @@ const { tcString } ' %:s := ChildNodes[''%:s''].Text;', { tcBas64 } ' %:s := Base64Decode(Trim(ChildNodes[''%:s''].Text));' ), + { dntElementNS } + ( + { tcNone } '', + { tcBoolean } '', + { tcFloat } ' %:s := XMLToFloat(ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue);', + { tcDateTime } ' %:s := XMLToDateTime(ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue, xdtDateTime);', + { tcDate } ' %:s := XMLToDateTime(ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue, xdtDate);', + { tcTime } ' %:s := XMLToDateTime(ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue, xdtTime);', + { tcString } ' %:s := ChildNodes.FindNode(''%:s'', ''%:s'').Text;', + { tcBas64 } ' %:s := Base64Decode(Trim(ChildNodes.FindNode(''%:s'', ''%:s'').Text));' + ), { dntAttribute } ( { tcNone } '', @@ -348,6 +419,17 @@ const { tcString } '', { tcBase64 } ' ChildNodes[''%:s''].NodeValue := Base64Encode(%:s);' ), + { dntElementNS } + ( + { tcNone } '', + { tcBoolean } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := BoolToXML(%:s);', + { tcFloat } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := FloatToXML(%:s);', + { tcDateTime } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := DateTimeToXML(%:s, xdtDateTime);', + { tcDate } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := DateTimeToXML(%:s, xdtDate);', + { tcTime } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := DateTimeToXML(%:s, xdtTime);', + { tcString } '', + { tcBase64 } ' ChildNodes.FindNode(''%:s'', ''%:s'').NodeValue := Base64Encode(%:s);' + ), { dntAttribute } ( { tcNone } '', diff --git a/Units/XMLDataBindingGenerator.pas b/Units/XMLDataBindingGenerator.pas index 1112d76..92592ae 100644 --- a/Units/XMLDataBindingGenerator.pas +++ b/Units/XMLDataBindingGenerator.pas @@ -258,27 +258,32 @@ type TXMLDataBindingProperty = class(TXMLDataBindingItem) private - FIsAttribute: Boolean; - FIsOptional: Boolean; - FIsNillable: Boolean; - FIsRepeating: Boolean; - FIsNodeValue: Boolean; - FCollection: TXMLDataBindingInterface; + FTargetNamespace: string; + FIsAttribute: Boolean; + FIsOptional: Boolean; + FIsNillable: Boolean; + FIsRepeating: Boolean; + FIsNodeValue: Boolean; + FCollection: TXMLDataBindingInterface; + function GetHasTargetNamespace: Boolean; protected function GetIsReadOnly: Boolean; virtual; abstract; function GetItemType: TXMLDataBindingItemType; override; function GetPropertyType: TXMLDataBindingPropertyType; virtual; abstract; public - property IsAttribute: Boolean read FIsAttribute write FIsAttribute; - property IsOptional: Boolean read FIsOptional write FIsOptional; - property IsNillable: Boolean read FIsNillable write FIsNillable; - property IsReadOnly: Boolean read GetIsReadOnly; - property IsRepeating: Boolean read FIsRepeating write FIsRepeating; - property IsNodeValue: Boolean read FIsNodeValue write FIsNodeValue; - property PropertyType: TXMLDataBindingPropertyType read GetPropertyType; + property TargetNamespace: string read FTargetNamespace write FTargetNamespace; + property IsAttribute: Boolean read FIsAttribute write FIsAttribute; + property IsOptional: Boolean read FIsOptional write FIsOptional; + property IsNillable: Boolean read FIsNillable write FIsNillable; + property IsReadOnly: Boolean read GetIsReadOnly; + property IsRepeating: Boolean read FIsRepeating write FIsRepeating; + property IsNodeValue: Boolean read FIsNodeValue write FIsNodeValue; + property PropertyType: TXMLDataBindingPropertyType read GetPropertyType; - property Collection: TXMLDataBindingInterface read FCollection write FCollection; + property Collection: TXMLDataBindingInterface read FCollection write FCollection; + + property HasTargetNamespace: Boolean read GetHasTargetNamespace; end; @@ -982,6 +987,7 @@ var actualElement: IXMLElementDef; propertyType: TXMLDataBindingItem; propertyItem: TXMLDataBindingProperty; + namespace: string; begin propertyType := ProcessElement(ASchema, AElement); @@ -997,6 +1003,10 @@ begin AElement.Name, AElement.DataType); + namespace := AElement.SchemaDef.TargetNamespace; + if namespace <> Schemas[0].TargetNamespace then + propertyItem.TargetNamespace := namespace; + propertyItem.IsOptional := IsElementOptional(AElement) or IsChoice(AElement); propertyItem.IsRepeating := IsElementRepeating(AElement); @@ -1020,6 +1030,7 @@ procedure TXMLDataBindingGenerator.ProcessAttribute(ASchema: TXMLDataBindingSche var propertyItem: TXMLDataBindingProperty; propertyType: TXMLDataBindingItem; + namespace: string; begin propertyType := ProcessElement(ASchema, AAttribute); @@ -1033,6 +1044,10 @@ begin AAttribute.Name, AAttribute.DataType); + namespace := AAttribute.SchemaDef.TargetNamespace; + if namespace <> ASchema.TargetNamespace then + propertyItem.TargetNamespace := namespace; + propertyItem.IsOptional := (AAttribute.Use <> UseRequired); propertyItem.IsAttribute := True; @@ -1891,6 +1906,12 @@ end; { TXMLDataBindingProperty } +function TXMLDataBindingProperty.GetHasTargetNamespace: Boolean; +begin + Result := (Length(TargetNamespace) > 0); +end; + + function TXMLDataBindingProperty.GetItemType: TXMLDataBindingItemType; begin Result := itProperty; @@ -1910,6 +1931,7 @@ constructor TXMLDataBindingSimpleProperty.CreateFromAlias(AOwner: TXMLDataBindin begin Create(AOwner, AProperty.SchemaItem, AProperty.Name, ADataType); + // #ToDo1 -oMvR: 6-4-2012: iets met TargetNamespace?? IsAttribute := AProperty.IsAttribute; IsOptional := AProperty.IsOptional; IsNillable := AProperty.IsNillable;