CVS update: /cowiki/includes/cowiki/class/parse/

[email protected] 2 Jun 2005 19:22:07 -0000
Newsgroups gmane.comp.php.cowiki.cvs
Message-ID <[email protected]>
User: cmarble 
Date: 2005/06/02 12:22:07

Modified:
   cowiki/includes/cowiki/class/parse/class.WikiReverseParser.php

Log:
 Rudimentary handling of xml errors during a reverse parse.

File Changes:

Directory: /cowiki/includes/cowiki/class/parse/
===============================================

File [changed]: class.WikiReverseParser.php
Url: http://cowiki.tigris.org/source/browse/cowiki/includes/cowiki/class/parse/class.WikiReverseParser.php?r1=1.22&r2=1.23
Delta lines:  +15 -4
--------------------
--- class.WikiReverseParser.php	31 May 2005 11:49:37 -0000	1.22
+++ class.WikiReverseParser.php	2 Jun 2005 19:22:05 -0000	1.23
@@ -2,7 +2,7 @@
 
 /**
  *
- * $Id: class.WikiReverseParser.php,v 1.22 2005/05/31 11:49:37 cmarble Exp $
+ * $Id: class.WikiReverseParser.php,v 1.23 2005/06/02 19:22:05 cmarble Exp $
  *
  * This file is part of coWiki. coWiki is free software under the terms of
  * the GNU General Public License (GPL). Read the LICENSE file. If you did
@@ -17,7 +17,7 @@
  * @author      Daniel T. Gorski, <[email protected]>
  * @copyright   (C) Daniel T. Gorski, {@link http://www.develnet.org}
  * @license     http://www.gnu.org/licenses/gpl.html
- * @version     $Revision: 1.22 $
+ * @version     $Revision: 1.23 $
  *
  */
 
@@ -224,8 +224,19 @@
         xml_set_character_data_handler( $this->rParser,
                                 array(&$this,'xml_cdata_handler') );
 
-        if(!xml_parse( $this->rParser, $sStr )){
-          echo xml_error_string(xml_get_error_code($this->rParser));
+        $aLines = explode( "\n",$sStr);
+        $max = sizeof($aLines);
+        $lc = 0;
+
+        while($lc < $max){ 
+            if(!xml_parse( $this->rParser, $aLines[$lc], ($lc==$max-1)))
+            {
+                $this->appendRow( sprintf("XML error: %s\n",
+                        xml_error_string(xml_get_error_code($this->rParser))));
+                $this->appendRow( $aLines[$lc] );
+                echo "Error on line ".$lc." before ".$aLines[$lc]."\n";
+            }
+            $lc++;
         }
 
         return implode("\n",$this->aRow);