The attached patch adds support for reading html 4 files to sewfox. This is done by adding gboolean is_html as a third parameter to sx_box_new_from_xml_css_paths() and sx_box_new_from_xml_css_bufs(). They then use htmlParseFile() or htmlParseDoc() if is_html is set. I have hard coded to use UTF-8 as the character set though. The patch also modifies minifox to set is_html to TRUE if the xml file ends with .html David -- Make your website SCREEM - Site Creating & Editing EnvironMent URL: http://www.screem.org/ Mail: david screem org
Index: src/sx-box-view.c =================================================================== RCS file: /cvs/gnome/sewfox/src/sx-box-view.c,v retrieving revision 1.17 diff -u -r1.17 sx-box-view.c --- src/sx-box-view.c 6 Mar 2004 01:42:41 -0000 1.17 +++ src/sx-box-view.c 7 Mar 2004 15:01:28 -0000 @@ -29,6 +29,7 @@ #include <string.h> #include <libcroco/cr-om-parser.h> #include <libxml/tree.h> +#include <libxml/HTMLparser.h> #include "sx-box-view.h" #include "sx-lay-eng.h" @@ -641,14 +642,15 @@ */ SXBoxView * sx_box_view_new_from_xml_css_paths (const guchar *a_xml_path, - const guchar *a_css_path) + const guchar *a_css_path, + gboolean is_html) { enum CRStatus status = CR_OK ; CRStyleSheet *ua_sheet = NULL, *user_sheet ; CRCascade *cascade = NULL ; SXBoxView *result = NULL ; xmlDoc *xml_doc = NULL ; - + g_return_val_if_fail (a_xml_path && a_css_path, NULL) ; status = sx_box_view_get_default_stylesheet (&ua_sheet) ; @@ -672,7 +674,14 @@ goto cleanup ; } ua_sheet = user_sheet = NULL ; - xml_doc = xmlParseFile (a_xml_path) ; + if (!is_html) + { + xml_doc = xmlParseFile (a_xml_path) ; + } + else + { + xml_doc = htmlParseFile (a_xml_path, "UTF-8"); + } if (!xml_doc) { cr_utils_trace_info ("Could not parse xml file") ; @@ -717,7 +726,8 @@ */ SXBoxView * sx_box_view_new_from_xml_css_bufs (const guchar *a_xml_buf, - const guchar *a_css_buf) + const guchar *a_css_buf, + gboolean is_html) { enum CRStatus status = CR_OK ; CRStyleSheet *sheet = NULL; @@ -747,7 +757,14 @@ sheet = NULL ; len = strlen (a_xml_buf) ; - xml_doc = xmlParseMemory (a_xml_buf, len) ; + if (!is_html) + { + xml_doc = xmlParseMemory (a_xml_buf, len) ; + } + else + { + xml_doc = htmlParseDoc (a_xml_buf, "UTF-8"); + } if (!xml_doc) { cr_utils_trace_info ("Could not parse xml buf") ; Index: src/sx-box-view.h =================================================================== RCS file: /cvs/gnome/sewfox/src/sx-box-view.h,v retrieving revision 1.9 diff -u -r1.9 sx-box-view.h --- src/sx-box-view.h 6 Mar 2004 01:42:41 -0000 1.9 +++ src/sx-box-view.h 7 Mar 2004 15:01:28 -0000 @@ -66,7 +66,8 @@ xmlDoc *a_xml_doc) ; SXBoxView * sx_box_view_new_from_xml_css_bufs (const guchar *a_xml_buf, - const guchar *a_css_buf) ; + const guchar *a_css_buf, + gboolean is_html) ; enum CRStatus sx_box_view_update_box_model_attrs (SXBoxView *a_this) ; @@ -91,7 +92,8 @@ void sx_box_view_finalize (GObject *a_this) ; SXBoxView * sx_box_view_new_from_xml_css_paths (const guchar *a_xml_path, - const guchar *a_css_path) ; + const guchar *a_css_path, + gboolean is_html) ; CRCascade * sx_box_view_get_cascade (SXBoxView *a_this) ; Index: tests/minifox.c =================================================================== RCS file: /cvs/gnome/sewfox/tests/minifox.c,v retrieving revision 1.3 diff -u -r1.3 minifox.c --- tests/minifox.c 28 Feb 2004 12:30:24 -0000 1.3 +++ tests/minifox.c 7 Mar 2004 15:01:28 -0000 @@ -23,6 +23,7 @@ */ #include <stdio.h> +#include <string.h> #include <libxml/parser.h> #include <libxml/tree.h> #include <sx-box-view.h> @@ -144,6 +145,8 @@ GtkWidget *window = NULL; GtkWidget *scroll = NULL; SXBoxView * viewport = NULL; + const gchar *ext; + gboolean is_html = FALSE; gtk_init (&argc, &argv); if (argc != 3) { @@ -162,7 +165,14 @@ scroll = gtk_scrolled_window_new (NULL, NULL) ; gtk_container_add (GTK_CONTAINER (window), scroll) ; g_print ("Rendering xml: %s - css: %s \n",argv[1],argv[2]); - viewport = sx_box_view_new_from_xml_css_paths(argv[1], argv[2]); + + ext = strrchr (argv[1], '.'); + if (ext) + { + is_html = ! strcmp (".html", ext); + } + viewport = sx_box_view_new_from_xml_css_paths(argv[1], argv[2], + is_html); if (!viewport) { cr_utils_trace_info ("Could not instanciate the viewport") ;
Attachment:
signature.asc
Description: This is a digitally signed message part