diff options
author | Kinsey Moore <kmoore@digium.com> | 2013-08-01 17:07:52 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2013-08-01 17:07:52 +0000 |
commit | 03090a88bab15b94843e3850df68b37ff8948b54 (patch) | |
tree | b32e51b384941143881c82dbb1a2d90e8de3536f /main/xml.c | |
parent | 5601b0f50cf30fd05c97a44ff7e18c20f58fc947 (diff) |
Fix documentation replication issues
This prevents XML documentation duplication by expanding channel and
bridge snapshot tags into channel and bridge snapshot parameter sets
with a given prefix or defaulting to no prefix. This also prevents
documentation from becoming fractured and out of date by keeping all
variations of the documentation in template form such that it only
needs to be updated once and keeps maintenance to a minimum.
Review: https://reviewboard.asterisk.org/r/2708/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395985 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/xml.c')
-rw-r--r-- | main/xml.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/main/xml.c b/main/xml.c index 5ca4d4ff1..bd5850813 100644 --- a/main/xml.c +++ b/main/xml.c @@ -29,6 +29,7 @@ #include "asterisk/xml.h" #include "asterisk/logger.h" #include "asterisk/utils.h" +#include "asterisk/autoconfig.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -38,6 +39,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include <libxml/xinclude.h> #include <libxml/xpath.h> /* libxml2 ast_xml implementation. */ +#ifdef HAVE_LIBXSLT + #include <libxslt/xsltInternals.h> + #include <libxslt/transform.h> +#endif /* HAVE_LIBXSLT */ int ast_xml_init(void) @@ -63,13 +68,32 @@ struct ast_xml_doc *ast_xml_open(char *filename) } doc = xmlReadFile(filename, NULL, XML_PARSE_RECOVER); - if (doc) { - /* process xinclude elements. */ - if (xmlXIncludeProcess(doc) < 0) { + if (!doc) { + return NULL; + } + + /* process xinclude elements. */ + if (xmlXIncludeProcess(doc) < 0) { + xmlFreeDoc(doc); + return NULL; + } + +#ifdef HAVE_LIBXSLT + { + xsltStylesheetPtr xslt = xsltLoadStylesheetPI(doc); + if (xslt) { + xmlDocPtr tmpdoc = xsltApplyStylesheet(xslt, doc, NULL); + xsltFreeStylesheet(xslt); xmlFreeDoc(doc); - return NULL; + if (!tmpdoc) { + return NULL; + } + doc = tmpdoc; } } +#else /* no HAVE_LIBXSLT */ + ast_log(LOG_NOTICE, "XSLT support not found. XML documentation may be incomplete.\n"); +#endif /* HAVE_LIBXSLT */ return (struct ast_xml_doc *) doc; } |