Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: rcoll on March 26, 2009, 07:07:31 pm

Title: wxSmith and XML
Post by: rcoll on March 26, 2009, 07:07:31 pm
I have a minor (if unusual) problem.

While developing a new function for wxSmith, I noticed that when I store a wxArrayString as a property, the XML writer stores the entire array to the *.wxs file properly.  However, when reading it back in (on the next session) the XML reader compresses multiple space chars into a single space.  Normally this is not a problem, but in my case the space chars are significant.

Is there any (simple) way to turn off this behavior?

Thanks,
Ringo
Title: Re: wxSmith and XML
Post by: MortenMacFly on March 26, 2009, 08:15:23 pm
Is there any (simple) way to turn off this behavior?
I'm afraid not. wxSmith uses TinXML for it's resources. The reason for that behaviour lies in TinyXML which (by default) will condense white spaces.
See the interface description to SetCondenseWhiteSpace(...) in tinyxml.h for details. You will realise that this behaviour is also the standard behaviour as proposed (or silently acknowledged) by the XML standard.
BUT: If you really need un-condensed white-spaces, why don't you write a CData element? This should work just fine.
Title: Re: wxSmith and XML
Post by: rcoll on March 26, 2009, 09:58:32 pm
Yes, there are several work-arounds I could use (and will); I was just hoping for a "magic bullet" to save some time.

Thanks,
Ringo
Title: Re: wxSmith and XML
Post by: rcoll on March 26, 2009, 10:58:41 pm
Er ... just a quick question about TinyXML .... shouldn't it be WRITING files with condensed spaces, rather than condensing them on input?  If I manually edit the *.wxs file, I can see my wxArrayString stored in all of it's whitespace glory; it's only when reading it back in that the white space is condensed.  Or am I confused (would not be the first time)?

Ringo
Title: Re: wxSmith and XML
Post by: MortenMacFly on March 27, 2009, 11:12:09 am
Or am I confused (would not be the first time)?
Now you got me confused. :-)

I need some more info:
- Are you using wxSmith and/or ConfigManager to read/write to the wxs file?
- Can you provide a sample wxs file with an array string?
Title: Re: wxSmith and XML
Post by: Jenna on March 27, 2009, 11:19:58 am
If I see it right, tinyxml only uses the value set with SetCondenseWhiteSpace(...) in ReadValue and ReadText, so it will save all spaces, but (if condenseWhiteSpace is set) condense them at read-time.
Title: Re: wxSmith and XML
Post by: MortenMacFly on March 27, 2009, 11:41:16 am
If I see it right, tinyxml only uses the value set with SetCondenseWhiteSpace(...) in ReadValue and ReadText, so it will save all spaces, but (if condenseWhiteSpace is set) condense them at read-time.
Hehe... that makes it clear. I'd say quite in-consequent, right?! The better default option would be to have the condensed variable to false so that it's the same when reading and writing...