From 8f29def76ebce162ab5d7c78e29fd34c04076c1d Mon Sep 17 00:00:00 2001 From: sergei Date: Tue, 15 Jun 2010 16:13:42 +0000 Subject: [PATCH] * 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 - --- packages/fcl-xml/src/xmlread.pp | 13 ++++++++++--- packages/fcl-xml/tests/xmlts.pp | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/fcl-xml/src/xmlread.pp b/packages/fcl-xml/src/xmlread.pp index f01024d83f..717b50fb49 100644 --- a/packages/fcl-xml/src/xmlread.pp +++ b/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 diff --git a/packages/fcl-xml/tests/xmlts.pp b/packages/fcl-xml/tests/xmlts.pp index a59e00f404..e52429c31c 100644 --- a/packages/fcl-xml/tests/xmlts.pp +++ b/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