1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/* Fo
* libfo-compat.c: LibFo compatibility processing
*
* Copyright (C) 2006 Sun Microsystems
* Copyright (C) 2007 Menteith Consulting
*
* See COPYING for the status of this software.
*/
#include "libfo/fo-xml-doc-private.h"
#include "libfo/libfo-compat.h"
#include "libfo/fo-xslt-transformer.h"
#include <libxml/xmlversion.h>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
const char *libfo_compat_error_messages [] = {
N_("libfo-compat error")
};
static const gchar* stylesheet =
REPLACE_ME;
/**
* libfo_compat_get_stylesheet:
*
* Get the built-in compatibility stylesheet as a single, rather long
* string.
*
* Return value: The built-in stylesheet.
**/
const gchar*
libfo_compat_get_stylesheet (void)
{
return stylesheet;
}
/**
* libfo_compat_make_compatible:
* @result_tree: Result of previous parse or transformation.
* @libfo_context: #FoLibfoContext.
* @error: Indication of any error that occurred.
*
* Make @result_tree compatible with libfo by applying the built-in
* copy of the 'libfo-compat.xsl' stylesheet.
*
* Return value: A new result tree.
**/
FoXmlDoc *
libfo_compat_make_compatible (FoXmlDoc *result_tree,
FoLibfoContext *libfo_context,
GError **error)
{
FoXmlDoc *compatible_result;
GError *tmp_error = NULL;
gchar* base = NULL;
g_return_val_if_fail (result_tree != NULL, NULL);
base = fo_xml_doc_get_base (result_tree);
FoXmlDoc *stylesheet_doc = fo_xml_doc_new_from_string (stylesheet,
base,
NULL,
libfo_context,
&tmp_error);
if (tmp_error != NULL)
{
g_propagate_error (error,
tmp_error);
return NULL;
}
compatible_result = fo_xslt_transformer_do_transform (result_tree,
stylesheet_doc,
&tmp_error);
fo_xml_doc_set_base (compatible_result,
base);
g_free (base);
if (tmp_error != NULL)
{
g_propagate_error (error,
tmp_error);
return NULL;
}
return compatible_result;
}
|