View Issue Details

IDProjectCategoryView StatusLast Update
0003332JEDI VCL00 JVCL Componentspublic2005-12-03 04:23
ReporterChrister FahlgrenAssigned Toelahn 
Status resolvedResolutionduplicate 
Product Version3.00 
Target VersionFixed in Version 
Summary0003332: TJvSimpleXMLElemText.LoadFromStream doesn't preserve whitespace.
DescriptionWhen loading an XML element from file like <text>Hi three spaces</text> it is read as <text>Hi three whitespaces</text> stripping the extra spaces.

According to the XML gurus I know (I am not an XML guru :-)) this whitespace should be preserved when reading a text element.

I would prefer no stripping of whitespaces at all for text elements. Potentially add an option to strip.

Note that the stripping is also very inconsistent - not stripping other whitespace such as tab, cr and lf. If you strip - strip it all off.

My proposal is to preserve white space as default and that this is what should be checked in.

I believe my proposal is backed up by the statements here:

procedure TJvSimpleXMLElemText.LoadFromStream(const Stream: TStream; Parent: TJvSimpleXML);
  I, lStreamPos, Count: Integer;
  lBuf: array [0..cBufferSize - 1] of Char;
  St: string;
  lStreamPos := Stream.Position;
  St := '';

    Count := Stream.Read(lBuf, SizeOf(lBuf));
    if Parent <> nil then
      Parent.DoLoadProgress(Stream.Position, Stream.Size);
    for I := 0 to Count - 1 do
      //Increment Stream pos for after comment

      case lBuf[I] of
            //Quit text
            Count := 0;
          St := St + lBuf[I];
  until Count = 0;
  if GetSimpleXML <> nil then
  Value := St;
  Name := '';

  if Parent <> nil then
    Parent.DoValueParsed('', St);

  Stream.Seek(lStreamPos, soFromBeginning);

Best regards,
TagsNo tags attached.


duplicate of 0002822 resolvedjfudickar TJvAppXMLFileStorage.ReadString bug if string containsLineFeed characters 


Christer Fahlgren

2005-11-30 02:34

reporter   ~0008178

Note that in my example above the tree spaces was stripped!
This is how it should be interpreted:
<text>Hi three___spaces</text> it is read as <text>Hi three_whitespaces</text> substitute the _ for a space.



2005-12-02 18:33

developer   ~0008191

I'm not sure I follow, as I use TJvSimpleXML extensively and whitespace is never stripped... Use the daily snapshots from here:

And tell us if that still happens. If it does, please post a simple example program and XML file that produces the bug. Please zip it up, including only the .dpr, .pas, .dfm & .xml files.

Christer Fahlgren

2005-12-03 03:34

reporter   ~0008193

Yes you are right, I am using 3.00 and this is fixed in the daily build. This is a duplicate of issue

Sorry for filing an issue about an already fixed bug!

Best regards,

Issue History

Date Modified Username Field Change
2005-11-30 02:31 Christer Fahlgren New Issue
2005-11-30 02:34 Christer Fahlgren Note Added: 0008178
2005-12-02 18:33 elahn Note Added: 0008191
2005-12-02 18:33 elahn Status new => feedback
2005-12-03 03:34 Christer Fahlgren Note Added: 0008193
2005-12-03 04:23 elahn Relationship added duplicate of 0002822
2005-12-03 04:23 elahn Duplicate ID 0 => 2822
2005-12-03 04:23 elahn Status feedback => resolved
2005-12-03 04:23 elahn Resolution open => duplicate
2005-12-03 04:23 elahn Assigned To => elahn