Re: [lazarus] XMLCFG BUG ?
Sebastian Günther schrieb: Ok great, then I'll implement it now. Done. The new xmlcfg unit is committed (trunk only, so far). I've changed quite some things, so be warned that it might break existing application somewhat. The main change: You cannot specify the filename in the constructor anymore, but you _have_ to use the Filename property. Escaping for invalid chars in XML is enabled by default; if you don't want to use it, set UseEscaping to False before setting the filename. If you always want to start with an empty file, set StartEmpty to True. I did only some quick tests and everything looks fine; hopefully I didn't introduce any new bugs... - Sebastian _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
Mattias Gaertner schrieb: While you are thinking about it, can you give an opinion on how to fix lazarus bug 902: http://www.lazarus.freepascal.org/mantis/view.php?id=902 Yes, it is the same. I would expect, that xmlwriter should raise an exception. I have a small suggestion, or better, a solution: First, yes, the xmlwriter should check names for validity. Second: Adding escaping to xmlcfg. Whenever a part of a path violates the XML specs, this part gets escaped. I suggest to use the underscore character as escaping char. Existing underscores in names gets doubled, and invalid characters will be transformed to underscore plus hex code. As I don't want to break too many existing xmlcfg files, the use of escaping should be indicated by a leading underscore in the name, as I think this case is quite seldom. (hardly any currently existing xmlcfg files will use an underscore as first character in any name, I think). Any comments? - Sebastian _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
On Mon, 15 Aug 2005 22:04:35 +0200 Sebastian Günther [EMAIL PROTECTED] wrote: Mattias Gaertner schrieb: While you are thinking about it, can you give an opinion on how to fix lazarus bug 902: http://www.lazarus.freepascal.org/mantis/view.php?id=902 Yes, it is the same. I would expect, that xmlwriter should raise an exception. I have a small suggestion, or better, a solution: First, yes, the xmlwriter should check names for validity. Second: Adding escaping to xmlcfg. Whenever a part of a path violates the XML specs, this part gets escaped. I suggest to use the underscore character as escaping char. Existing underscores in names gets doubled, and invalid characters will be transformed to underscore plus hex code. As I don't want to break too many existing xmlcfg files, the use of escaping should be indicated by a leading underscore in the name, as I think this case is quite seldom. (hardly any currently existing xmlcfg files will use an underscore as first character in any name, I think). Any comments? The systems sounds useful. Just one question: Why should xmlcfg allow, what xml does not? I mean, I see the gain to allow numbers as identifiers, but OTOH a newbie could be mislead, that his paths are the xml paths (e.g. '1' vs '_1'). When the configs are read by other applications the paths are different. Maybe we can add a boolean property to TXMLConfig, whether to raise an exception or to automatically convert illegal paths? Then again, what should be the default for the property? Mattias _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
Mattias Gaertner schrieb: Just one question: Why should xmlcfg allow, what xml does not? I mean, I see the gain to allow numbers as identifiers, but OTOH a newbie could be mislead, that his paths are the xml paths (e.g. '1' vs '_1'). When the configs are read by other applications the paths are different. Maybe we can add a boolean property to TXMLConfig, whether to raise an exception or to automatically convert illegal paths? Then again, what should be the default for the property? Hmm! I just got a new idea! (which is _so_ apparent, that I really don't know why I didn't think about it earlier. See second thought below)... I should add two new properties: - one for enabling the conversion stuff. (Rationale: when I wrote the first version of xmlcfg, it was planned as a cross-platform replacement for TRegistry and similar components, in the long term. And TRegistry doesn't has such restrictions. Additionally, a newbie doesn't really care about XML and its restrictions.) - A property which specifies the document root element name. Using this property you could read and write lots of existing XML files using the simple xmlcfg methods. (Personal reminder for me: Finally add namespace support. More and more existing XML files are using them.) Any further comments? :-) - Sebastian _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
On Thu, 11 Aug 2005 23:36:54 +0200 Sebastian Günther [EMAIL PROTECTED] wrote: Christian Fillion schrieb: Hi all i'm making a application tha use the xmlcfg.pp unit. I dont know if i find a bug in the xmlcfg file at procedure TXMLConfig.SetValue(const APath, AValue: String); Anyway this is a small sample of the bug [...] For some reason SetValue have difficulty to set APath with one letter lenght and dont create 500 element Sorry, I cannot reproduce this problem, using the latest compiler version. But the xmlcfg unit has not changed for ages, so perhaps it's a problem with your compiler or RTL/FCL. I don't know if the one letter is a problem, but token_xml.SetValue('keys/' + {'t' +} inttostr(x) + '/values' , 'some_value' ); the inttostr(x) does not create a valid xml name. The fpc xmlwriter allows it and writes it (bug), but the xmlreader does not like it. Mattias _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
Mattias Gaertner schrieb: I don't know if the one letter is a problem, but token_xml.SetValue('keys/' + {'t' +} inttostr(x) + '/values' , 'some_value' ); the inttostr(x) does not create a valid xml name. The fpc xmlwriter allows it and writes it (bug), but the xmlreader does not like it. Okay, no I have it. The xmlreader is right. According to the XML specs, an element name is defined as (Letter | '_' | ':') (NameChar)* and NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender So the xmlwriter writes an illegal XML document in this case. How should we handle this? Should xmlcfg add a special prefix (perhaps together with a special attribute for reaching uniqueness), ignore such a case, or throw an exception? - Sebastian _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
On Fri, 12 Aug 2005 21:51:51 +0200 Vincent Snijders [EMAIL PROTECTED] wrote: Sebastian Günther wrote: Mattias Gaertner schrieb: I don't know if the one letter is a problem, but token_xml.SetValue('keys/' + {'t' +} inttostr(x) + '/values' , 'some_value' ); the inttostr(x) does not create a valid xml name. The fpc xmlwriter allows it and writes it (bug), but the xmlreader does not like it. Okay, no I have it. The xmlreader is right. According to the XML specs, an element name is defined as (Letter | '_' | ':') (NameChar)* and NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender So the xmlwriter writes an illegal XML document in this case. How should we handle this? Should xmlcfg add a special prefix (perhaps together with a special attribute for reaching uniqueness), ignore such a case, or throw an exception? While you are thinking about it, can you give an opinion on how to fix lazarus bug 902: http://www.lazarus.freepascal.org/mantis/view.php?id=902 Yes, it is the same. I would expect, that xmlwriter should raise an exception. Mattias _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] XMLCFG BUG ?
Christian Fillion schrieb: Hi all i'm making a application tha use the xmlcfg.pp unit. I dont know if i find a bug in the xmlcfg file at procedure TXMLConfig.SetValue(const APath, AValue: String); Anyway this is a small sample of the bug [...] For some reason SetValue have difficulty to set APath with one letter lenght and dont create 500 element Sorry, I cannot reproduce this problem, using the latest compiler version. But the xmlcfg unit has not changed for ages, so perhaps it's a problem with your compiler or RTL/FCL. Regards, Sebastian _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] XMLCFG BUG ?
Hi all i'm making a application tha use the xmlcfg.pp unit. I dont know if i find a bug in the xmlcfg file at procedure TXMLConfig.SetValue(const APath, AValue: String); Anyway this is a small sample of the bug program xml_bug; uses SysUtils,xmlcfg; var token_xml: TXMLConfig;var x: integer; begin token_xml := TXMLConfig.Create( 'bug.xml' ); for x:= 0 to 500 do begin token_xml.SetValue('keys/' + {'t' +} inttostr(x) + '/values' , 'some_value' ); end; token_xml.Free; end. For some reason SetValue have difficulty to set APath withone letter lenght and dont create 500 element But if i remove coment over the{'t' +} (thats add a t to the middle token) thats work correcly In other way it's create 500 element in the xml If a Lazarus or FPC Guru can correct this or point me how to correct it i will be realy happy Thanks Christian Fillion