View Issue Details

IDProjectCategoryView StatusLast Update
0002368JEDI VCL00 JVCL Componentspublic2004-12-11 03:10
ReporteranonymousAssigned To 
Status resolvedResolutionfixed 
Product Version3.00 BETA 2 
Target VersionFixed in Version3.00 RC 1 
Summary0002368: TJvSimpleXML - reading properties with "default value" when using "sxoAutoCreate"
a) reading property element: TJvSimpleXMLProps.value(X,Y)
b) property X does not exists
c) supplies a default value Y (not an empty string)
d) sxoAutoCreate is a member of TjvSimpleXML.options.

The result of TJvSimpleXMLProps.value(X,Y) will not be the value Y, but rather an empty string.
Additional InformationThis code illustrates the problem;

procedure TForm1.Button1Click(Sender: TObject);
var xml :TjvSimpleXML;
    a :string;
  if a='DEFAULT' then
    showmessage('I''m default')
  else if a='' then
    showmessage('Oops, autocreated empty property');

Running the example, 'a' will contain an empty string, not the value 'DEFAULT' as I would expect.
The problem lies in method TJvSimpleXMLProps.GetItemNamed which automaticly create the property with empty string. It looks like it would be safe to return nil instead of creating within TJvSimpleXMLProps.GetItemNamed.

TagsNo tags attached.



2004-12-09 12:22


Try the attached update.


2004-12-09 15:08

viewer   ~0005849

Thanks Peter, attached file solved the problem.


2004-12-09 19:05

reporter   ~0005850

Last edited: 2004-12-09 19:06

I just noticed that the TJvSimpleXMLElems.Value(x,y) has the same problem (using the

New example code:

procedure TForm1.Button1Click(Sender: TObject);
var xml :TjvSimpleXML;
  a :string;
  if a='DEFAULT' then
    showmessage('I''m default')
  else if a='' then
    showmessage('Oops, autocreated empty value');

2004-12-10 05:15 (14,867 bytes)


2004-12-10 05:15


Try the new file attached


2004-12-10 16:50

reporter   ~0005859

Almost there, line 121 and 1854;

function GetItemNamedDefault(const Name): TJvSimpleXMLProp;
should be
function GetItemNamedDefault(const Name, Default: string): TJvSimpleXMLProp;

With the above change, it works like charm. Thanks!


2004-12-11 03:10


Updated in CVS

Issue History

Date Modified Username Field Change
2004-12-08 17:14 anonymous New Issue
2004-12-09 12:22 user72 File Added:
2004-12-09 12:22 user72 Note Added: 0005847
2004-12-09 12:22 user72 Status new => feedback
2004-12-09 15:08 anonymous Note Added: 0005849
2004-12-09 19:05 mliesen Note Added: 0005850
2004-12-09 19:06 mliesen Note Edited: 0005850
2004-12-10 05:14 user72 File Deleted:
2004-12-10 05:15 user72 File Added:
2004-12-10 05:15 user72 Note Added: 0005851
2004-12-10 16:50 mliesen Note Added: 0005859
2004-12-11 03:10 user72 Status feedback => resolved
2004-12-11 03:10 user72 Resolution open => fixed
2004-12-11 03:10 user72 Assigned To => user72
2004-12-11 03:10 user72 Note Added: 0005860
2004-12-11 03:10 user72 Assigned To user72 =>