升级到MacOS Catalina并链接到10.15 SDK中包含的libxslt和libxml2后,一个奇怪的问题是
disable-output-escaping="yes"
无论如何都会损坏并退出输出。来自各种XSLT表的几个示例:
<xsl:text disable-output-escaping="yes"><--test comment--></xsl:text>
<xsl:value-of select="/*[1]/LBL_CM_3" disable-output-escaping="yes" />
在哪里
LBL_CM_3
节点中有一些HTML,例如。
cm<sup>3</sup>
.当我的代码使用非常直接的API使用处理时,这两种情况都被转义(意外结果)。这是一个精简版本,省略了错误检查和清理:
xmlDocPtr tmpXmlDoc = xmlParseMemory(inputString.c_str(), (int)inputString.size());
xmlDocPtr tmpXslDoc = xmlParseMemory(xslInputStr, xslInputStrSize);
xsltStylesheetPtr tmpXslStyleSheet = xsltParseStylesheetDoc(tmpXslDoc);
xmlDocPtr tmpHtmlDoc = xsltApplyStylesheet(tmpXslStyleSheet, tmpXmlDoc, params);
但是,如果我使用
/usr/bin/xsltproc
,输出未转义(预期结果)。我们都在系统上链接同一个库:
$ otool -L /usr/bin/xsltproc | grep -E 'xml|xslt'
/usr/bin/xsltproc:
/usr/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.15.0)
/usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
$ otool -L TestXslt.app/Contents/MacOS/TestXslt | grep -E 'xml|xslt'
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
/usr/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.15.0)
/usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
系统
xsltproc
版本信息:
$ /usr/bin/xsltproc --version
Using libxml 20904, libxslt 10129 and libexslt 817
xsltproc was compiled against libxml 20904, libxslt 10129 and libexslt 817
libxslt 10129 was compiled against libxml 20904
libexslt 817 was compiled against libxml 20904
10.15 SDK
usr/include/libxml/xmlversion.h
显示了相同的版本:
/**
* LIBXML_DOTTED_VERSION:
*
* the version string like "1.2.3"
*/
#define LIBXML_DOTTED_VERSION "2.9.4"
/**
* LIBXML_VERSION:
*
* the version number: 1.2.3 value is 10203
*/
#define LIBXML_VERSION 20904
这与之前MacOS Sierra SDK的预期一样,使用相同的调用代码和相同的XSLT表。XSLT处理的其余部分似乎都按预期工作,只有
禁用输出转义=“yes”
被忽略了。