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

2012-05-24 Thread Matthias Brantner
I think we should add an additional function

declare function html:parse (
$html as xs:string, 
$options as element(html-options:options) 
 ) as xs:string external;

which returns the string processed by tidy. The other functions should invoke 
this function and call parse-xml on the result. This gives the user a way to 
see the result of tidy.
-- 
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.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2012-05-22 Thread Sorin Marian Nasoi
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 +
+++ src/com/zorba-xquery/www/modules/converters/html.xq.src/tidy_wrapper.h	2012-05-22 14:10:24 +
@@ -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 */

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2012-05-22 Thread Sorin Marian Nasoi
Review: Approve


-- 
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.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp


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

2012-05-22 Thread Matthias Brantner
Review: Needs Fixing

- the error message is misleading because the query doesn't explicitly invoke 
parse-xml: 
/home/mbrantner/zorba/build/URI_PATH/com/zorba-xquery/www/modules/converters/html.xq:124,5:
 user-defined error 
[http://www.zorba-xquery.com/modules/converters/html#InternalError]: invalid 
content passed to fn:parse-xml(): loader parsing error: Failed to parse QName 
'divine:'
- it's still unclear to me how the user can find out how the result after 
parsing looked like. In this case, tidying succeeded but there is a problem 
with the result after tidying.
- please don't use tabs
  
-- 
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.

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp