2
0
Эх сурвалжийг харах

* xmlread.pp: when IgnoreComments=True, merge together text nodes that precede and follow the skipped comment. With this fix, the reader finally produces normalized documents in all modes, so remove the corresponding cheat from testing program (xmlts.pp).

git-svn-id: trunk@15442 -
sergei 15 жил өмнө
parent
commit
8f29def76e

+ 10 - 3
packages/fcl-xml/src/xmlread.pp

@@ -2060,7 +2060,6 @@ var
   wc: WideChar;
 begin
   Result := False;
-  FValue.Length := 0;
   StoreLocation(FTokenStart);
   repeat
     wc := FSource.SkipUntil(FValue, Delim);
@@ -2083,12 +2082,16 @@ begin
 end;
 
 procedure TXMLReader.ParseComment;    // [15]
+var
+  SaveLength: Integer;
 begin
   ExpectString('--');
+  SaveLength := FValue.Length;
   if SkipUntilSeq([#0, '-'], '-') then
   begin
     ExpectChar('>');
-    DoComment(FValue.Buffer, FValue.Length);
+    DoComment(@FValue.Buffer[SaveLength], FValue.Length-SaveLength);
+    FValue.Length := SaveLength;
   end
   else
     FatalError('Unterminated comment', -1);
@@ -2117,6 +2120,7 @@ begin
   if FSource.FBuf^ <> '?' then
     SkipS(True);
 
+  FValue.Length := 0;
   if SkipUntilSeq(GT_Delim, '?') then
   begin
     SetString(Value, FValue.Buffer, FValue.Length);
@@ -2960,8 +2964,11 @@ begin
         end
         else if FSource.FBuf^ = '-' then
         begin
-          DoText(FValue.Buffer, FValue.Length, not nonWs);
+          if not FIgnoreComments then
+            DoText(FValue.Buffer, FValue.Length, not nonWs);
           ParseComment;
+          if FIgnoreComments then
+            Continue;
         end
         else
         begin

+ 0 - 1
packages/fcl-xml/tests/xmlts.pp

@@ -482,7 +482,6 @@ begin
       end;
 
     if outURI = '' then Exit;
-    TempDoc.DocumentElement.Normalize;
     try
       // reference data must be parsed in non-validating mode because it contains DTDs
       // only when Notations need to be reported