diff --git a/Forms/MainFrm.dfm b/Forms/MainFrm.dfm index 88c8557..ef2dd30 100644 --- a/Forms/MainFrm.dfm +++ b/Forms/MainFrm.dfm @@ -4,7 +4,7 @@ object MainForm: TMainForm BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsDialog Caption = 'X'#178'Software XML Data Binding for Delphi' - ClientHeight = 254 + ClientHeight = 291 ClientWidth = 438 Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -17,7 +17,7 @@ object MainForm: TMainForm OnCreate = FormCreate DesignSize = ( 438 - 254) + 291) PixelsPerInch = 96 TextHeight = 13 object lblSchema: TLabel @@ -44,30 +44,31 @@ object MainForm: TMainForm Left = 8 Top = 43 Width = 422 - Height = 167 + Height = 204 Anchors = [akLeft, akTop, akBottom] Caption = ' Output ' TabOrder = 1 + ExplicitHeight = 167 DesignSize = ( 422 - 167) + 204) object rbFile: TRadioButton - Left = 7 + Left = 11 Top = 21 - Width = 126 + Width = 127 Height = 17 - Caption = 'Output to &single file' + Caption = ' Output to &single file' Checked = True TabOrder = 0 TabStop = True OnClick = OutputTypeClick end object rbFolder: TRadioButton - Left = 8 + Left = 11 Top = 44 - Width = 149 + Width = 150 Height = 17 - Caption = 'Output to separate &files' + Caption = ' Output to separate &files' TabOrder = 1 OnClick = OutputTypeClick end @@ -75,15 +76,16 @@ object MainForm: TMainForm Left = 3 Top = 68 Width = 416 - Height = 95 - ActivePage = spFile - Anchors = [akLeft, akTop, akRight, akBottom] + Height = 93 + ActivePage = spFolder + Anchors = [akLeft, akTop, akRight] Style = tsButtons TabOrder = 2 object spFile: TTabSheet TabVisible = False + ExplicitHeight = 85 object lblFile: TLabel - Left = 8 + Left = 4 Top = 7 Width = 55 Height = 13 @@ -91,7 +93,7 @@ object MainForm: TMainForm end object feFile: TcxButtonEdit Left = 88 - Top = 3 + Top = 4 Properties.Buttons = < item Kind = bkEllipsis @@ -103,37 +105,35 @@ object MainForm: TMainForm end object spFolder: TTabSheet TabVisible = False - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 + ExplicitLeft = 8 + ExplicitHeight = 195 DesignSize = ( 408 - 85) + 83) object lblFolder: TLabel - Left = 8 + Left = 4 Top = 7 Width = 69 Height = 13 Caption = 'Output folder:' end object lblFolderPrefix: TLabel - Left = 8 - Top = 34 + Left = 4 + Top = 32 Width = 51 Height = 13 Caption = 'File prefix:' end object lblFolderPostfix: TLabel - Left = 8 - Top = 60 + Left = 4 + Top = 58 Width = 56 Height = 13 Caption = 'File postfix:' end object deFolder: TcxButtonEdit Left = 88 - Top = 3 + Top = 4 Anchors = [akLeft, akTop, akRight] Properties.Buttons = < item @@ -145,23 +145,36 @@ object MainForm: TMainForm end object edtFolderPrefix: TcxTextEdit Left = 88 - Top = 30 + Top = 29 TabOrder = 1 Text = 'xml_' Width = 121 end object edtFolderPostfix: TcxTextEdit Left = 88 - Top = 57 + Top = 55 TabOrder = 2 Width = 121 end end end + object cbHasChecksEmpty: TCheckBox + Left = 11 + Top = 175 + Width = 401 + Height = 17 + Hint = + 'Workaround for XML'#39's generated by people who do not understand t' + + 'he concept of optional elements or XSD'#39's in general' + Caption = + ' Check for empty elements as well as omitted elements in Has pro' + + 'perties' + TabOrder = 3 + end end object btnGenerate: TButton Left = 274 - Top = 221 + Top = 258 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -169,10 +182,11 @@ object MainForm: TMainForm Default = True TabOrder = 3 OnClick = btnGenerateClick + ExplicitTop = 221 end object btnClose: TButton Left = 355 - Top = 221 + Top = 258 Width = 75 Height = 25 Anchors = [akRight, akBottom] @@ -180,10 +194,11 @@ object MainForm: TMainForm Caption = '&Close' TabOrder = 4 OnClick = btnCloseClick + ExplicitTop = 221 end object btnHints: TButton Left = 7 - Top = 221 + Top = 258 Width = 142 Height = 25 Anchors = [akRight, akBottom] @@ -191,6 +206,7 @@ object MainForm: TMainForm Caption = 'Generate blank &Hints file' TabOrder = 2 OnClick = btnHintsClick + ExplicitTop = 221 end object DefaultEditStyle: TcxDefaultEditStyleController Style.HotTrack = False @@ -206,13 +222,13 @@ object MainForm: TMainForm object dlgSchema: TOpenDialog Filter = 'W3C XML Schema files (*.xsd)|*.xsd|All files (*.*)|*.*' Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing] - Left = 260 - Top = 156 + Left = 212 + Top = 40 end object dlgOutputFile: TSaveDialog Filter = 'Delphi source files (*.pas)|*.pas|All files (*.*)|*.*' Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing] - Left = 343 - Top = 157 + Left = 323 + Top = 45 end end diff --git a/Forms/MainFrm.pas b/Forms/MainFrm.pas index a3149de..9f97609 100644 --- a/Forms/MainFrm.pas +++ b/Forms/MainFrm.pas @@ -51,6 +51,7 @@ type rbFolder: TRadioButton; spFile: TTabSheet; spFolder: TTabSheet; + cbHasChecksEmpty: TCheckBox; procedure btnCloseClick(Sender: TObject); procedure btnGenerateClick(Sender: TObject); @@ -181,6 +182,7 @@ begin generator.OutputPath := deFolder.Text; end; + generator.HasChecksEmpty := cbHasChecksEmpty.Checked; generator.OnGetFileName := GetFileName; generator.Execute(feSchema.Text); @@ -263,14 +265,14 @@ begin if settings.HasOutput then begin case settings.Output.OutputType of - OutputType_Single: + DataBindingOutputType_Single: begin outputSingle := settings.Output.OutputSingle; rbFile.Checked := True; feFile.Text := outputSingle.FileName; end; - OutputType_Multiple: + DataBindingOutputType_Multiple: begin outputMultiple := settings.Output.OutputMultiple; rbFolder.Checked := True; @@ -279,6 +281,8 @@ begin edtFolderPostfix.Text := outputMultiple.Postfix; end; end; + + cbHasChecksEmpty.Checked := settings.Output.HasHasChecksEmpty and settings.Output.HasChecksEmpty; end; end; end; @@ -302,18 +306,19 @@ begin if rbFile.Checked then begin - settings.Output.OutputType := OutputType_Single; + settings.Output.OutputType := DataBindingOutputType_Single; outputSingle := settings.Output.OutputSingle; outputSingle.FileName := feFile.Text; end else begin - settings.Output.OutputType := OutputType_Multiple; + settings.Output.OutputType := DataBindingOutputType_Multiple; outputMultiple := settings.Output.OutputMultiple; outputMultiple.Path := deFolder.Text; outputMultiple.Prefix := edtFolderPrefix.Text; outputMultiple.Postfix := edtFolderPostfix.Text; end; + settings.Output.HasChecksEmpty := cbHasChecksEmpty.Checked; settings.OwnerDocument.SaveToFile(fileName); end; diff --git a/Units/DataBindingSettingsXML.pas b/Units/DataBindingSettingsXML.pas index 33bf1e5..97f43d3 100644 --- a/Units/DataBindingSettingsXML.pas +++ b/Units/DataBindingSettingsXML.pas @@ -1,32 +1,35 @@ { X2Software XML Data Binding - Generated on: 24-4-2008 11:37:27 - Generated from: P:\test\XMLDataBinding\XSD\DataBindingSettings.xsd + Generated on: 21-7-2017 9:19:46 + Generated from: P:\x2xmldatabinding\XSD\DataBindingSettings.xsd } unit DataBindingSettingsXML; interface uses Classes, + SysUtils, XMLDoc, - XMLIntf; + XMLIntf, + XMLDataBindingUtils; type { Forward declarations for DataBindingSettings } IXMLDataBindingSettings = interface; IXMLDataBindingOutput = interface; - TXMLOutputType = (OutputType_Single, - OutputType_Multiple); IXMLOutputSingle = interface; IXMLOutputMultiple = interface; + TXMLDataBindingOutputType = (DataBindingOutputType_Single, + DataBindingOutputType_Multiple); { Interfaces for DataBindingSettings } { Contains the settings and hints for the Delphi XML Data Binding. } IXMLDataBindingSettings = interface(IXMLNode) - ['{C78D63A5-77C2-4547-AC37-5311160D543B}'] + ['{0407CBCB-B49B-4ED3-A2F6-CCDDFE46F334}'] + procedure XSDValidateDocument(AStrict: Boolean = False); function GetHasOutput: Boolean; function GetOutput: IXMLDataBindingOutput; @@ -38,27 +41,38 @@ type Contains the user-defined output settings last used } IXMLDataBindingOutput = interface(IXMLNode) - ['{81374819-83EF-42A8-A7B8-2F59A470D77B}'] + ['{21821EFA-C7D8-4299-BF44-8122FBF2BC2E}'] + procedure XSDValidate; + procedure XSDValidateStrict(AResult: IXSDValidateStrictResult); + function GetOutputTypeText: WideString; - function GetOutputType: TXMLOutputType; + function GetOutputType: TXMLDataBindingOutputType; function GetHasOutputSingle: Boolean; function GetOutputSingle: IXMLOutputSingle; function GetHasOutputMultiple: Boolean; function GetOutputMultiple: IXMLOutputMultiple; + function GetHasHasChecksEmpty: Boolean; + function GetHasChecksEmpty: Boolean; procedure SetOutputTypeText(const Value: WideString); - procedure SetOutputType(const Value: TXMLOutputType); + procedure SetOutputType(const Value: TXMLDataBindingOutputType); + procedure SetHasChecksEmpty(const Value: Boolean); property OutputTypeText: WideString read GetOutputTypeText write SetOutputTypeText; - property OutputType: TXMLOutputType read GetOutputType write SetOutputType; + property OutputType: TXMLDataBindingOutputType read GetOutputType write SetOutputType; property HasOutputSingle: Boolean read GetHasOutputSingle; property OutputSingle: IXMLOutputSingle read GetOutputSingle; property HasOutputMultiple: Boolean read GetHasOutputMultiple; property OutputMultiple: IXMLOutputMultiple read GetOutputMultiple; + property HasHasChecksEmpty: Boolean read GetHasHasChecksEmpty; + property HasChecksEmpty: Boolean read GetHasChecksEmpty write SetHasChecksEmpty; end; IXMLOutputSingle = interface(IXMLNode) - ['{9BB52722-C7C0-45F8-81A1-59BE074BF62E}'] + ['{ABB2D62A-0B4D-4E4B-8835-ED8AFE7564EA}'] + procedure XSDValidate; + procedure XSDValidateStrict(AResult: IXSDValidateStrictResult); + function GetFileName: WideString; procedure SetFileName(const Value: WideString); @@ -67,7 +81,10 @@ type end; IXMLOutputMultiple = interface(IXMLNode) - ['{4B5AC82E-572A-4C21-B779-4626BF79E0E6}'] + ['{2F4918D6-EE9C-4986-9052-285A8B4D58C5}'] + procedure XSDValidate; + procedure XSDValidateStrict(AResult: IXSDValidateStrictResult); + function GetPath: WideString; function GetPrefix: WideString; function GetPostfix: WideString; @@ -83,38 +100,51 @@ type { Classes for DataBindingSettings } - TXMLDataBindingSettings = class(TXMLNode, IXMLDataBindingSettings) + TXMLDataBindingSettings = class(TX2XMLNode, IXMLDataBindingSettings) public procedure AfterConstruction; override; protected + procedure XSDValidateDocument(AStrict: Boolean = False); function GetHasOutput: Boolean; function GetOutput: IXMLDataBindingOutput; end; - TXMLDataBindingOutput = class(TXMLNode, IXMLDataBindingOutput) + TXMLDataBindingOutput = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLDataBindingOutput) public procedure AfterConstruction; override; protected + procedure XSDValidate; + procedure XSDValidateStrict(AResult: IXSDValidateStrictResult); + function GetOutputTypeText: WideString; - function GetOutputType: TXMLOutputType; + function GetOutputType: TXMLDataBindingOutputType; function GetHasOutputSingle: Boolean; function GetOutputSingle: IXMLOutputSingle; function GetHasOutputMultiple: Boolean; function GetOutputMultiple: IXMLOutputMultiple; + function GetHasHasChecksEmpty: Boolean; + function GetHasChecksEmpty: Boolean; procedure SetOutputTypeText(const Value: WideString); - procedure SetOutputType(const Value: TXMLOutputType); + procedure SetOutputType(const Value: TXMLDataBindingOutputType); + procedure SetHasChecksEmpty(const Value: Boolean); end; - TXMLOutputSingle = class(TXMLNode, IXMLOutputSingle) + TXMLOutputSingle = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLOutputSingle) protected + procedure XSDValidate; + procedure XSDValidateStrict(AResult: IXSDValidateStrictResult); + function GetFileName: WideString; procedure SetFileName(const Value: WideString); end; - TXMLOutputMultiple = class(TXMLNode, IXMLOutputMultiple) + TXMLOutputMultiple = class(TX2XMLNode, IXSDValidate, IXSDValidateStrict, IXMLOutputMultiple) protected + procedure XSDValidate; + procedure XSDValidateStrict(AResult: IXSDValidateStrictResult); + function GetPath: WideString; function GetPrefix: WideString; function GetPostfix: WideString; @@ -126,9 +156,10 @@ type { Document functions } - function GetDataBindingSettings(ADocument: IXMLDocument): IXMLDataBindingSettings; + function GetDataBindingSettings(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingSettings; function LoadDataBindingSettings(const AFileName: String): IXMLDataBindingSettings; function LoadDataBindingSettingsFromStream(AStream: TStream): IXMLDataBindingSettings; + function LoadDataBindingSettingsFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding = nil; AOwnsEncoding: Boolean = True{$IFEND}): IXMLDataBindingSettings; function NewDataBindingSettings: IXMLDataBindingSettings; @@ -137,21 +168,21 @@ const const - OutputTypeValues: array[TXMLOutputType] of WideString = - ( - 'Single', - 'Multiple' - ); + DataBindingOutputTypeValues: array[TXMLDataBindingOutputType] of WideString = + ( + 'Single', + 'Multiple' + ); { Enumeration conversion helpers } - function StringToOutputType(const AValue: WideString): TXMLOutputType; + function StringToDataBindingOutputType(const AValue: WideString): TXMLDataBindingOutputType; implementation uses - SysUtils; + Variants; { Document functions } -function GetDataBindingSettings(ADocument: IXMLDocument): IXMLDataBindingSettings; +function GetDataBindingSettings(ADocument: XMLIntf.IXMLDocument): IXMLDataBindingSettings; begin Result := ADocument.GetDocBinding('DataBindingSettings', TXMLDataBindingSettings, TargetNamespace) as IXMLDataBindingSettings end; @@ -163,7 +194,7 @@ end; function LoadDataBindingSettingsFromStream(AStream: TStream): IXMLDataBindingSettings; var - doc: IXMLDocument; + doc: XMLIntf.IXMLDocument; begin doc := NewXMLDocument; @@ -171,6 +202,24 @@ begin Result := GetDataBindingSettings(doc); end; +function LoadDataBindingSettingsFromString(const AString: String{$IF CompilerVersion >= 20}; AEncoding: TEncoding; AOwnsEncoding: Boolean{$IFEND}): IXMLDataBindingSettings; +var + stream: TStringStream; + +begin + {$IF CompilerVersion >= 20} + if Assigned(AEncoding) then + stream := TStringStream.Create(AString, AEncoding, AOwnsEncoding) + else + {$IFEND} + stream := TStringStream.Create(AString); + try + Result := LoadDataBindingSettingsFromStream(stream); + finally + FreeAndNil(stream); + end; +end; + function NewDataBindingSettings: IXMLDataBindingSettings; begin Result := NewXMLDocument.GetDocBinding('DataBindingSettings', TXMLDataBindingSettings, TargetNamespace) as IXMLDataBindingSettings @@ -179,14 +228,14 @@ end; { Enumeration conversion helpers } -function StringToOutputType(const AValue: WideString): TXMLOutputType; +function StringToDataBindingOutputType(const AValue: WideString): TXMLDataBindingOutputType; var - enumValue: TXMLOutputType; + enumValue: TXMLDataBindingOutputType; begin - Result := TXMLOutputType(-1); - for enumValue := Low(TXMLOutputType) to High(TXMLOutputType) do - if OutputTypeValues[enumValue] = AValue then + Result := TXMLDataBindingOutputType(-1); + for enumValue := Low(TXMLDataBindingOutputType) to High(TXMLDataBindingOutputType) do + if DataBindingOutputTypeValues[enumValue] = AValue then begin Result := enumValue; break; @@ -201,6 +250,14 @@ begin inherited; end; +procedure TXMLDataBindingSettings.XSDValidateDocument(AStrict: Boolean); +begin + if AStrict then + XMLDataBindingUtils.XSDValidateStrict(Self) + else + XMLDataBindingUtils.XSDValidate(Self); +end; + function TXMLDataBindingSettings.GetHasOutput: Boolean; begin Result := Assigned(ChildNodes.FindNode('Output')); @@ -219,15 +276,27 @@ begin inherited; end; +procedure TXMLDataBindingOutput.XSDValidate; +begin + GetOutputType; + SortChildNodes(Self, ['OutputType', 'OutputSingle', 'OutputMultiple', 'HasChecksEmpty']); +end; + +procedure TXMLDataBindingOutput.XSDValidateStrict(AResult: IXSDValidateStrictResult); +begin + GetOutputType; + SortChildNodes(Self, ['OutputType', 'OutputSingle', 'OutputMultiple', 'HasChecksEmpty']); +end; + function TXMLDataBindingOutput.GetOutputTypeText: WideString; begin Result := ChildNodes['OutputType'].Text; end; -function TXMLDataBindingOutput.GetOutputType: TXMLOutputType; +function TXMLDataBindingOutput.GetOutputType: TXMLDataBindingOutputType; begin - Result := StringToOutputType(GetOutputTypeText); + Result := StringToDataBindingOutputType(GetOutputTypeText); end; function TXMLDataBindingOutput.GetHasOutputSingle: Boolean; @@ -252,15 +321,41 @@ begin Result := (ChildNodes['OutputMultiple'] as IXMLOutputMultiple); end; +function TXMLDataBindingOutput.GetHasHasChecksEmpty: Boolean; +begin + Result := Assigned(ChildNodes.FindNode('HasChecksEmpty')); +end; + + +function TXMLDataBindingOutput.GetHasChecksEmpty: Boolean; +begin + Result := ChildNodes['HasChecksEmpty'].NodeValue; +end; + procedure TXMLDataBindingOutput.SetOutputTypeText(const Value: WideString); begin ChildNodes['OutputType'].NodeValue := Value; end; -procedure TXMLDataBindingOutput.SetOutputType(const Value: TXMLOutputType); +procedure TXMLDataBindingOutput.SetOutputType(const Value: TXMLDataBindingOutputType); begin - ChildNodes['OutputType'].NodeValue := OutputTypeValues[Value]; + ChildNodes['OutputType'].NodeValue := DataBindingOutputTypeValues[Value]; +end; + +procedure TXMLDataBindingOutput.SetHasChecksEmpty(const Value: Boolean); +begin + ChildNodes['HasChecksEmpty'].NodeValue := BoolToXML(Value); +end; + +procedure TXMLOutputSingle.XSDValidate; +begin + CreateRequiredElements(Self, ['FileName']); +end; + +procedure TXMLOutputSingle.XSDValidateStrict(AResult: IXSDValidateStrictResult); +begin + ValidateRequiredElements(AResult, Self, ['FileName']); end; function TXMLOutputSingle.GetFileName: WideString; @@ -270,7 +365,19 @@ end; procedure TXMLOutputSingle.SetFileName(const Value: WideString); begin - ChildNodes['FileName'].NodeValue := Value; + ChildNodes['FileName'].NodeValue := GetValidXMLText(Value); +end; + +procedure TXMLOutputMultiple.XSDValidate; +begin + CreateRequiredElements(Self, ['Path', 'Prefix', 'Postfix']); + SortChildNodes(Self, ['Path', 'Prefix', 'Postfix']); +end; + +procedure TXMLOutputMultiple.XSDValidateStrict(AResult: IXSDValidateStrictResult); +begin + ValidateRequiredElements(AResult, Self, ['Path', 'Prefix', 'Postfix']); + SortChildNodes(Self, ['Path', 'Prefix', 'Postfix']); end; function TXMLOutputMultiple.GetPath: WideString; @@ -290,17 +397,17 @@ end; procedure TXMLOutputMultiple.SetPath(const Value: WideString); begin - ChildNodes['Path'].NodeValue := Value; + ChildNodes['Path'].NodeValue := GetValidXMLText(Value); end; procedure TXMLOutputMultiple.SetPrefix(const Value: WideString); begin - ChildNodes['Prefix'].NodeValue := Value; + ChildNodes['Prefix'].NodeValue := GetValidXMLText(Value); end; procedure TXMLOutputMultiple.SetPostfix(const Value: WideString); begin - ChildNodes['Postfix'].NodeValue := Value; + ChildNodes['Postfix'].NodeValue := GetValidXMLText(Value); end; diff --git a/Units/DelphiXMLDataBindingGenerator.pas b/Units/DelphiXMLDataBindingGenerator.pas index bd921b6..70aedb9 100644 --- a/Units/DelphiXMLDataBindingGenerator.pas +++ b/Units/DelphiXMLDataBindingGenerator.pas @@ -18,10 +18,11 @@ type TDelphiXMLDataBindingGenerator = class(TXMLDataBindingGenerator) private - FProcessedItems: TList; - FUnitNames: TDictionary; + FProcessedItems: TList; + FUnitNames: TDictionary; - FOnGetFileName: TGetFileNameEvent; + FHasChecksEmpty: Boolean; + FOnGetFileName: TGetFileNameEvent; protected procedure GenerateDataBinding; override; procedure GenerateOutputFile(ASchemaList: TXMLSchemaList; const ASourceFileName, AUnitName: String); @@ -70,7 +71,9 @@ type property ProcessedItems: TList read FProcessedItems; property UnitNames: TDictionary read FUnitNames; public - property OnGetFileName: TGetFileNameEvent read FOnGetFileName write FOnGetFileName; + property HasChecksEmpty: Boolean read FHasChecksEmpty write FHasChecksEmpty; + + property OnGetFileName: TGetFileNameEvent read FOnGetFileName write FOnGetFileName; end; @@ -1141,6 +1144,7 @@ var writeStream: Boolean; typeMapping: TTypeMapping; nodeType: TDelphiNodeType; + elementType: TDelphiElementType; begin Result := False; @@ -1295,9 +1299,12 @@ begin if writeOptional then if AProperty.IsAttribute then - sourceCode.Add(PropertyImplMethodGetOptionalAttr) + sourceCode.Add(IfThen(HasChecksEmpty, PropertyImplMethodGetOptionalAttrEmpty, PropertyImplMethodGetOptionalAttr)) else - sourceCode.Add(PropertyImplMethodGetOptional[GetDelphiElementType(nodeType)]); + begin + elementType := GetDelphiElementType(nodeType); + sourceCode.Add(IfThen(HasChecksEmpty, PropertyImplMethodGetOptionalEmpty[elementType], PropertyImplMethodGetOptional[elementType])); + end; if writeNil then sourceCode.Add(PropertyImplMethodGetNil[GetDelphiElementType(nodeType)]); diff --git a/Units/DelphiXMLDataBindingResources.pas b/Units/DelphiXMLDataBindingResources.pas index e2cd0f8..8c999e7 100644 --- a/Units/DelphiXMLDataBindingResources.pas +++ b/Units/DelphiXMLDataBindingResources.pas @@ -198,6 +198,31 @@ const '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 } diff --git a/XSD/DataBindingSettings.settings.xml b/XSD/DataBindingSettings.settings.xml new file mode 100644 index 0000000..8223c72 --- /dev/null +++ b/XSD/DataBindingSettings.settings.xml @@ -0,0 +1,2 @@ + +Single..\Units\DataBindingSettingsXML.pas diff --git a/XSD/DataBindingSettings.xsd b/XSD/DataBindingSettings.xsd index aab57cf..df6b65c 100644 --- a/XSD/DataBindingSettings.xsd +++ b/XSD/DataBindingSettings.xsd @@ -1,5 +1,5 @@ - + Contains the settings and hints for the Delphi XML Data Binding. @@ -34,6 +34,7 @@ +