* 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 -
This commit is contained in:
sergei 2010-06-15 16:13:42 +00:00
parent cfae57bccd
commit 8f29def76e
2 changed files with 10 additions and 4 deletions

View File

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

View File

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