View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002368 | JEDI VCL | 00 JVCL Components | public | 2004-12-08 17:14 | 2004-12-11 03:10 |
Reporter | anonymous | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.00 BETA 2 | ||||
Target Version | Fixed in Version | 3.00 RC 1 | |||
Summary | 0002368: TJvSimpleXML - reading properties with "default value" when using "sxoAutoCreate" | ||||
Description | When 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 Information | This code illustrates the problem; procedure TForm1.Button1Click(Sender: TObject); var xml :TjvSimpleXML; a :string; begin xml:=TjvSimpleXML.create(application); xml.Options:=[sxoAutoCreate]; a:=xml.Root.Properties.Value('TEST','DEFAULT'); if a='DEFAULT' then showmessage('I''m default') else if a='' then showmessage('Oops, autocreated empty property'); end; 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. | ||||
Tags | No tags attached. | ||||
|
Try the attached update. |
|
Thanks Peter, attached file solved the problem. |
|
I just noticed that the TJvSimpleXMLElems.Value(x,y) has the same problem (using the JvSimpleXml041209.zip) New example code: procedure TForm1.Button1Click(Sender: TObject); var xml :TjvSimpleXML; a :string; begin xml:=TjvSimpleXML.create(application); xml.Options:=[sxoAutoCreate]; a:=xml.Root.Items.Value('TEST','DEFAULT'); if a='DEFAULT' then showmessage('I''m default') else if a='' then showmessage('Oops, autocreated empty value'); end; |
2004-12-10 05:15
|
JvSimpleXml041210.zip (14,867 bytes) |
|
Try the new file attached |
|
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! |
|
Updated in CVS |
Date Modified | Username | Field | Change |
---|---|---|---|
2004-12-08 17:14 | anonymous | New Issue | |
2004-12-09 12:22 |
|
File Added: JvSimpleXml041209.zip | |
2004-12-09 12:22 |
|
Note Added: 0005847 | |
2004-12-09 12:22 |
|
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 |
|
File Deleted: JvSimpleXml041209.zip | |
2004-12-10 05:15 |
|
File Added: JvSimpleXml041210.zip | |
2004-12-10 05:15 |
|
Note Added: 0005851 | |
2004-12-10 16:50 | mliesen | Note Added: 0005859 | |
2004-12-11 03:10 |
|
Status | feedback => resolved |
2004-12-11 03:10 |
|
Resolution | open => fixed |
2004-12-11 03:10 |
|
Assigned To | => user72 |
2004-12-11 03:10 |
|
Note Added: 0005860 | |
2004-12-11 03:10 |
|
Assigned To | user72 => |