← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/fix_html_module into lp:zorba/data-converters-module

 

Sorin Marian Nasoi has proposed merging lp:~zorba-coders/zorba/fix_html_module into lp:zorba/data-converters-module.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Sorin Marian Nasoi (sorin.marian.nasoi)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix_html_module/+merge/106814

When the tidying is not successful, an error is raised instead of just returning the empty sequence.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix_html_module/+merge/106814
Your team Zorba Coders is subscribed to branch lp:zorba/data-converters-module.
=== modified file 'src/com/zorba-xquery/www/modules/converters/html.xq.src/tidy_wrapper.h'
--- src/com/zorba-xquery/www/modules/converters/html.xq.src/tidy_wrapper.h	2011-08-18 23:42:49 +0000
+++ src/com/zorba-xquery/www/modules/converters/html.xq.src/tidy_wrapper.h	2012-05-22 14:10:24 +0000
@@ -114,7 +114,13 @@
       }
       else
       {
-        return no;
+        zorba::Item lError = Zorba::getInstance(0)->getItemFactory()
+          ->createQName(
+              "http://www.zorba-xquery.com/modules/converters/html";,
+              "TidyOption");
+          std::ostringstream lErrorMsg;
+          lErrorMsg << "Tidy option '" << option << "' not found.";
+          throw USER_EXCEPTION(lError, lErrorMsg.str());
       }
       return ok;
     }
@@ -169,11 +175,21 @@
       checkRC(rc, "Could not set error buffer");
       rc = tidyParseSource(tDoc, &lInputSource);
       checkRC(rc, "Could not parse the source");
+			//try cleanup
       rc = tidyCleanAndRepair(tDoc);
-      checkRC(rc, "Could not clean and repair");
-      rc = tidyRunDiagnostics(tDoc);
+      if ( rc <= 1 )
+	      rc = tidyRunDiagnostics(tDoc);
+
+			//if cleanup was not successful try to force output
       if ( rc > 1 )
+      {
         rc = ( tidyOptSetBool(tDoc, TidyForceOutput, yes) ? rc : -1 );
+        checkRC(rc, "Could not set force-output to true");
+				rc = tidyCleanAndRepair(tDoc);
+	      checkRC(rc, "Could not clean and repair");
+	      rc = tidyRunDiagnostics(tDoc);
+        checkRC(rc, "Could not clean and repair");
+      }
 
       // Tidy does not support streaming for output, it only supports
       // something they call a "sink". Therefore we buffer it in a string.
@@ -189,10 +205,14 @@
       try
       {
         return lDM->parseXML(lStream);
-      } catch (ZorbaException&)
+      } catch (ZorbaException& e)
       {
-        return NULL;//Zorba::getInstance(0)->getItemFactory()->createString(lResult);
+        zorba::Item lError = Zorba::getInstance(0)->getItemFactory()->createQName(
+            "http://www.zorba-xquery.com/modules/converters/html";,
+            "InternalError");
+        throw USER_EXCEPTION(lError, e.what() );
       }
+      return NULL;
     }
   } /* namespace htmlmodule */
 } /* namespace zorba */


Follow ups