Fixed: elements which are part of a choice compositor are treated as being optional
Fixed: xs:string properties use IXMLNode.Text property instead of NodeValue Changed: GUI uses DevEx components
This commit is contained in:
parent
0c38a497f9
commit
0d63424104
Binary file not shown.
@ -1,45 +1,58 @@
|
|||||||
unit MainFrm;
|
unit MainFrm;
|
||||||
|
|
||||||
|
{$WARN UNIT_PLATFORM OFF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
Classes,
|
Classes,
|
||||||
|
ComCtrls,
|
||||||
Controls,
|
Controls,
|
||||||
|
Dialogs,
|
||||||
Forms,
|
Forms,
|
||||||
Mask,
|
Mask,
|
||||||
StdCtrls,
|
StdCtrls,
|
||||||
|
|
||||||
JvComponent,
|
cxButtonEdit,
|
||||||
JvExControls,
|
cxContainer,
|
||||||
JvExMask,
|
cxControls,
|
||||||
JvPageList,
|
cxEdit,
|
||||||
JvToolEdit;
|
cxLookAndFeels,
|
||||||
|
cxMaskEdit,
|
||||||
|
cxTextEdit;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TMainForm = class(TForm)
|
TMainForm = class(TForm)
|
||||||
btnClose: TButton;
|
btnClose: TButton;
|
||||||
btnGenerate: TButton;
|
btnGenerate: TButton;
|
||||||
deFolder: TJvDirectoryEdit;
|
DefaultEditStyle: TcxDefaultEditStyleController;
|
||||||
edtFolderPostfix: TEdit;
|
deFolder: TcxButtonEdit;
|
||||||
edtFolderPrefix: TEdit;
|
dlgOutputFile: TSaveDialog;
|
||||||
feFile: TJvFilenameEdit;
|
dlgSchema: TOpenDialog;
|
||||||
feSchema: TJvFilenameEdit;
|
edtFolderPostfix: TcxTextEdit;
|
||||||
|
edtFolderPrefix: TcxTextEdit;
|
||||||
|
feFile: TcxButtonEdit;
|
||||||
|
feSchema: TcxButtonEdit;
|
||||||
gbOutput: TGroupBox;
|
gbOutput: TGroupBox;
|
||||||
lblFile: TLabel;
|
lblFile: TLabel;
|
||||||
lblFolder: TLabel;
|
lblFolder: TLabel;
|
||||||
lblFolderPostfix: TLabel;
|
lblFolderPostfix: TLabel;
|
||||||
lblFolderPrefix: TLabel;
|
lblFolderPrefix: TLabel;
|
||||||
lblSchema: TLabel;
|
lblSchema: TLabel;
|
||||||
plOutput: TJvPageList;
|
LookAndFeel: TcxLookAndFeelController;
|
||||||
|
plOutput: TPageControl;
|
||||||
rbFile: TRadioButton;
|
rbFile: TRadioButton;
|
||||||
rbFolder: TRadioButton;
|
rbFolder: TRadioButton;
|
||||||
spFile: TJvStandardPage;
|
spFile: TTabSheet;
|
||||||
spFolder: TJvStandardPage;
|
spFolder: TTabSheet;
|
||||||
|
|
||||||
procedure btnCloseClick(Sender: TObject);
|
procedure btnCloseClick(Sender: TObject);
|
||||||
procedure btnGenerateClick(Sender: TObject);
|
procedure btnGenerateClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure OutputTypeClick(Sender: TObject);
|
procedure OutputTypeClick(Sender: TObject);
|
||||||
|
procedure feFilePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||||||
|
procedure deFolderPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||||||
|
procedure feSchemaPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||||||
private
|
private
|
||||||
procedure GetFileName(Sender: TObject; const SchemaName: String; var Path, FileName: String);
|
procedure GetFileName(Sender: TObject; const SchemaName: String; var Path, FileName: String);
|
||||||
end;
|
end;
|
||||||
@ -47,6 +60,7 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
|
FileCtrl,
|
||||||
SysUtils,
|
SysUtils,
|
||||||
Windows,
|
Windows,
|
||||||
|
|
||||||
@ -92,7 +106,7 @@ end;
|
|||||||
|
|
||||||
procedure TMainForm.btnGenerateClick(Sender: TObject);
|
procedure TMainForm.btnGenerateClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if not FileExists(feSchema.FileName) then
|
if not FileExists(feSchema.Text) then
|
||||||
begin
|
begin
|
||||||
MessageBox(Self.Handle, 'Please specify a valid schema file.',
|
MessageBox(Self.Handle, 'Please specify a valid schema file.',
|
||||||
'Schema file does not exist', MB_OK or MB_ICONERROR);
|
'Schema file does not exist', MB_OK or MB_ICONERROR);
|
||||||
@ -106,7 +120,7 @@ begin
|
|||||||
if rbFile.Checked then
|
if rbFile.Checked then
|
||||||
begin
|
begin
|
||||||
OutputType := otSingle;
|
OutputType := otSingle;
|
||||||
OutputPath := feFile.FileName;
|
OutputPath := feFile.Text;
|
||||||
end else if rbFolder.Checked then
|
end else if rbFolder.Checked then
|
||||||
begin
|
begin
|
||||||
OutputType := otMultiple;
|
OutputType := otMultiple;
|
||||||
@ -114,7 +128,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
OnGetFileName := GetFileName;
|
OnGetFileName := GetFileName;
|
||||||
Execute(feSchema.FileName);
|
Execute(feSchema.Text);
|
||||||
|
|
||||||
|
ShowMessage('The data binding has been generated.');
|
||||||
finally
|
finally
|
||||||
Free();
|
Free();
|
||||||
end;
|
end;
|
||||||
@ -134,4 +150,28 @@ begin
|
|||||||
CheckValidFileName(FileName);
|
CheckValidFileName(FileName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.feFilePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||||||
|
begin
|
||||||
|
if dlgOutputFile.Execute() then
|
||||||
|
feFile.Text := dlgOutputFile.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.deFolderPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||||||
|
var
|
||||||
|
directory: String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if SelectDirectory('Select output folder', '', directory) then
|
||||||
|
deFolder.Text := directory;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TMainForm.feSchemaPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||||||
|
begin
|
||||||
|
if dlgSchema.Execute() then
|
||||||
|
feSchema.Text := dlgSchema.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -921,6 +921,7 @@ var
|
|||||||
collectionItem: TXMLDataBindingItem;
|
collectionItem: TXMLDataBindingItem;
|
||||||
sourceCode: TNamedFormatStringList;
|
sourceCode: TNamedFormatStringList;
|
||||||
typeDef: IXMLTypeDef;
|
typeDef: IXMLTypeDef;
|
||||||
|
typeMapping: TTypeMapping;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -984,9 +985,13 @@ begin
|
|||||||
begin
|
begin
|
||||||
typeDef := TXMLDataBindingSimpleProperty(AItem.CollectionItem).DataType;
|
typeDef := TXMLDataBindingSimpleProperty(AItem.CollectionItem).DataType;
|
||||||
|
|
||||||
// #ToDo3 (MvR) 19-3-2008: use Text for strings ?
|
|
||||||
sourceCode.Add('function TXML%<Name>:s.Get_%<ItemName>:s(Index: Integer): %<DataType>:s;');
|
sourceCode.Add('function TXML%<Name>:s.Get_%<ItemName>:s(Index: Integer): %<DataType>:s;');
|
||||||
|
|
||||||
|
if GetDataTypeMapping(typeDef, typeMapping) and (typeMapping.Conversion = tcString) then
|
||||||
|
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].Text', typeDef, dntCustom))
|
||||||
|
else
|
||||||
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].NodeValue', typeDef, dntCustom));
|
sourceCode.Add(XMLToNativeDataType('Result', 'List[Index].NodeValue', typeDef, dntCustom));
|
||||||
|
|
||||||
sourceCode.AddLn;
|
sourceCode.AddLn;
|
||||||
|
|
||||||
sourceCode.Add('function TXML%<Name>:s.Add(%<ItemName>:s: %<DataType>:s): %<DataInterface>:s;');
|
sourceCode.Add('function TXML%<Name>:s.Add(%<ItemName>:s: %<DataType>:s): %<DataInterface>:s;');
|
||||||
@ -1366,14 +1371,6 @@ begin
|
|||||||
typeMapping.Conversion := tcNone;
|
typeMapping.Conversion := tcNone;
|
||||||
|
|
||||||
|
|
||||||
(*
|
|
||||||
if Length(TypeConversionVariables[AAccessor, ANodeType, typeMapping.Conversion]) > 0 then
|
|
||||||
begin
|
|
||||||
Add('var');
|
|
||||||
Add(TypeConversionVariables[AAccessor, ANodeType, typeMapping.Conversion]);
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
|
|
||||||
Add('begin');
|
Add('begin');
|
||||||
|
|
||||||
if Length(ALinesBefore) > 0 then
|
if Length(ALinesBefore) > 0 then
|
||||||
|
@ -162,7 +162,7 @@ const
|
|||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TTypeConversion = (tcNone, tcBoolean, tcFloat, tcDateTime);
|
TTypeConversion = (tcNone, tcBoolean, tcFloat, tcDateTime, tcString);
|
||||||
TTypeConversions = set of TTypeConversion;
|
TTypeConversions = set of TTypeConversion;
|
||||||
|
|
||||||
TTypeMapping = record
|
TTypeMapping = record
|
||||||
@ -185,7 +185,7 @@ const
|
|||||||
(SchemaName: 'float'; DelphiName: 'Double'; Conversion: tcFloat),
|
(SchemaName: 'float'; DelphiName: 'Double'; Conversion: tcFloat),
|
||||||
(SchemaName: 'double'; DelphiName: 'Double'; Conversion: tcFloat),
|
(SchemaName: 'double'; DelphiName: 'Double'; Conversion: tcFloat),
|
||||||
(SchemaName: 'boolean'; DelphiName: 'Boolean'; Conversion: tcBoolean),
|
(SchemaName: 'boolean'; DelphiName: 'Boolean'; Conversion: tcBoolean),
|
||||||
(SchemaName: 'string'; DelphiName: 'WideString'; Conversion: tcNone)
|
(SchemaName: 'string'; DelphiName: 'WideString'; Conversion: tcString)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -255,7 +255,10 @@ const
|
|||||||
' Result := 0;' + CrLf +
|
' Result := 0;' + CrLf +
|
||||||
' end;' + CrLf +
|
' end;' + CrLf +
|
||||||
'end;' + CrLf +
|
'end;' + CrLf +
|
||||||
'' + CrLf
|
'' + CrLf,
|
||||||
|
|
||||||
|
{ tcString }
|
||||||
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -268,21 +271,24 @@ const
|
|||||||
{ tcNone } '',
|
{ tcNone } '',
|
||||||
{ tcBoolean } '',
|
{ tcBoolean } '',
|
||||||
{ tcFloat } ' %<Destination>:s := XMLToFloat(ChildNodes[''%<Source>:s''].NodeValue);',
|
{ tcFloat } ' %<Destination>:s := XMLToFloat(ChildNodes[''%<Source>:s''].NodeValue);',
|
||||||
{ tcDateTime } ' %<Destination>:s := XMLToDate(ChildNodes[''%<Source>:s''].NodeValue);'
|
{ tcDateTime } ' %<Destination>:s := XMLToDate(ChildNodes[''%<Source>:s''].NodeValue);',
|
||||||
|
{ tcString } ' %<Destination>:s := ChildNodes[''%<Source>:s''].Text;'
|
||||||
),
|
),
|
||||||
{ dntAttribute }
|
{ dntAttribute }
|
||||||
(
|
(
|
||||||
{ tcNone } '',
|
{ tcNone } '',
|
||||||
{ tcBoolean } '',
|
{ tcBoolean } '',
|
||||||
{ tcFloat } ' %<Destination>:s := XMLToFloat(AttributeNodes[''%<Source>:s''].NodeValue);',
|
{ tcFloat } ' %<Destination>:s := XMLToFloat(AttributeNodes[''%<Source>:s''].NodeValue);',
|
||||||
{ tcDateTime } ' %<Destination>:s := XMLToDate(AttributeNodes[''%<Source>:s''].NodeValue);'
|
{ tcDateTime } ' %<Destination>:s := XMLToDate(AttributeNodes[''%<Source>:s''].NodeValue);',
|
||||||
|
{ tcString } ' %<Destination>:s := AttributeNodes[''%<Source>:s''].Text;'
|
||||||
),
|
),
|
||||||
{ dntCustom}
|
{ dntCustom}
|
||||||
(
|
(
|
||||||
{ tcNone } '',
|
{ tcNone } '',
|
||||||
{ tcBoolean } '',
|
{ tcBoolean } '',
|
||||||
{ tcFloat } ' %<Destination>:s := XMLToFloat(%<Source>:s);',
|
{ tcFloat } ' %<Destination>:s := XMLToFloat(%<Source>:s);',
|
||||||
{ tcDateTime } ' %<Destination>:s := XMLToDate(%<Source>:s);'
|
{ tcDateTime } ' %<Destination>:s := XMLToDate(%<Source>:s);',
|
||||||
|
{ tcString } ''
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
{ daSet }
|
{ daSet }
|
||||||
@ -292,78 +298,28 @@ const
|
|||||||
{ tcNone } '',
|
{ tcNone } '',
|
||||||
{ tcBoolean } ' ChildNodes[''%<Destination>:s''].NodeValue := BoolToXML(%<Source>:s);',
|
{ tcBoolean } ' ChildNodes[''%<Destination>:s''].NodeValue := BoolToXML(%<Source>:s);',
|
||||||
{ tcFloat } ' ChildNodes[''%<Destination>:s''].NodeValue := FloatToXML(%<Source>:s);',
|
{ tcFloat } ' ChildNodes[''%<Destination>:s''].NodeValue := FloatToXML(%<Source>:s);',
|
||||||
{ tcDateTime } ' ChildNodes[''%<Destination>:s''].NodeValue := DateToXML(%<Source>:s);'
|
{ tcDateTime } ' ChildNodes[''%<Destination>:s''].NodeValue := DateToXML(%<Source>:s);',
|
||||||
|
{ tcString } ''
|
||||||
),
|
),
|
||||||
{ dntAttribute }
|
{ dntAttribute }
|
||||||
(
|
(
|
||||||
{ tcNone } '',
|
{ tcNone } '',
|
||||||
{ tcBoolean } ' SetAttribute(''%<Destination>:s'', BoolToXML(%<Source>:s));',
|
{ tcBoolean } ' SetAttribute(''%<Destination>:s'', BoolToXML(%<Source>:s));',
|
||||||
{ tcFloat } ' SetAttribute(''%<Destination>:s'', FloatToXML(%<Source>:s));',
|
{ tcFloat } ' SetAttribute(''%<Destination>:s'', FloatToXML(%<Source>:s));',
|
||||||
{ tcDateTime } ' SetAttribute(''%<Destination>:s'', DateToXML(%<Source>:s));'
|
{ tcDateTime } ' SetAttribute(''%<Destination>:s'', DateToXML(%<Source>:s));',
|
||||||
|
{ tcString } ''
|
||||||
),
|
),
|
||||||
{ dntCustom}
|
{ dntCustom}
|
||||||
(
|
(
|
||||||
{ tcNone } '',
|
{ tcNone } '',
|
||||||
{ tcBoolean } ' %<Destination>:s := BoolToXML(%<Source>:s);',
|
{ tcBoolean } ' %<Destination>:s := BoolToXML(%<Source>:s);',
|
||||||
{ tcFloat } ' %<Destination>:s := FloatToXML(%<Source>:s);',
|
{ tcFloat } ' %<Destination>:s := FloatToXML(%<Source>:s);',
|
||||||
{ tcDateTime } ' %<Destination>:s := DateToXML(%<Source>:s);'
|
{ tcDateTime } ' %<Destination>:s := DateToXML(%<Source>:s);',
|
||||||
|
{ tcString } ''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
(*
|
|
||||||
TypeConversionVariables: array[TDelphiAccessor, TDelphiNodeType, TTypeConversion] of String =
|
|
||||||
(
|
|
||||||
{ daGet }
|
|
||||||
(
|
|
||||||
{ dntElement }
|
|
||||||
(
|
|
||||||
{ tcNone } '',
|
|
||||||
{ tcBoolean } '',
|
|
||||||
{ tcFloat } '',
|
|
||||||
{ tcDateTime } ''
|
|
||||||
),
|
|
||||||
{ dntAttribute }
|
|
||||||
(
|
|
||||||
{ tcNone } '',
|
|
||||||
{ tcBoolean } '',
|
|
||||||
{ tcFloat } '',
|
|
||||||
{ tcDateTime } ''
|
|
||||||
),
|
|
||||||
{ dntCustom}
|
|
||||||
(
|
|
||||||
{ tcNone } '',
|
|
||||||
{ tcBoolean } '',
|
|
||||||
{ tcFloat } '',
|
|
||||||
{ tcDateTime } ''
|
|
||||||
)
|
|
||||||
),
|
|
||||||
{ daSet }
|
|
||||||
(
|
|
||||||
{ dntElement }
|
|
||||||
(
|
|
||||||
{ tcNone } '',
|
|
||||||
{ tcBoolean } '',
|
|
||||||
{ tcFloat } '',
|
|
||||||
{ tcDateTime } ''
|
|
||||||
),
|
|
||||||
{ dntAttribute }
|
|
||||||
(
|
|
||||||
{ tcNone } '',
|
|
||||||
{ tcBoolean } '',
|
|
||||||
{ tcFloat } '',
|
|
||||||
{ tcDateTime } ''
|
|
||||||
),
|
|
||||||
{ dntCustom}
|
|
||||||
(
|
|
||||||
{ tcNone } '',
|
|
||||||
{ tcBoolean } '',
|
|
||||||
{ tcFloat } '',
|
|
||||||
{ tcDateTime } ''
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
*)
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
end.
|
end.
|
||||||
|
@ -624,7 +624,8 @@ function TXMLDataBindingGenerator.CheckElementOccurance(AElement: IXMLElementDef
|
|||||||
if Supports(ANode, IXMLElementCompositor, compositor) then
|
if Supports(ANode, IXMLElementCompositor, compositor) then
|
||||||
begin
|
begin
|
||||||
case AOccurance of
|
case AOccurance of
|
||||||
boMinOccurs: Result := (compositor.MinOccurs = 0);
|
boMinOccurs: Result := (compositor.MinOccurs = 0) or
|
||||||
|
(compositor.CompositorType = ctChoice);
|
||||||
boMaxOccurs: Result := (compositor.MaxOccurs = MaxOccursUnbounded) or
|
boMaxOccurs: Result := (compositor.MaxOccurs = MaxOccursUnbounded) or
|
||||||
(compositor.MaxOccurs > 1);
|
(compositor.MaxOccurs > 1);
|
||||||
end;
|
end;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
-$A8
|
-$A8
|
||||||
-$B-
|
-$B-
|
||||||
-$C+
|
-$C-
|
||||||
-$D+
|
-$D+
|
||||||
-$E-
|
-$E-
|
||||||
-$F-
|
-$F-
|
||||||
@ -12,7 +12,7 @@
|
|||||||
-$L+
|
-$L+
|
||||||
-$M-
|
-$M-
|
||||||
-$N+
|
-$N+
|
||||||
-$O+
|
-$O-
|
||||||
-$P+
|
-$P+
|
||||||
-$Q-
|
-$Q-
|
||||||
-$R-
|
-$R-
|
||||||
@ -22,7 +22,7 @@
|
|||||||
-$V+
|
-$V+
|
||||||
-$W-
|
-$W-
|
||||||
-$X+
|
-$X+
|
||||||
-$YD
|
-$Y+
|
||||||
-$Z1
|
-$Z1
|
||||||
-GD
|
-GD
|
||||||
-cg
|
-cg
|
||||||
@ -32,8 +32,9 @@
|
|||||||
-M
|
-M
|
||||||
-$M16384,1048576
|
-$M16384,1048576
|
||||||
-K$00400000
|
-K$00400000
|
||||||
-LE"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
-N"lib"
|
||||||
-LN"C:\Documents and Settings\PsychoMark\My Documents\Borland Studio Projects\Bpl"
|
-LE"c:\program files\borland\delphi7\Projects\Bpl"
|
||||||
|
-LN"c:\program files\borland\delphi7\Projects\Bpl"
|
||||||
-w-UNSAFE_TYPE
|
-w-UNSAFE_TYPE
|
||||||
-w-UNSAFE_CODE
|
-w-UNSAFE_CODE
|
||||||
-w-UNSAFE_CAST
|
-w-UNSAFE_CAST
|
||||||
|
Loading…
Reference in New Issue
Block a user