C 程序使用 XSLT 从字符串 XML 中过滤类型为 anyURI 的元素

C program to filter elements of type anyURI from string XML using XSLT

我有一个 XML 字符串,我想在此 XML 上应用 XSLT 字符串来过滤 anyURI 类型的元素。

我有兴趣使用 libxslt。但它会转换文件中存在的 xml。我想转换 xml string.

如何编写 C 程序来转换这个 xml 字符串?

就 XSLT 而言,libxslt 是 XSLT 1.0 处理器,因此它不支持 XSLT 中的 xs:anyURI 等 W3C 模式类型,您需要使用 XSLT 2 或 3 处理器。因此,我不确定您如何期望您的 XSLT 程序(无论是在文件中还是在字符串中)过滤掉 xs:anyURI.

类型的元素

就 C 而言,我想,根据您的 "string" 表示,您需要使用 http://www.xmlsoft.org/html/libxml-parser.html#xmlReadMemory or xmlReadDoc to get an http://www.xmlsoft.org/html/libxml-tree.html#xmlDocPtr for both the XML "string" input and the XSLT "string" input and then the libxslt APIs allow you to use http://xmlsoft.org/XSLT/html/libxslt-xsltInternals.html#xsltParseStylesheetDoc 来获得 xsltStylesheetPtr 然后到 运行 xsltApplyStylesheet.