MCPcopy Index your code
hub / github.com/MapServer/MapServer / msTransformXmlMapfile

Function msTransformXmlMapfile

mapxml.c:41–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39extern int xmlLoadExtDtdDefaultValue;
40
41int msTransformXmlMapfile(const char *stylesheet, const char *xmlMapfile, FILE *tmpfile)
42{
43 xsltStylesheetPtr cur = NULL;
44 int status = MS_FAILURE;
45 xmlDocPtr doc, res;
46
47 exsltRegisterAll();
48 xsltRegisterTestModule();
49
50 xmlSubstituteEntitiesDefault(1);
51 xmlLoadExtDtdDefaultValue = 1;
52
53 cur = xsltParseStylesheetFile((const xmlChar *)stylesheet);
54 if (cur == NULL)
55 {
56 msSetError(MS_MISCERR, "Failed to load xslt stylesheet", "msTransformXmlMapfile()");
57 goto done;
58 }
59
60 doc = xmlParseFile(xmlMapfile);
61 if (doc == NULL)
62 {
63 msSetError(MS_MISCERR, "Failed to load xml mapfile", "msTransformXmlMapfile()");
64 goto done;
65 }
66
67 res = xsltApplyStylesheet(cur, doc, NULL);
68 if (res == NULL)
69 {
70 msSetError(MS_MISCERR, "Failed to apply style sheet to %s", "msTransformXmlMapfile()", xmlMapfile);
71 goto done;
72 }
73
74 if ( xsltSaveResultToFile(tmpfile, res, cur) != -1 )
75 status = MS_SUCCESS;
76
77done:
78 if (cur)
79 xsltFreeStylesheet(cur);
80 if (res)
81 xmlFreeDoc(res);
82 if (doc)
83 xmlFreeDoc(doc);
84
85 xsltCleanupGlobals();
86 xmlCleanupParser();
87
88 return status;
89}
90
91#endif

Callers 1

mapfile.cFile · 0.85

Calls 1

msSetErrorFunction · 0.85

Tested by

no test coverage detected