unit DelphiXMLDataBindingResources; // #ToDo1 -oMvR: 6-4-2012: namespace support voor attributes interface type TDelphiXMLSection = (dxsForward, dxsInterface, dxsClass, dxsImplementation); TDelphiXMLMember = (dxmPropertyGet, dxmPropertySet, dxmPropertyMethods, dxmPropertyDeclaration); TDelphiAccessor = (daGet, daSet); TDelphiNodeType = (dntElement, dntElementNS, dntAttribute, dntNodeValue, dntCustom); TDelphiElementType = dntElement..dntElementNS; const CrLf = #13#10; UnitHeader = '{' + CrLf + ' X2Software XML Data Binding' + CrLf + '' + CrLf + ' Generated on: %:s' + CrLf + ' Generated from: %:s' + CrLf + '}' + CrLf + 'unit %:s;' + CrLf + '' + CrLf; UnitInterface = 'interface' + CrLf + 'uses' + CrLf + '%:s' + ' Classes,' + CrLf + ' SysUtils,' + CrLf + ' XMLDoc,' + CrLf + ' XMLIntf,' + CrLf + ' XMLDataBindingUtils;' + CrLf + '' + CrLf + 'type' + CrLf; UnitImplementation = 'implementation' + CrLf; UnitFooter = '' + CrLf + 'end.' + CrLf; DocumentBinding = 'GetDocBinding(''%:s'', TXML%:s, TargetNamespace) as IXML%:s'; DocumentFunctionsInterface = ' function Get%:s(ADocument: XMLIntf.IXMLDocument): IXML%:s;' + CrLf + ' function Load%:s(const AFileName: String): IXML%:s;' + CrLf + ' function Load%:sFromStream(AStream: TStream): IXML%:s;' + CrLf + ' function Load%:sFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding = nil; AOwnsEncoding: Boolean = True{$IFEND}): IXML%:s;' + CrLf + ' function New%:s: IXML%:s;' + CrLf; DocumentFunctionsImplementation = 'function Get%:s(ADocument: XMLIntf.IXMLDocument): IXML%:s;' + CrLf + 'begin' + CrLf + ' Result := ADocument.' + DocumentBinding + CrLf + 'end;' + CrLf + '' + CrLf + 'function Load%:s(const AFileName: String): IXML%:s;' + CrLf + 'begin' + CrLf + ' Result := LoadXMLDocument(AFileName).' + DocumentBinding + CrLf + 'end;' + CrLf + '' + CrLf + 'function Load%:sFromStream(AStream: TStream): IXML%:s;' + CrLf + 'var' + CrLf + ' doc: XMLIntf.IXMLDocument;' + CrLf + '' + CrLf + 'begin' + CrLf + ' doc := NewXMLDocument;' + CrLf + ' doc.LoadFromStream(AStream);' + CrLf + ' Result := Get%:s(doc);' + CrLf + 'end;' + CrLf + '' + CrLf + 'function Load%:sFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding; AOwnsEncoding: Boolean{$IFEND}): IXML%:s;' + CrLf + 'var' + CrLf + ' stream: TStringStream;' + CrLf + '' + CrLf + 'begin' + CrLf + ' {$IF CompilerVersion >= 20}' + CrLf + ' if Assigned(AEncoding) then' + CrLf + ' stream := TStringStream.Create(AString, AEncoding, AOwnsEncoding)' + CrLf + ' else' + CrLf + ' {$IFEND}' + CrLf + ' stream := TStringStream.Create(AString);' + CrLf + ' try' + CrLf + ' Result := Load%:sFromStream(stream);' + CrLf + ' finally' + CrLf + ' FreeAndNil(stream);' + CrLf + ' end;' + CrLf + 'end;' + CrLf + '' + CrLf + 'function New%:s: IXML%:s;' + CrLf + 'begin' + CrLf + ' Result := NewXMLDocument.' + DocumentBinding + CrLf + 'end;' + CrLf + '' + CrLf; XSDValidateInterface = 'IXSDValidate, IXSDValidateStrict'; XSDValidateDocumentMethodInterface = ' procedure XSDValidateDocument(AStrict: Boolean = False);'; XSDValidateDocumentMethodImplementation = 'procedure TXML%:s.XSDValidateDocument(AStrict: Boolean);' + CrLf + 'begin' + CrLf + ' if AStrict then' + CrLf + ' XMLDataBindingUtils.XSDValidateStrict(Self)' + CrLf + ' else' + CrLf + ' XMLDataBindingUtils.XSDValidate(Self);' + CrLf + 'end;' + CrLf; XSDValidateMethodInterface = ' procedure XSDValidate;' + CrLf + ' procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);'; XSDValidateMethodImplementationBegin = 'procedure TXML%:s.XSDValidate;' + CrLf + 'begin'; XSDValidateMethodImplementationRequired = ' CreateRequiredElements(Self, [%:s], [%:s]);'; XSDValidateMethodImplementationComplex = ' Get%:s;'; XSDValidateMethodImplementationAttrib = ' CreateRequiredAttributes(Self, [%:s]);'; XSDValidateMethodImplementationSort = ' SortChildNodes(Self, [%:s]);'; XSDValidateMethodImplementationArrayBreak = #13#10 + ' '; XSDValidateMethodImplementationEnd = 'end;' + CrLf; XSDValidateStrictMethodImplementationBegin = 'procedure TXML%:s.XSDValidateStrict(AResult: IXSDValidateStrictResult);' + CrLf + 'begin'; XSDValidateStrictMethodImplementationRequired = ' ValidateRequiredElements(AResult, Self, [%:s]);'; XSDValidateStrictMethodImplementationAttrib = ' ValidateRequiredAttributes(AResult, Self, [%:s]);'; XSDValidateStrictMethodImplementationEnd = 'end;' + CrLf; EnumeratorMethodInterface = ' function GetEnumerator: IXML%:sEnumerator;'; EnumeratorMethodImplementation = 'function TXML%:s.GetEnumerator: IXML%:sEnumerator;' + CrLf + 'begin' + CrLf + ' Result := TXML%:sEnumerator.Create(Self);' + CrLf + 'end;' + CrLf; EnumeratorInterface = ' IXML%:sEnumerator = interface' + CrLf + ' %:s' + CrLf + ' function GetCurrent: %:s;' + CrLf + ' function MoveNext: Boolean;' + CrLf + ' property Current: %:s read GetCurrent;' + CrLf + ' end;' + CrLf; EnumeratorClass = ' TXML%:sEnumerator = class(TXMLNodeCollectionEnumerator, IXML%:sEnumerator)' + CrLf + ' protected' + CrLf + ' function GetCurrent: %:s;' + CrLf + ' end;' + CrLf; EnumeratorImplementation = 'function TXML%:sEnumerator.GetCurrent: %:s;' + CrLf + 'begin' + CrLf + ' Result := (inherited GetCurrent as %:s);' + CrLf + 'end;' + CrLf; PropertyIntfMethodGetOptional = ' function GetHas%:s: Boolean;'; PropertyIntfMethodGetOptionalOrDefault = ' function %:sDef(const ADefaultValue: %:s = Default(%:s)): %:s;'; PropertyIntfMethodGetNil = ' function Get%:sIsNil: Boolean;'; PropertyIntfMethodGetText = ' function Get%:sText: WideString;'; PropertyIntfMethodGet = ' function Get%:s: %:s;'; PropertyIntfMethodSetNil = ' procedure Set%:sIsNil(const Value: Boolean);'; PropertyIntfMethodSetText = ' procedure Set%:sText(const Value: WideString);'; PropertyIntfMethodSet = ' procedure Set%:s(const Value: %:s);'; PropertyIntfMethodLoadFromStream = ' procedure Load%:sFromStream(AStream: TStream);'; PropertyIntfMethodLoadFromFile = ' procedure Load%:sFromFile(const AFileName: string);'; PropertyIntfMethodSaveToStream = ' procedure Save%:sToStream(AStream: TStream);'; PropertyIntfMethodSaveToFile = ' procedure Save%:sToFile(const AFileName: string);'; PropertyInterfaceOptional = ' property Has%:s: Boolean read GetHas%:s;'; PropertyInterfaceNilReadOnly = ' property %:sIsNil: Boolean read Get%:sIsNil;'; PropertyInterfaceNil = ' property %:sIsNil: Boolean read Get%:sIsNil write Set%:sIsNil;'; PropertyInterfaceTextReadOnly = ' property %:sText: WideString read Get%:sText;'; PropertyInterfaceReadOnly = ' property %:s: %:s read Get%:s;'; PropertyInterfaceText = ' property %:sText: WideString read Get%:sText write Set%:sText;'; PropertyInterface = ' property %:s: %:s read Get%:s write Set%:s;'; PropertyImplMethodGetOptionalOrDefault = 'function TXML%:s.%:sDef(const ADefaultValue: %:s): %:s;' + CrLf + 'begin' + CrLf + ' if GetHas%:s then' + CrLf + ' Result := Get%:s' + CrLf + ' else' + CrLf + ' Result := ADefaultValue;' + 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 + ' Result := Assigned(AttributeNodes.FindNode(''%:s''));' + CrLf + 'end;' + CrLf + '' + CrLf; PropertyImplMethodGetOptionalEmpty: array[TDelphiElementType] of string = ( { dntElement } 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + 'begin' + CrLf + ' Result := Assigned(ChildNodes.FindNode(''%:s'')) and (Length(ChildNodes[''%:s''].Text) > 0);' + CrLf + 'end;' + CrLf + '' + CrLf, { dntElementNS } 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + 'begin' + CrLf + ' Result := Assigned(ChildNodes.FindNode(''%:s'', ''%:s'')) and (Length(ChildNodesNS[''%:s'', ''%:s''].Text) > 0);' + CrLf + 'end;' + CrLf + '' + CrLf ); PropertyImplMethodGetOptionalAttrEmpty = 'function TXML%:s.GetHas%:s: Boolean;' + CrLf + 'begin' + CrLf + ' Result := Assigned(AttributeNodes.FindNode(''%:s'')) and (Length(AttributeNodes[''%:s''].Text) > 0);' + 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, { dntElementNS } 'function TXML%:s.Get%:sIsNil: Boolean;' + CrLf + 'begin' + CrLf + ' Result := GetNodeIsNil(ChildNodesNS[''%:s'', ''%:s'']);' + 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(ChildNodesNS[''%: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 := ChildNodesNS[''%:s'', ''%:s''].Text;' + CrLf + 'end;' + CrLf + '' + CrLf ); PropertyImplMethodGetTextAttr = 'function TXML%:s.Get%:sText: WideString;' + CrLf + 'begin' + CrLf + ' Result := AttributeNodes[''%:s''].Text;' + 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 + ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := Value;' + CrLf + 'end;' + CrLf + '' + CrLf ); PropertyImplMethodSetTextAttr = 'procedure TXML%:s.Set%:sText(const Value: WideString);' + CrLf + 'begin' + CrLf + ' AttributeNodes[''%:s''].NodeValue := Value;' + CrLf + 'end;' + CrLf + '' + CrLf; PropertyImplMethodLoadFromStream: array[TDelphiElementType] of string = ( { dntElement } 'procedure TXML%:s.Load%:sFromStream(AStream: TStream);' + CrLf + 'begin' + CrLf + ' ChildNodes[''%:s''].NodeValue := Base64EncodeFromStream(AStream);' + CrLf + 'end;' + CrLf + '' + CrLf, { dntElementNS } 'procedure TXML%:s.Load%:sFromStream(AStream: TStream);' + CrLf + 'begin' + CrLf + ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := Base64EncodeFromStream(AStream);' + CrLf + 'end;' + CrLf + '' + CrLf ); PropertyImplMethodLoadFromFile: array[TDelphiElementType] of string = ( { dntElement } 'procedure TXML%:s.Load%:sFromFile(const AFileName: string);' + CrLf + 'begin' + CrLf + ' ChildNodes[''%:s''].NodeValue := Base64EncodeFromFile(AFileName);' + CrLf + 'end;' + CrLf + '' + CrLf, { dntElementNS } 'procedure TXML%:s.Load%:sFromFile(const AFileName: string);' + CrLf + 'begin' + CrLf + ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := Base64EncodeFromFile(AFileName);' + CrLf + 'end;' + CrLf + '' + CrLf ); PropertyImplMethodSaveToStream: 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(ChildNodesNS[''%:s'', ''%:s''].Text), AStream);' + CrLf + 'end;' + CrLf + '' + CrLf ); PropertyImplMethodSaveToFile: array[TDelphiElementType] of string = ( { dntElement } 'procedure TXML%:s.Save%:sToFile(const AFileName: string);' + CrLf + 'begin' + CrLf + ' Base64DecodeToFile(Trim(ChildNodes[''%:s''].Text), AFileName);' + CrLf + 'end;' + CrLf + '' + CrLf, { dntElementNS } 'procedure TXML%:s.Save%:sToFile(const AFileName: string);' + CrLf + 'begin' + CrLf + ' Base64DecodeToFile(Trim(ChildNodesNS[''%:s'', ''%:s''].Text), AFileName);' + CrLf + 'end;' + CrLf + '' + CrLf ); SectionComments: array[TDelphiXMLSection] of String = ( ' { Forward declarations for %:s }', ' { Interfaces for %:s }', ' { Classes for %:s }', '{ Implementation for %:s }' ); PrefixInterface = 'IXML'; PrefixClass = 'TXML'; PrefixField = 'F'; InterfaceItemForward = ' IXML%:s = interface;'; InterfaceItemInterface = ' IXML%:s = interface(%:s)'; InterfaceItemClass = ' TXML%:s = class(%:s, IXML%:s)'; CollectionInterface = 'IXMLNodeCollection'; CollectionClass = 'TX2XMLNodeCollection'; ItemInterface = 'IXMLNode'; ItemClass = 'TX2XMLNode'; // #ToDo1 (MvR) 9-3-2008: document / node / etc // #ToDo1 (MvR) 9-3-2008: WideString etc ? ReservedWords: array[0..107] of String = ( 'absolute', 'abstract', 'and', 'array', 'as', 'asm', 'assembler', {'automated', }'begin', 'case', 'cdecl', 'class', 'const', 'constructor', {'contains', }'default', 'deprecated', 'destructor', 'dispid', 'dispinterface', 'div', 'do', 'downto', 'dynamic', 'else', 'end', 'except', 'export', 'exports', 'external', 'far', 'file', {'final', }'finalization', 'finally', 'for', 'forward', 'function', 'goto', 'if', 'implementation', 'implements', 'in', 'index', 'inherited', 'initialization', 'inline', 'interface', 'is', 'label', 'library', 'local', 'message', 'mod', {'name', }'near', 'nil', 'nodefault', 'not', 'object', 'of', 'or', 'out', 'overload', 'override', 'package', 'packed', 'pascal', 'platform', 'private', 'procedure', 'program', 'property', 'protected', 'public', 'published', 'raise', 'read', 'readonly', 'record', 'register', 'reintroduce', 'repeat', 'requires', 'resident', 'resourcestring', 'safecall', 'sealed', 'set', 'shl', 'shr', 'static', 'stdcall', 'stored', 'string', 'then', 'threadvar', 'to', 'try', 'type', 'unit', 'unsafe', 'until', 'uses', 'var', 'varargs', 'virtual', 'while', 'with', 'write', 'writeonly', 'xor' ); SafeChars = ['A'..'Z', 'a'..'z', '0'..'9', '_']; type TTypeConversion = (tcNone, tcBoolean, tcFloat, tcDateTime, tcDate, tcTime, tcString, tcBase64, tcNode); TTypeConversions = set of TTypeConversion; TTypeMapping = record SchemaName: String; DelphiName: String; Conversion: TTypeConversion; end; const SimpleTypeMapping: array[0..41] of TTypeMapping = ( { built-in primitive datatypes } (SchemaName: 'string'; DelphiName: 'WideString'; Conversion: tcString), // (SchemaName: 'boolean'; DelphiName: 'Boolean'; Conversion: tcBoolean), // (SchemaName: 'decimal'; DelphiName: 'Double'; Conversion: tcFloat), // (SchemaName: 'float'; DelphiName: 'Double'; Conversion: tcFloat), // (SchemaName: 'double'; DelphiName: 'Double'; Conversion: tcFloat), // (SchemaName: 'duration'; DelphiName: 'WideString'; Conversion: tcString), // TODO: convert duration to ?? (SchemaName: 'dateTime'; DelphiName: 'TDateTime'; Conversion: tcDateTime), // (SchemaName: 'time'; DelphiName: 'TDateTime'; Conversion: tcTime), // (SchemaName: 'date'; DelphiName: 'TDateTime'; Conversion: tcDate), // (SchemaName: 'gYearMonth'; DelphiName: 'WideString'; Conversion: tcString), // TODO: convert gYearMonth (SchemaName: 'gYear'; DelphiName: 'WideString'; Conversion: tcString), // TODO: convert gYear (SchemaName: 'gMonthDay'; DelphiName: 'WideString'; Conversion: tcString), // TODO: convert gMonthDay (SchemaName: 'gDay'; DelphiName: 'WideString'; Conversion: tcString), // TODO: convert gDay (SchemaName: 'gMonth'; DelphiName: 'WideString'; Conversion: tcString), // TODO: convert gMonth (SchemaName: 'hexBinary'; DelphiName: 'WideString'; Conversion: tcString), // (SchemaName: 'base64Binary'; DelphiName: 'WideString'; Conversion: tcBase64), // (SchemaName: 'anyURI'; DelphiName: 'WideString'; Conversion: tcString), // (SchemaName: 'QName'; DelphiName: 'WideString'; Conversion: tcString), // (SchemaName: 'NOTATION'; DelphiName: 'WideString'; Conversion: tcString), // { built-in derivative datatypes } (SchemaName: 'normalizedString'; DelphiName: 'WideString'; Conversion: tcString), // string (SchemaName: 'token'; DelphiName: 'WideString'; Conversion: tcString), // normalizedString (SchemaName: 'language'; DelphiName: 'WideString'; Conversion: tcString), // token (SchemaName: 'NMTOKEN'; DelphiName: 'WideString'; Conversion: tcString), // token (SchemaName: 'Name'; DelphiName: 'WideString'; Conversion: tcString), // token (SchemaName: 'NCName'; DelphiName: 'WideString'; Conversion: tcString), // Name (SchemaName: 'ID'; DelphiName: 'WideString'; Conversion: tcString), // NCName (SchemaName: 'IDREF'; DelphiName: 'WideString'; Conversion: tcString), // NCName (SchemaName: 'ENTITY'; DelphiName: 'WideString'; Conversion: tcString), // NCName (SchemaName: 'integer'; DelphiName: 'Int64'; Conversion: tcNone), // decimal (SchemaName: 'nonPositiveInteger'; DelphiName: 'Int64'; Conversion: tcNone), // integer (SchemaName: 'negativeInteger'; DelphiName: 'Int64'; Conversion: tcNone), // nonPositiveInteger (SchemaName: 'long'; DelphiName: 'Int64'; Conversion: tcNone), // integer (SchemaName: 'int'; DelphiName: 'Integer'; Conversion: tcNone), // long (SchemaName: 'short'; DelphiName: 'SmallInt'; Conversion: tcNone), // int (SchemaName: 'byte'; DelphiName: 'ShortInt'; Conversion: tcNone), // short (SchemaName: 'nonNegativeInteger'; DelphiName: 'UInt64'; Conversion: tcNone), // integer (SchemaName: 'unsignedLong'; DelphiName: 'UInt64'; Conversion: tcNone), // nonNegativeInteger (SchemaName: 'unsignedInt'; DelphiName: 'Cardinal'; Conversion: tcNone), // unsignedLong (SchemaName: 'unsignedShort'; DelphiName: 'Word'; Conversion: tcNone), // unsignedInt (SchemaName: 'unsignedByte'; DelphiName: 'Byte'; Conversion: tcNone), // unsignedShort (SchemaName: 'positiveInteger'; DelphiName: 'UInt64'; Conversion: tcNone), // nonNegativeInteger { any other type } (SchemaName: 'anyType'; DelphiName: 'IXMLNode'; Conversion: tcNode) ); TypeConversionReqUtils: array[TTypeConversion] of Boolean = ( { tcNone } False, { tcBoolean } True, { tcFloat } True, { tcDateTime } True, { tcDate } True, { tcTime } True, { tcString } True, { tcBase64 } True, { tcNone } False ); TypeConversionNone: array[TDelphiAccessor, TDelphiNodeType] of String = ( { daGet } ( { dntElement } ' %:s := ChildNodes[''%:s''].NodeValue;', { dntElementNS } ' %:s := ChildNodesNS[''%:s'', ''%:s''].NodeValue;', { dntAttribute } ' %:s := AttributeNodes[''%:s''].NodeValue;', { dntNodeValue } ' %:s := GetNodeValue;', { dntCustom } ' %:s := %:s;' ), { daSet } ( { dntElement } ' ChildNodes[''%:s''].NodeValue := %:s;', { dntElementNS } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := %:s;', { dntAttribute } ' SetAttribute(''%:s'', %:s);', { dntNodeValue } ' SetNodeValue(%:s);', { dntCustom } ' %:s := %:s;' ) ); TypeConversion: array[TDelphiAccessor, TDelphiNodeType, TTypeConversion] of String = ( { daGet } ( { dntElement } ( { tcNone } '', { tcBoolean } '', { tcFloat } ' %:s := XMLToFloat(ChildNodes[''%:s''].NodeValue);', { tcDateTime } ' %:s := XMLToDateTime(ChildNodes[''%:s''].NodeValue, xdtDateTime);', { tcDate } ' %:s := XMLToDateTime(ChildNodes[''%:s''].NodeValue, xdtDate);', { tcTime } ' %:s := XMLToDateTime(ChildNodes[''%:s''].NodeValue, xdtTime);', { tcString } ' %:s := ChildNodes[''%:s''].Text;', { tcBase64 } ' %:s := Base64Decode(Trim(ChildNodes[''%:s''].Text));', { tcNode } ' %:s := ChildNodes[''%:s''];' ), { dntElementNS } ( { tcNone } '', { tcBoolean } '', { tcFloat } ' %:s := XMLToFloat(ChildNodesNS[''%:s'', ''%:s''].NodeValue);', { tcDateTime } ' %:s := XMLToDateTime(ChildNodesNS[''%:s'', ''%:s''].NodeValue, xdtDateTime);', { tcDate } ' %:s := XMLToDateTime(ChildNodesNS[''%:s'', ''%:s''].NodeValue, xdtDate);', { tcTime } ' %:s := XMLToDateTime(ChildNodesNS[''%:s'', ''%:s''].NodeValue, xdtTime);', { tcString } ' %:s := ChildNodesNS[''%:s'', ''%:s''].Text;', { tcBase64 } ' %:s := Base64Decode(Trim(ChildNodesNS[''%:s'', ''%:s''].Text));', { tcNode } ' %:s := ChildNodesNS[''%:s'', ''%:s''];' ), { dntAttribute } ( { tcNone } '', { tcBoolean } '', { tcFloat } ' %:s := XMLToFloat(AttributeNodes[''%:s''].NodeValue);', { tcDateTime } ' %:s := XMLToDateTime(AttributeNodes[''%:s''].NodeValue, xdtDateTime);', { tcDate } ' %:s := XMLToDateTime(AttributeNodes[''%:s''].NodeValue, xdtDate);', { tcTime } ' %:s := XMLToDateTime(AttributeNodes[''%:s''].NodeValue, xdtTime);', { tcString } ' %:s := AttributeNodes[''%:s''].Text;', { tcBase64 } ' %:s := Base64Decode(Trim(AttributeNodes[''%:s''].Text));', { tcNode } ' %:s := AttributeNodes[''%:s''];' ), { dntNodeValue } ( { tcNone } '', { tcBoolean } '', { tcFloat } ' %:s := XMLToFloat(GetNodeValue);', { tcDateTime } ' %:s := XMLToDateTime(GetNodeValue, xdtDateTime);', { tcDate } ' %:s := XMLToDateTime(GetNodeValue, xdtDate);', { tcTime } ' %:s := XMLToDateTime(GetNodeValue, xdtTime);', { tcString } ' %:s := VarToStr(GetNodeValue);', { tcBase64 } ' %:s := Base64Decode(Trim(GetNodeValue));', { tcNode } '' ), { dntCustom} ( { tcNone } '', { tcBoolean } '', { tcFloat } ' %:s := XMLToFloat(%:s);', { tcDateTime } ' %:s := XMLToDateTime(%:s, xdtDateTime);', { tcDate } ' %:s := XMLToDateTime(%:s, xdtDate);', { tcTime } ' %:s := XMLToDateTime(%:s, xdtTime);', { tcString } '', { tcBase64 } ' %:s := Base64Decode(Trim(%:s));', { tcNode } '' ) ), { daSet } ( { dntElement } ( { tcNone } '', { tcBoolean } ' ChildNodes[''%:s''].NodeValue := BoolToXML(%:s);', { tcFloat } ' ChildNodes[''%:s''].NodeValue := FloatToXML(%:s);', { tcDateTime } ' ChildNodes[''%:s''].NodeValue := DateTimeToXML(%:s, xdtDateTime);', { tcDate } ' ChildNodes[''%:s''].NodeValue := DateTimeToXML(%:s, xdtDate);', { tcTime } ' ChildNodes[''%:s''].NodeValue := DateTimeToXML(%:s, xdtTime);', { tcString } ' ChildNodes[''%:s''].NodeValue := GetValidXMLText(%:s);', { tcBase64 } ' ChildNodes[''%:s''].NodeValue := Base64Encode(%:s);', { tcNode } ' ChildNodes[''%:s''] := %:s;' ), { dntElementNS } ( { tcNone } '', { tcBoolean } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := BoolToXML(%:s);', { tcFloat } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := FloatToXML(%:s);', { tcDateTime } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := DateTimeToXML(%:s, xdtDateTime);', { tcDate } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := DateTimeToXML(%:s, xdtDate);', { tcTime } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := DateTimeToXML(%:s, xdtTime);', { tcString } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := GetValidXMLText(%:s);', { tcBase64 } ' ChildNodesNS[''%:s'', ''%:s''].NodeValue := Base64Encode(%:s);', { tcNode } ' ChildNodesNS[''%:s'', ''%:s''] := %:s;' ), { dntAttribute } ( { tcNone } '', { tcBoolean } ' SetAttribute(''%:s'', BoolToXML(%:s));', { tcFloat } ' SetAttribute(''%:s'', FloatToXML(%:s));', { tcDateTime } ' SetAttribute(''%:s'', DateTimeToXML(%:s, xdtDateTime));', { tcDate } ' SetAttribute(''%:s'', DateTimeToXML(%:s, xdtDate));', { tcTime } ' SetAttribute(''%:s'', DateTimeToXML(%:s, xdtTime));', { tcString } ' SetAttribute(''%:s'', GetValidXMLText(%:s));', { tcBase64 } ' SetAttribute(''%:s'', Base64Encode(%:s));', { tcNode } '' ), { dntNodeValue } ( { tcNone } '', { tcBoolean } ' SetNodeValue(BoolToXML(%:s));', { tcFloat } ' SetNodeValue(FloatToXML(%:s));', { tcDateTime } ' SetNodeValue(DateTimeToXML(%:s, xdtDateTime));', { tcDate } ' SetNodeValue(DateTimeToXML(%:s, xdtDate));', { tcTime } ' SetNodeValue(DateTimeToXML(%:s, xdtTime));', { tcString } ' SetNodeValue(GetValidXMLText(%:s));', { tcBase64 } ' SetNodeValue(Base64Encode(%:s));', { tcNode } '' ), { dntCustom} ( { tcNone } '', { tcBoolean } ' %:s := BoolToXML(%:s);', { tcFloat } ' %:s := FloatToXML(%:s);', { tcDateTime } ' %:s := DateTimeToXML(%:s, xdtDateTime);', { tcDate } ' %:s := DateTimeToXML(%:s, xdtDate);', { tcTime } ' %:s := DateTimeToXML(%:s, xdtTime);', { tcString } ' %:s := GetValidXMLText(%:s);', { tcBase64 } ' %:s := Base64Encode(%:s);', { tcNode } '' ) ) ); implementation end.