2008-03-21 15:23:14 +00:00
unit DelphiXMLDataBindingResources;
2012-04-10 08:47:48 +00:00
// #ToDo1 -oMvR: 6-4-2012: namespace support voor attributes
2008-03-21 15:23:14 +00:00
interface
type
TDelphiXMLSection = ( dxsForward, dxsInterface, dxsClass, dxsImplementation) ;
2014-08-25 18:26:12 +00:00
TDelphiXMLMember = ( dxmPropertyGet, dxmPropertySet, dxmPropertyMethods, dxmPropertyDeclaration) ;
2008-04-14 19:28:57 +00:00
TDelphiAccessor = ( daGet, daSet) ;
2012-04-10 08:47:48 +00:00
TDelphiNodeType = ( dntElement, dntElementNS, dntAttribute, dntNodeValue, dntCustom) ;
TDelphiElementType = dntElement.. dntElementNS;
2008-03-21 15:23:14 +00:00
const
CrLf = #13 #10 ;
UnitHeader = '{' + CrLf +
2008-04-22 13:36:55 +00:00
' X2Software XML Data Binding' + CrLf +
'' + CrLf +
' Generated on: %<DateTime>:s' + CrLf +
2008-03-21 15:23:14 +00:00
' Generated from: %<SourceFileName>:s' + CrLf +
'}' + CrLf +
'unit %<UnitName>:s;' + CrLf +
'' + CrLf;
UnitInterface = 'interface' + CrLf +
'uses' + CrLf +
2008-04-14 19:28:57 +00:00
'%<UsesClause>:s' +
2008-03-21 15:23:14 +00:00
' Classes,' + CrLf +
2014-12-09 14:26:11 +00:00
' SysUtils,' + CrLf +
2008-03-21 15:23:14 +00:00
' XMLDoc,' + CrLf +
2010-07-15 10:57:03 +00:00
' XMLIntf,' + CrLf +
' XMLDataBindingUtils;' + CrLf +
2008-03-21 15:23:14 +00:00
'' + CrLf +
'type' + CrLf;
2008-04-24 14:37:05 +00:00
UnitImplementation = 'implementation' + CrLf;
2008-03-21 15:23:14 +00:00
UnitFooter = '' + CrLf +
'end.' + CrLf;
DocumentBinding = 'GetDocBinding(' '%<SourceName>:s' ', TXML%<Name>:s, TargetNamespace) as IXML%<Name>:s' ;
2008-07-31 14:56:36 +00:00
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 +
2014-12-09 14:26:11 +00:00
' function Load%<Name>:sFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding = nil; AOwnsEncoding: Boolean = True{$IFEND}): IXML%<Name>:s;' + CrLf +
2008-07-31 14:56:36 +00:00
' function New%<Name>:s: IXML%<Name>:s;' + CrLf;
DocumentFunctionsImplementation = 'function Get%<Name>:s(ADocument: XMLIntf.IXMLDocument): IXML%<Name>:s;' + CrLf +
'begin' + CrLf +
' Result := ADocument.' + DocumentBinding + CrLf +
'end;' + CrLf +
'' + CrLf +
'function Load%<Name>:s(const AFileName: String): IXML%<Name>:s;' + CrLf +
'begin' + CrLf +
' Result := LoadXMLDocument(AFileName).' + DocumentBinding + CrLf +
'end;' + CrLf +
'' + CrLf +
'function Load%<Name>:sFromStream(AStream: TStream): IXML%<Name>:s;' + CrLf +
'var' + CrLf +
' doc: XMLIntf.IXMLDocument;' + CrLf +
'' + CrLf +
'begin' + CrLf +
' doc := NewXMLDocument;' + CrLf +
' doc.LoadFromStream(AStream);' + CrLf +
' Result := Get%<Name>:s(doc);' + CrLf +
'end;' + CrLf +
2013-10-14 15:12:39 +00:00
'' + CrLf +
2014-12-09 14:26:11 +00:00
'function Load%<Name>:sFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding; AOwnsEncoding: Boolean{$IFEND}): IXML%<Name>:s;' + CrLf +
2013-10-14 15:12:39 +00:00
'var' + CrLf +
' stream: TStringStream;' + CrLf +
'' + CrLf +
'begin' + CrLf +
2016-07-21 13:23:20 +00:00
' {$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 +
2013-10-14 15:12:39 +00:00
' try' + CrLf +
' Result := Load%<Name>:sFromStream(stream);' + CrLf +
' finally' + CrLf +
' FreeAndNil(stream);' + CrLf +
' end;' + CrLf +
'end;' + CrLf +
2008-07-31 14:56:36 +00:00
'' + CrLf +
'function New%<Name>:s: IXML%<Name>:s;' + CrLf +
'begin' + CrLf +
' Result := NewXMLDocument.' + DocumentBinding + CrLf +
'end;' + CrLf +
'' + CrLf;
2008-03-21 15:23:14 +00:00
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateInterface = 'IXSDValidate, IXSDValidateStrict' ;
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateDocumentMethodInterface = ' procedure XSDValidateDocument(AStrict: Boolean = False);' ;
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateDocumentMethodImplementation = 'procedure TXML%<Name>:s.XSDValidateDocument(AStrict: Boolean);' + CrLf +
'begin' + CrLf +
' if AStrict then' + CrLf +
' XMLDataBindingUtils.XSDValidateStrict(Self)' + CrLf +
' else' + CrLf +
' XMLDataBindingUtils.XSDValidate(Self);' + CrLf +
'end;' + CrLf;
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateMethodInterface = ' procedure XSDValidate;' + CrLf +
' procedure XSDValidateStrict(AResult: IXSDValidateStrictResult);' ;
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateMethodImplementationBegin = 'procedure TXML%<Name>:s.XSDValidate;' + CrLf +
'begin' ;
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateMethodImplementationRequired = ' CreateRequiredElements(Self, [%<RequiredElements>:s]);' ;
XSDValidateMethodImplementationComplex = ' Get%<Name>:s;' ;
XSDValidateMethodImplementationAttrib = ' CreateRequiredAttributes(Self, [%<RequiredAttributes>:s]);' ;
XSDValidateMethodImplementationSort = ' SortChildNodes(Self, [%<SortOrder>:s]);' ;
XSDValidateMethodImplementationArrayBreak = #13 #10 + ' ' ;
2010-07-15 10:57:03 +00:00
2017-07-19 11:58:31 +00:00
XSDValidateMethodImplementationEnd = 'end;' + CrLf;
XSDValidateStrictMethodImplementationBegin = 'procedure TXML%<Name>:s.XSDValidateStrict(AResult: IXSDValidateStrictResult);' + CrLf +
'begin' ;
XSDValidateStrictMethodImplementationRequired = ' ValidateRequiredElements(AResult, Self, [%<RequiredElements>:s]);' ;
XSDValidateStrictMethodImplementationAttrib = ' ValidateRequiredAttributes(AResult, Self, [%<RequiredAttributes>:s]);' ;
XSDValidateStrictMethodImplementationEnd = 'end;' + CrLf;
2010-07-15 10:57:03 +00:00
2013-07-03 14:59:26 +00:00
EnumeratorMethodInterface = ' function GetEnumerator: IXML%<Name>:sEnumerator;' ;
2013-06-21 11:05:00 +00:00
EnumeratorMethodImplementation = 'function TXML%<Name>:s.GetEnumerator: IXML%<Name>:sEnumerator;' + CrLf +
'begin' + CrLf +
' Result := TXML%<Name>:sEnumerator.Create(Self);' + CrLf +
'end;' + CrLf;
EnumeratorInterface = ' IXML%<Name>:sEnumerator = interface' + CrLf +
' %<GUID>:s' + CrLf +
2013-07-03 14:53:48 +00:00
' function GetCurrent: %<DataType>:s;' + CrLf +
2013-06-21 11:05:00 +00:00
' function MoveNext: Boolean;' + CrLf +
2013-07-03 14:53:48 +00:00
' property Current: %<DataType>:s read GetCurrent;' + CrLf +
2013-06-21 11:05:00 +00:00
' end;' + CrLf;
EnumeratorClass = ' TXML%<Name>:sEnumerator = class(TXMLNodeCollectionEnumerator, IXML%<Name>:sEnumerator)' + CrLf +
' protected' + CrLf +
2013-07-03 14:53:48 +00:00
' function GetCurrent: %<DataType>:s;' + CrLf +
2013-06-21 11:05:00 +00:00
' end;' + CrLf;
2013-07-03 14:53:48 +00:00
EnumeratorImplementation = 'function TXML%<Name>:sEnumerator.GetCurrent: %<DataType>:s;' + CrLf +
2013-06-21 11:05:00 +00:00
'begin' + CrLf +
2013-07-03 14:53:48 +00:00
' Result := (inherited GetCurrent as %<DataType>:s);' + CrLf +
2013-06-21 11:05:00 +00:00
'end;' + CrLf;
2014-08-25 18:26:12 +00:00
PropertyIntfMethodGetOptional = ' function GetHas%<PropertyName>:s: Boolean;' ;
PropertyIntfMethodGetNil = ' function Get%<PropertyName>:sIsNil: Boolean;' ;
PropertyIntfMethodGetText = ' function Get%<PropertyName>:sText: WideString;' ;
PropertyIntfMethodGet = ' function Get%<PropertyName>:s: %<DataType>:s;' ;
PropertyIntfMethodSetNil = ' procedure Set%<PropertyName>:sIsNil(const Value: Boolean);' ;
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);' ;
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);' ;
PropertyIntfMethodLoadFromStream = ' procedure Load%<PropertyName>:sFromStream(AStream: TStream);' ;
PropertyIntfMethodLoadFromFile = ' procedure Load%<PropertyName>:sFromFile(const AFileName: string);' ;
PropertyIntfMethodSaveToStream = ' procedure Save%<PropertyName>:sToStream(AStream: TStream);' ;
PropertyIntfMethodSaveToFile = ' procedure Save%<PropertyName>:sToFile(const AFileName: string);' ;
PropertyInterfaceOptional = ' property Has%<PropertyName>:s: Boolean read GetHas%<PropertyName>:s;' ;
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;' ;
PropertyInterfaceNil = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil write Set%<PropertyName>:sIsNil;' ;
PropertyInterfaceTextReadOnly = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText;' ;
PropertyInterfaceReadOnly = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s;' ;
PropertyInterfaceText = ' property %<PropertyName>:sText: WideString read Get%<PropertyName>:sText write Set%<PropertyName>:sText;' ;
PropertyInterface = ' property %<PropertyName>:s: %<DataType>:s read Get%<PropertyName>:s write Set%<PropertyName>:s;' ;
2008-03-21 15:23:14 +00:00
2012-04-10 08:47:48 +00:00
PropertyImplMethodGetOptional: array [ TDelphiElementType] of string =
(
{ dntElement }
'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
'begin' + CrLf +
' Result := Assigned(ChildNodes.FindNode(' '%<PropertySourceName>:s' '));' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
'begin' + CrLf +
' Result := Assigned(ChildNodes.FindNode(' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '));' + CrLf +
'end;' + CrLf +
'' + CrLf
) ;
2008-03-21 15:23:14 +00:00
2009-09-18 07:49:04 +00:00
PropertyImplMethodGetOptionalAttr = 'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
'begin' + CrLf +
' Result := Assigned(AttributeNodes.FindNode(' '%<PropertySourceName>:s' '));' + CrLf +
'end;' + CrLf +
'' + CrLf;
2017-07-21 07:38:17 +00:00
PropertyImplMethodGetOptionalEmpty: array [ TDelphiElementType] of string =
(
{ dntElement }
'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
'begin' + CrLf +
' Result := Assigned(ChildNodes.FindNode(' '%<PropertySourceName>:s' ')) and (Length(ChildNodes[' '%<PropertySourceName>:s' '].Text) > 0);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
'begin' + CrLf +
' Result := Assigned(ChildNodes.FindNode(' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' ')) and (Length(ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].Text) > 0);' + CrLf +
'end;' + CrLf +
'' + CrLf
) ;
PropertyImplMethodGetOptionalAttrEmpty = 'function TXML%<Name>:s.GetHas%<PropertyName>:s: Boolean;' + CrLf +
'begin' + CrLf +
' Result := Assigned(AttributeNodes.FindNode(' '%<PropertySourceName>:s' ')) and (Length(AttributeNodes[' '%<PropertySourceName>:s' '].Text) > 0);' + CrLf +
'end;' + CrLf +
'' + CrLf;
2012-04-10 08:47:48 +00:00
PropertyImplMethodGetNil: array [ TDelphiElementType] of string =
(
{ dntElement }
'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
'begin' + CrLf +
' Result := GetNodeIsNil(ChildNodes[' '%<PropertySourceName>:s' ']);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'function TXML%<Name>:s.Get%<PropertyName>:sIsNil: Boolean;' + CrLf +
'begin' + CrLf +
2013-06-21 10:25:49 +00:00
' Result := GetNodeIsNil(ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' ']);' + CrLf +
2012-04-10 08:47:48 +00:00
'end;' + CrLf +
'' + CrLf
) ;
2009-09-18 07:49:04 +00:00
2012-04-10 08:47:48 +00:00
PropertyImplMethodSetNil: array [ TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
'begin' + CrLf +
' SetNodeIsNil(ChildNodes[' '%<PropertySourceName>:s' '], Value);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Set%<PropertyName>:sIsNil(const Value: Boolean);' + CrLf +
'begin' + CrLf +
2013-06-21 10:25:49 +00:00
' SetNodeIsNil(ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '], Value);' + CrLf +
2012-04-10 08:47:48 +00:00
'end;' + CrLf +
'' + CrLf
) ;
2008-04-21 15:24:33 +00:00
2012-04-10 08:47:48 +00:00
PropertyImplMethodGetText: array [ TDelphiElementType] of string =
(
{ dntElement }
'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
'begin' + CrLf +
' Result := ChildNodes[' '%<PropertySourceName>:s' '].Text;' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElement }
'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
'begin' + CrLf +
2013-06-21 10:25:49 +00:00
' Result := ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].Text;' + CrLf +
2012-04-10 08:47:48 +00:00
'end;' + CrLf +
'' + CrLf
) ;
2008-03-21 15:23:14 +00:00
2010-06-22 08:27:28 +00:00
PropertyImplMethodGetTextAttr = 'function TXML%<Name>:s.Get%<PropertyName>:sText: WideString;' + CrLf +
'begin' + CrLf +
2013-06-21 10:25:49 +00:00
' Result := AttributeNodes[' '%<PropertySourceName>:s' '].Text;' + CrLf +
2010-06-22 08:27:28 +00:00
'end;' + CrLf +
'' + CrLf;
2012-04-10 08:47:48 +00:00
PropertyImplMethodSetText: array [ TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
'begin' + CrLf +
' ChildNodes[' '%<PropertySourceName>:s' '].NodeValue := Value;' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
'begin' + CrLf +
2013-06-21 10:25:49 +00:00
' ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].NodeValue := Value;' + CrLf +
2012-04-10 08:47:48 +00:00
'end;' + CrLf +
'' + CrLf
) ;
2008-03-21 15:23:14 +00:00
2010-06-22 08:27:28 +00:00
PropertyImplMethodSetTextAttr = 'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
'begin' + CrLf +
2012-04-13 13:33:23 +00:00
' AttributeNodes[' '%<PropertySourceName>:s' '].NodeValue := Value;' + CrLf +
2010-06-22 08:27:28 +00:00
'end;' + CrLf +
'' + CrLf;
2014-08-25 18:26:12 +00:00
PropertyImplMethodLoadFromStream: array [ TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Load%<PropertyName>:sFromStream(AStream: TStream);' + CrLf +
'begin' + CrLf +
' ChildNodes[' '%<PropertySourceName>:s' '].NodeValue := Base64EncodeFromStream(AStream);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Load%<PropertyName>:sFromStream(AStream: TStream);' + CrLf +
'begin' + CrLf +
' ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].NodeValue := Base64EncodeFromStream(AStream);' + CrLf +
'end;' + CrLf +
'' + CrLf
) ;
PropertyImplMethodLoadFromFile: array [ TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Load%<PropertyName>:sFromFile(const AFileName: string);' + CrLf +
'begin' + CrLf +
' ChildNodes[' '%<PropertySourceName>:s' '].NodeValue := Base64EncodeFromFile(AFileName);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Load%<PropertyName>:sFromFile(const AFileName: string);' + CrLf +
'begin' + CrLf +
' ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].NodeValue := Base64EncodeFromFile(AFileName);' + CrLf +
'end;' + CrLf +
'' + CrLf
) ;
PropertyImplMethodSaveToStream: array [ TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Save%<PropertyName>:sToStream(AStream: TStream);' + CrLf +
'begin' + CrLf +
' Base64DecodeToStream(Trim(ChildNodes[' '%<PropertySourceName>:s' '].Text), AStream);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Save%<PropertyName>:sToStream(AStream: TStream);' + CrLf +
'begin' + CrLf +
' Base64DecodeToStream(Trim(ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].Text), AStream);' + CrLf +
'end;' + CrLf +
'' + CrLf
) ;
PropertyImplMethodSaveToFile: array [ TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Save%<PropertyName>:sToFile(const AFileName: string);' + CrLf +
'begin' + CrLf +
' Base64DecodeToFile(Trim(ChildNodes[' '%<PropertySourceName>:s' '].Text), AFileName);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Save%<PropertyName>:sToFile(const AFileName: string);' + CrLf +
'begin' + CrLf +
' Base64DecodeToFile(Trim(ChildNodesNS[' '%<PropertySourceName>:s' ', ' '%<Namespace>:s' '].Text), AFileName);' + CrLf +
'end;' + CrLf +
'' + CrLf
) ;
2008-03-21 15:23:14 +00:00
SectionComments: array [ TDelphiXMLSection] of String =
(
' { Forward declarations for %<SchemaName>:s }' ,
' { Interfaces for %<SchemaName>:s }' ,
' { Classes for %<SchemaName>:s }' ,
'{ Implementation for %<SchemaName>:s }'
) ;
PrefixInterface = 'IXML' ;
PrefixClass = 'TXML' ;
2008-04-14 19:28:57 +00:00
PrefixField = 'F' ;
2008-03-21 15:23:14 +00:00
InterfaceItemForward = ' IXML%<Name>:s = interface;' ;
InterfaceItemInterface = ' IXML%<Name>:s = interface(%<ParentName>:s)' ;
InterfaceItemClass = ' TXML%<Name>:s = class(%<ParentName>:s, IXML%<Name>:s)' ;
CollectionInterface = 'IXMLNodeCollection' ;
2013-06-21 10:25:49 +00:00
CollectionClass = 'TX2XMLNodeCollection' ;
2008-03-21 15:23:14 +00:00
ItemInterface = 'IXMLNode' ;
2013-06-21 10:25:49 +00:00
ItemClass = 'TX2XMLNode' ;
2008-03-21 15:23:14 +00:00
// #ToDo1 (MvR) 9-3-2008: document / node / etc
// #ToDo1 (MvR) 9-3-2008: WideString etc ?
2010-07-14 08:50:33 +00:00
ReservedWords: array [ 0 .. 1 0 7 ] of String =
2008-03-21 15:23:14 +00:00
(
'absolute' , 'abstract' , 'and' , 'array' , 'as' , 'asm' ,
2008-04-22 13:36:55 +00:00
'assembler' , {'automated', } 'begin' , 'case' , 'cdecl' , 'class' ,
'const' , 'constructor' , {'contains', } 'default' , 'deprecated' ,
2008-03-21 15:23:14 +00:00
'destructor' , 'dispid' , 'dispinterface' , 'div' , 'do' ,
'downto' , 'dynamic' , 'else' , 'end' , 'except' , 'export' ,
2010-07-14 08:50:33 +00:00
'exports' , 'external' , 'far' , 'file' , {'final', } 'finalization' ,
2008-03-21 15:23:14 +00:00
'finally' , 'for' , 'forward' , 'function' , 'goto' , 'if' ,
'implementation' , 'implements' , 'in' , 'index' , 'inherited' ,
'initialization' , 'inline' , 'interface' , 'is' , 'label' ,
2008-04-22 13:36:55 +00:00
'library' , 'local' , 'message' , 'mod' , {'name', } 'near' ,
2008-03-21 15:23:14 +00:00
'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'
) ;
2010-07-14 08:50:33 +00:00
SafeChars = [ 'A' .. 'Z' , 'a' .. 'z' , '0' .. '9' , '_' ] ;
2008-04-18 14:36:17 +00:00
2008-03-21 15:23:14 +00:00
type
2008-04-24 14:37:05 +00:00
TTypeConversion = ( tcNone,
tcBoolean,
tcFloat,
tcDateTime,
tcDate,
tcTime,
2008-07-20 12:07:18 +00:00
tcString,
2012-05-22 13:23:21 +00:00
tcBase64,
tcNode) ;
2008-04-24 14:37:05 +00:00
2008-03-21 15:23:14 +00:00
TTypeConversions = set of TTypeConversion;
TTypeMapping = record
SchemaName: String ;
DelphiName: String ;
Conversion: TTypeConversion;
end ;
const
2012-05-22 13:23:21 +00:00
SimpleTypeMapping: array [ 0 .. 1 3 ] of TTypeMapping =
2008-03-21 15:23:14 +00:00
(
2008-07-20 12:07:18 +00:00
( SchemaName: 'int' ; DelphiName: 'Integer' ; Conversion: tcNone) ,
( SchemaName: 'integer' ; DelphiName: 'Integer' ; Conversion: tcNone) ,
( SchemaName: 'short' ; DelphiName: 'Smallint' ; Conversion: tcNone) ,
( SchemaName: 'date' ; DelphiName: 'TDateTime' ; Conversion: tcDate) ,
( SchemaName: 'time' ; DelphiName: 'TDateTime' ; Conversion: tcTime) ,
( SchemaName: 'dateTime' ; DelphiName: 'TDateTime' ; Conversion: tcDateTime) ,
2012-04-20 08:33:26 +00:00
( SchemaName: 'decimal' ; DelphiName: 'Double' ; Conversion: tcFloat) ,
2008-07-20 12:07:18 +00:00
( SchemaName: 'float' ; DelphiName: 'Double' ; Conversion: tcFloat) ,
( SchemaName: 'double' ; DelphiName: 'Double' ; Conversion: tcFloat) ,
( SchemaName: 'boolean' ; DelphiName: 'Boolean' ; Conversion: tcBoolean) ,
( SchemaName: 'string' ; DelphiName: 'WideString' ; Conversion: tcString) ,
2008-07-31 14:56:36 +00:00
( SchemaName: 'anyURI' ; DelphiName: 'WideString' ; Conversion: tcString) ,
2012-05-22 13:23:21 +00:00
( SchemaName: 'base64Binary' ; DelphiName: 'WideString' ; Conversion: tcBase64) ,
( SchemaName: 'anyType' ; DelphiName: 'IXMLNode' ; Conversion: tcNode)
2008-03-21 15:23:14 +00:00
) ;
2008-04-24 14:37:05 +00:00
TypeConversionReqUtils: array [ TTypeConversion] of Boolean =
(
{ tcNone } False ,
{ tcBoolean } True ,
{ tcFloat } True ,
{ tcDateTime } True ,
{ tcDate } True ,
{ tcTime } True ,
2014-06-27 07:53:21 +00:00
{ tcString } True ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } True ,
{ tcNone } False
2008-04-24 14:37:05 +00:00
) ;
2008-03-21 15:23:14 +00:00
2008-04-14 19:28:57 +00:00
TypeConversionNone: array [ TDelphiAccessor, TDelphiNodeType] of String =
(
{ daGet }
(
{ dntElement } ' %<Destination>:s := ChildNodes[' '%<Source>:s' '].NodeValue;' ,
2013-06-21 10:25:49 +00:00
{ dntElementNS } ' %<Destination>:s := ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].NodeValue;' ,
2008-04-14 19:28:57 +00:00
{ dntAttribute } ' %<Destination>:s := AttributeNodes[' '%<Source>:s' '].NodeValue;' ,
2010-07-15 10:57:03 +00:00
{ dntNodeValue } ' %<Destination>:s := GetNodeValue;' ,
2008-04-14 19:28:57 +00:00
{ dntCustom } ' %<Destination>:s := %<Source>:s;'
) ,
{ daSet }
(
{ dntElement } ' ChildNodes[' '%<Destination>:s' '].NodeValue := %<Source>:s;' ,
2013-06-21 10:25:49 +00:00
{ dntElementNS } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := %<Source>:s;' ,
2008-04-14 19:28:57 +00:00
{ dntAttribute } ' SetAttribute(' '%<Destination>:s' ', %<Source>:s);' ,
2010-07-15 10:57:03 +00:00
{ dntNodeValue } ' SetNodeValue(%<Source>:s);' ,
2008-04-14 19:28:57 +00:00
{ dntCustom } ' %<Destination>:s := %<Source>:s;'
)
) ;
2008-03-21 15:23:14 +00:00
2008-04-14 19:28:57 +00:00
TypeConversion: array [ TDelphiAccessor, TDelphiNodeType, TTypeConversion] of String =
2008-03-21 15:23:14 +00:00
(
2008-04-14 19:28:57 +00:00
{ daGet }
(
{ dntElement }
(
{ tcNone } '' ,
{ tcBoolean } '' ,
{ tcFloat } ' %<Destination>:s := XMLToFloat(ChildNodes[' '%<Source>:s' '].NodeValue);' ,
2008-04-24 14:37:05 +00:00
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(ChildNodes[' '%<Source>:s' '].NodeValue, xdtDateTime);' ,
{ tcDate } ' %<Destination>:s := XMLToDateTime(ChildNodes[' '%<Source>:s' '].NodeValue, xdtDate);' ,
{ tcTime } ' %<Destination>:s := XMLToDateTime(ChildNodes[' '%<Source>:s' '].NodeValue, xdtTime);' ,
2008-07-20 12:07:18 +00:00
{ tcString } ' %<Destination>:s := ChildNodes[' '%<Source>:s' '].Text;' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' %<Destination>:s := Base64Decode(Trim(ChildNodes[' '%<Source>:s' '].Text));' ,
{ tcNode } ' %<Destination>:s := ChildNodes[' '%<Source>:s' '];'
2008-04-14 19:28:57 +00:00
) ,
2012-04-10 08:47:48 +00:00
{ dntElementNS }
(
{ tcNone } '' ,
{ tcBoolean } '' ,
2013-06-21 10:25:49 +00:00
{ tcFloat } ' %<Destination>:s := XMLToFloat(ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].NodeValue);' ,
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].NodeValue, xdtDateTime);' ,
{ tcDate } ' %<Destination>:s := XMLToDateTime(ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].NodeValue, xdtDate);' ,
{ tcTime } ' %<Destination>:s := XMLToDateTime(ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].NodeValue, xdtTime);' ,
{ tcString } ' %<Destination>:s := ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].Text;' ,
{ tcBase64 } ' %<Destination>:s := Base64Decode(Trim(ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '].Text));' ,
{ tcNode } ' %<Destination>:s := ChildNodesNS[' '%<Source>:s' ', ' '%<Namespace>:s' '];'
2012-04-10 08:47:48 +00:00
) ,
2008-04-14 19:28:57 +00:00
{ dntAttribute }
(
{ tcNone } '' ,
{ tcBoolean } '' ,
{ tcFloat } ' %<Destination>:s := XMLToFloat(AttributeNodes[' '%<Source>:s' '].NodeValue);' ,
2008-04-24 14:37:05 +00:00
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(AttributeNodes[' '%<Source>:s' '].NodeValue, xdtDateTime);' ,
{ tcDate } ' %<Destination>:s := XMLToDateTime(AttributeNodes[' '%<Source>:s' '].NodeValue, xdtDate);' ,
{ tcTime } ' %<Destination>:s := XMLToDateTime(AttributeNodes[' '%<Source>:s' '].NodeValue, xdtTime);' ,
2008-07-20 12:07:18 +00:00
{ tcString } ' %<Destination>:s := AttributeNodes[' '%<Source>:s' '].Text;' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' %<Destination>:s := Base64Decode(Trim(AttributeNodes[' '%<Source>:s' '].Text));' ,
{ tcNode } ' %<Destination>:s := AttributeNodes[' '%<Source>:s' '];'
2008-04-14 19:28:57 +00:00
) ,
2010-06-22 08:27:28 +00:00
{ dntNodeValue }
(
{ tcNone } '' ,
{ tcBoolean } '' ,
2010-07-15 10:57:03 +00:00
{ tcFloat } ' %<Destination>:s := XMLToFloat(GetNodeValue);' ,
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtDateTime);' ,
{ tcDate } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtDate);' ,
{ tcTime } ' %<Destination>:s := XMLToDateTime(GetNodeValue, xdtTime);' ,
2014-10-28 14:22:41 +00:00
{ tcString } ' %<Destination>:s := VarToStr(GetNodeValue);' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' %<Destination>:s := Base64Decode(Trim(GetNodeValue));' ,
{ tcNode } ''
2010-06-22 08:27:28 +00:00
) ,
2008-04-14 19:28:57 +00:00
{ dntCustom}
(
{ tcNone } '' ,
{ tcBoolean } '' ,
{ tcFloat } ' %<Destination>:s := XMLToFloat(%<Source>:s);' ,
2008-04-24 14:37:05 +00:00
{ tcDateTime } ' %<Destination>:s := XMLToDateTime(%<Source>:s, xdtDateTime);' ,
{ tcDate } ' %<Destination>:s := XMLToDateTime(%<Source>:s, xdtDate);' ,
{ tcTime } ' %<Destination>:s := XMLToDateTime(%<Source>:s, xdtTime);' ,
2008-07-20 12:07:18 +00:00
{ tcString } '' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' %<Destination>:s := Base64Decode(Trim(%<Source>:s));' ,
{ tcNode } ''
2008-04-14 19:28:57 +00:00
)
) ,
{ daSet }
(
{ dntElement }
(
{ tcNone } '' ,
{ tcBoolean } ' ChildNodes[' '%<Destination>:s' '].NodeValue := BoolToXML(%<Source>:s);' ,
{ tcFloat } ' ChildNodes[' '%<Destination>:s' '].NodeValue := FloatToXML(%<Source>:s);' ,
2008-04-24 14:37:05 +00:00
{ tcDateTime } ' ChildNodes[' '%<Destination>:s' '].NodeValue := DateTimeToXML(%<Source>:s, xdtDateTime);' ,
{ tcDate } ' ChildNodes[' '%<Destination>:s' '].NodeValue := DateTimeToXML(%<Source>:s, xdtDate);' ,
{ tcTime } ' ChildNodes[' '%<Destination>:s' '].NodeValue := DateTimeToXML(%<Source>:s, xdtTime);' ,
2014-06-27 07:53:21 +00:00
{ tcString } ' ChildNodes[' '%<Destination>:s' '].NodeValue := GetValidXMLText(%<Source>:s);' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' ChildNodes[' '%<Destination>:s' '].NodeValue := Base64Encode(%<Source>:s);' ,
{ tcNode } ' ChildNodes[' '%<Destination>:s' '] := %<Source>:s;'
2008-04-14 19:28:57 +00:00
) ,
2012-04-10 08:47:48 +00:00
{ dntElementNS }
(
{ tcNone } '' ,
2013-06-21 10:25:49 +00:00
{ tcBoolean } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := BoolToXML(%<Source>:s);' ,
{ tcFloat } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := FloatToXML(%<Source>:s);' ,
{ tcDateTime } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := DateTimeToXML(%<Source>:s, xdtDateTime);' ,
{ tcDate } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := DateTimeToXML(%<Source>:s, xdtDate);' ,
{ tcTime } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := DateTimeToXML(%<Source>:s, xdtTime);' ,
2014-06-27 07:53:21 +00:00
{ tcString } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := GetValidXMLText(%<Source>:s);' ,
2013-06-21 10:25:49 +00:00
{ tcBase64 } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '].NodeValue := Base64Encode(%<Source>:s);' ,
{ tcNode } ' ChildNodesNS[' '%<Destination>:s' ', ' '%<Namespace>:s' '] := %<Source>:s;'
2012-04-10 08:47:48 +00:00
) ,
2008-04-14 19:28:57 +00:00
{ dntAttribute }
(
{ tcNone } '' ,
{ tcBoolean } ' SetAttribute(' '%<Destination>:s' ', BoolToXML(%<Source>:s));' ,
{ tcFloat } ' SetAttribute(' '%<Destination>:s' ', FloatToXML(%<Source>:s));' ,
2008-04-24 14:37:05 +00:00
{ tcDateTime } ' SetAttribute(' '%<Destination>:s' ', DateTimeToXML(%<Source>:s, xdtDateTime));' ,
{ tcDate } ' SetAttribute(' '%<Destination>:s' ', DateTimeToXML(%<Source>:s, xdtDate));' ,
{ tcTime } ' SetAttribute(' '%<Destination>:s' ', DateTimeToXML(%<Source>:s, xdtTime));' ,
2014-06-27 07:53:21 +00:00
{ tcString } ' SetAttribute(' '%<Destination>:s' ', GetValidXMLText(%<Source>:s));' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' SetAttribute(' '%<Destination>:s' ', Base64Encode(%<Source>:s));' ,
{ tcNode } ''
2008-04-14 19:28:57 +00:00
) ,
2010-06-22 08:27:28 +00:00
{ dntNodeValue }
(
{ tcNone } '' ,
2010-07-15 10:57:03 +00:00
{ tcBoolean } ' SetNodeValue(BoolToXML(%<Source>:s));' ,
{ tcFloat } ' SetNodeValue(FloatToXML(%<Source>:s));' ,
{ tcDateTime } ' SetNodeValue(DateTimeToXML(%<Source>:s, xdtDateTime));' ,
{ tcDate } ' SetNodeValue(DateTimeToXML(%<Source>:s, xdtDate));' ,
{ tcTime } ' SetNodeValue(DateTimeToXML(%<Source>:s, xdtTime));' ,
2014-06-27 07:53:21 +00:00
{ tcString } ' SetNodeValue(GetValidXMLText(%<Source>:s));' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' SetNodeValue(Base64Encode(%<Source>:s));' ,
{ tcNode } ''
2010-06-22 08:27:28 +00:00
) ,
2008-04-14 19:28:57 +00:00
{ dntCustom}
(
{ tcNone } '' ,
{ tcBoolean } ' %<Destination>:s := BoolToXML(%<Source>:s);' ,
{ tcFloat } ' %<Destination>:s := FloatToXML(%<Source>:s);' ,
2008-04-24 14:37:05 +00:00
{ tcDateTime } ' %<Destination>:s := DateTimeToXML(%<Source>:s, xdtDateTime);' ,
{ tcDate } ' %<Destination>:s := DateTimeToXML(%<Source>:s, xdtDate);' ,
{ tcTime } ' %<Destination>:s := DateTimeToXML(%<Source>:s, xdtTime);' ,
2014-06-27 07:53:21 +00:00
{ tcString } ' %<Destination>:s := GetValidXMLText(%<Source>:s);' ,
2012-05-22 13:23:21 +00:00
{ tcBase64 } ' %<Destination>:s := Base64Encode(%<Source>:s);' ,
{ tcNode } ''
2008-04-14 19:28:57 +00:00
)
)
2008-03-21 15:23:14 +00:00
) ;
implementation
end .