summaryrefslogtreecommitdiffstats
path: root/eurephiadm
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-03-29 20:19:16 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-03-29 20:19:16 +0200
commit2b2d4c802ff93aedc63c86cd882b7ccef57cc6cd (patch)
tree7b3c137ec0d61df8d642c95d75fe781e7f405d76 /eurephiadm
parent105fe0cae7f8fb542a69912eb330a37645afd4fa (diff)
downloadeurephia-2b2d4c802ff93aedc63c86cd882b7ccef57cc6cd.tar.gz
eurephia-2b2d4c802ff93aedc63c86cd882b7ccef57cc6cd.tar.xz
eurephia-2b2d4c802ff93aedc63c86cd882b7ccef57cc6cd.zip
Implemented an XSLT parser for eurephiadm
Diffstat (limited to 'eurephiadm')
-rw-r--r--eurephiadm/xsltparser.c70
-rw-r--r--eurephiadm/xsltparser.h29
2 files changed, 99 insertions, 0 deletions
diff --git a/eurephiadm/xsltparser.c b/eurephiadm/xsltparser.c
new file mode 100644
index 0000000..663417d
--- /dev/null
+++ b/eurephiadm/xsltparser.c
@@ -0,0 +1,70 @@
+/* xsltparser.c -- Generic XSLT parser for eurephiadm
+ *
+ * GPLv2 only - Copyright (C) 2009
+ * David Sommerseth <dazo@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+
+#ifdef HAVE_LIBXML2
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+#endif
+
+#ifdef HAVE_LIBXSLT
+#include <libxslt/xsltInternals.h>
+#include <libxslt/transform.h>
+#include <libxslt/xsltutils.h>
+#endif
+
+#include <eurephia_values.h>
+
+int xslt_print_xmldoc(FILE *dst, eurephiaVALUES *cfg, xmlDoc *xmldoc,
+ const char *xsltfname, const char **xsltparams)
+{
+#ifdef HAVE_LIBXSLT
+ xmlDoc *result = NULL;
+ xsltStylesheet *xslt = NULL;
+ xmlChar xsltfile[2048];
+
+ // Build up complete path to the XSLT template we will use
+ xmlStrPrintf(xsltfile,2046, (xmlChar *)"%s/%s%c", eGet_value(cfg, "eurephiadm_xslt_path"), xsltfname, 0);
+
+ // Load the XSLT template
+ xslt = xsltParseStylesheetFile(xsltfile);
+ if( xslt == NULL ) {
+ return 0;
+ }
+
+ // Parse the XML document, using the XSLT template
+ result = xsltApplyStylesheet(xslt, xmldoc, xsltparams);
+ if( result == NULL ) {
+ return 0;
+ }
+
+ // Send the result to file
+ xsltSaveResultToFile(dst, result, xslt);
+
+ // Clean up
+ xmlFreeDoc(result);
+ xsltFreeStylesheet(xslt);
+ return 1;
+#else
+ return 0;
+#endif
+}
diff --git a/eurephiadm/xsltparser.h b/eurephiadm/xsltparser.h
new file mode 100644
index 0000000..dffa8d1
--- /dev/null
+++ b/eurephiadm/xsltparser.h
@@ -0,0 +1,29 @@
+/* xsltparser.c -- Generic XSLT parser for eurephiadm
+ *
+ * GPLv2 only - Copyright (C) 2009
+ * David Sommerseth <dazo@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#ifndef XSLTPARSER_H_
+# define XSLTPARSER_H_
+
+int xslt_print_xmldoc(FILE *dst, eurephiaVALUES *cfg, xmlDoc *xmldoc,
+ const char *xsltfname, const char **xsltparams);
+
+#endif /* !XSLTPARSER_H_ */