/* xsltparser.c -- Generic XSLT parser for eurephiadm * * GPLv2 only - Copyright (C) 2009 * David Sommerseth * * 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 #ifdef HAVE_LIBXML2 #include #include #endif #ifdef HAVE_LIBXSLT #include #include #include #endif #include 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 }