diff --git a/Units/DelphiXMLDataBindingGenerator.pas b/Units/DelphiXMLDataBindingGenerator.pas index 55df5ce..3304533 100644 --- a/Units/DelphiXMLDataBindingGenerator.pas +++ b/Units/DelphiXMLDataBindingGenerator.pas @@ -1068,6 +1068,8 @@ var value: String; propertyItemName: String; fieldName: String; + writeStream: Boolean; + typeMapping: TTypeMapping; begin Result := False; @@ -1084,6 +1086,15 @@ begin writeOptional := not Assigned(AProperty.Collection) and AProperty.IsOptional; + writeStream := False; + if (AMember = dxmPropertyGet) and (AProperty.PropertyType = ptSimple) then + begin + if GetDataTypeMapping(TXMLDataBindingSimpleProperty(AProperty).DataType, typeMapping) then + writeStream := (typeMapping.Conversion = tcBase64); + end; + + + dataTypeName := ''; propertyItem := nil; @@ -1146,6 +1157,9 @@ begin if writeTextProp then sourceCode.Add(PropertyIntfMethodGetText); + if writeStream then + sourceCode.Add(PropertyIntfMethodStream); + sourceCode.Add(PropertyIntfMethodGet); end; @@ -1216,6 +1230,9 @@ begin else sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]); + if writeStream then + sourceCode.Add(PropertyImplMethodStream[GetDelphiElementType(AProperty)]); + sourceCode.Add('function TXML%:s.Get%:s: %:s;'); case AProperty.PropertyType of diff --git a/Units/DelphiXMLDataBindingResources.pas b/Units/DelphiXMLDataBindingResources.pas index 9c2649d..2d6cb6e 100644 --- a/Units/DelphiXMLDataBindingResources.pas +++ b/Units/DelphiXMLDataBindingResources.pas @@ -105,6 +105,7 @@ const PropertyIntfMethodSetNil = ' procedure Set%:sIsNil(const Value: Boolean);'; PropertyIntfMethodSetText = ' procedure Set%:sText(const Value: WideString);'; PropertyIntfMethodSet = ' procedure Set%:s(const Value: %:s);'; + PropertyIntfMethodStream = ' procedure Save%:sToStream(AStream: TStream);'; PropertyInterfaceOptional = ' property Has%:s: Boolean read GetHas%:s;'; PropertyInterfaceNilReadOnly = ' property %:sIsNil: Boolean read Get%:sIsNil;'; @@ -213,10 +214,27 @@ const PropertyImplMethodSetTextAttr = 'procedure TXML%:s.Set%:sText(const Value: WideString);' + CrLf + 'begin' + CrLf + - ' AttributeNodes[''%:s''].NodeValue := Value;' + CrLf + + ' AttributeNodes[''%:s''].NodeValue := Value;' + CrLf + 'end;' + CrLf + '' + CrLf; + PropertyImplMethodStream: array[TDelphiElementType] of string = + ( + { dntElement } + 'procedure TXML%:s.Save%:sToStream(AStream: TStream);' + CrLf + + 'begin' + CrLf + + ' Base64DecodeToStream(Trim(ChildNodes[''%:s''].Text), AStream);' + CrLf + + 'end;' + CrLf + + '' + CrLf, + + { dntElementNS } + 'procedure TXML%:s.Save%:sToStream(AStream: TStream);' + CrLf + + 'begin' + CrLf + + ' Base64DecodeToStream(Trim(ChildNodes.FindNode(''%:s'', ''%:s'').Text), AStream);' + CrLf + + 'end;' + CrLf + + '' + CrLf + ); + SectionComments: array[TDelphiXMLSection] of String = ( diff --git a/Units/XMLDataBindingGenerator.pas b/Units/XMLDataBindingGenerator.pas index 92592ae..b5c5337 100644 --- a/Units/XMLDataBindingGenerator.pas +++ b/Units/XMLDataBindingGenerator.pas @@ -657,7 +657,8 @@ var schemaDef: IXMLSchemaDef; simpleTypeIndex: Integer; simpleType: IXMLSimpleTypeDef; - enumerationObject: TXMLDataBindingEnumeration; + enumerationObject: TXMLDataBindingEnumeration; + baseType: IXMLTypeDef; begin schemaDef := ASchema.SchemaDef; @@ -670,6 +671,15 @@ begin begin enumerationObject := TXMLDataBindingEnumeration.Create(Self, simpleType, simpleType.Enumerations, simpleType.Name, False); ASchema.AddItem(enumerationObject); + end else if simpleType.DerivationMethod = sdmRestriction then + begin + baseType := simpleType.BaseType; + + while Assigned(baseType.BaseType) do + baseType := baseType.BaseType; + + if not baseType.IsComplex then + ASchema.AddItem(TXMLDataBindingSimpleTypeAliasItem.Create(Self, baseType, simpleType.Name)); end; end; end; @@ -837,7 +847,7 @@ begin for attributeIndex := 0 to Pred(AElement.AttributeDefs.Count) do ProcessAttribute(ASchema, AElement.AttributeDefs[attributeIndex], interfaceObject); - end else if AElement.IsGlobal then + end else {if AElement.IsGlobal then} begin { Non-anonymous non-complex type. Assume somewhere in there is a built-in type. diff --git a/X2XMLDataBinding.dproj b/X2XMLDataBinding.dproj index 98cf5d2..9da07c0 100644 --- a/X2XMLDataBinding.dproj +++ b/X2XMLDataBinding.dproj @@ -24,7 +24,7 @@ Delphi.Personality -FalseTrueFalse"P:\test\XMLDataBinding\Tests\Data\01. Basic simple and complex types.xsd"FalseFalse1000FalseFalseFalseFalseFalse104312521.0.0.01.0.0.0X2XMLDataBinding.dpr +FalseTrueFalseP:\hyundai\DealerAccessoryMsg_v0101.xsdFalseFalse1000FalseFalseFalseFalseFalse104312521.0.0.01.0.0.0X2XMLDataBinding.dpr