0
我正在将libxml2与libxslt用于C++程序的XML处理。对于转换XML文档与XSL,我使用下面的函数(删除错误处理):C++,libxslt:释放样式表文档后释放样式表导致崩溃
xmlDocPtr
transformXmlDocument(
const xmlDocPtr inputDocument,
const std::string& stylesheetString
) {
exsltRegisterAll();
// Read the stylesheet document.
xmlDocPtr stylesheetDocument = xmlReadMemory(
stylesheetString.c_str(),
stylesheetString.length(),
"stylesheet.xsd",
0, // No encoding set - get it from the file header.
0 // No further options.
);
// Parse the stylesheet
xsltStylesheetPtr stylesheet = xsltParseStylesheetDoc(stylesheetDocument);
// Transform the document
xmlDocPtr result = xsltApplyStylesheet(stylesheet, inputDocument, 0);
// Free used resources
xsltFreeStylesheet(stylesheet);
xsltCleanupGlobals();
// Here the program crashes
xmlFreeDoc(stylesheetDocument);
return result;
}
的问题是,该方案与访问冲突崩溃(glibc的说道:免费():无效的指针:0x00000000026d8090 *)在第二行。
我无法在文档中找到xsltFreeStylesheet也释放底层文档或任何提示,所以这里有什么问题?
没有阅读过,只能阅读:http://xmlsoft.org/XSLT/html/libxslt-xsltInternals.html#xsltFreeStylesheet ...谢谢。 – Jost