Browse Source

Applied a fix similar to r13047:
* Handle empty tags by emitting a pair of StartElement/EndElement
events. While this is optional in HTML parser, here in XML parser it is a requirement.

git-svn-id: trunk@13048 -

sergei 16 years ago
parent
commit
e75bad33e4
1 changed files with 11 additions and 2 deletions
  1. 11 2
      packages/fcl-xml/src/sax_xml.pp

+ 11 - 2
packages/fcl-xml/src/sax_xml.pp

@@ -371,11 +371,20 @@ begin
       if Length(TokenText) > 0 then
       begin
         Attr := nil;
-        if TokenText[1] = '/' then
+        if TokenText[Length(fTokenText)]='/' then  // handle empty tag
+        begin
+          setlength(fTokenText,length(fTokenText)-1);
+          // Do NOT combine to a single line, as Attr is an output value!
+          TagName := SplitTagString(TokenText, Attr);
+          DoStartElement('', TagName, '', Attr);
+          DoEndElement('', TagName, '');
+        end
+        else if TokenText[1] = '/' then
         begin
           DoEndElement('',
             SplitTagString(Copy(TokenText, 2, Length(TokenText)), Attr), '');
-        end else if TokenText[1] <> '!' then
+        end
+        else if TokenText[1] <> '!' then
         begin
           // Do NOT combine to a single line, as Attr is an output value!
           TagName := SplitTagString(TokenText, Attr);