how to use exsl:node-set from nodejs/node_xslt?

ぐ巨炮叔叔 提交于 2020-01-02 21:00:19

问题


I am trying to use EXSLT node-set function from nodejs via node_xslt module. This is a simple wrapper around the libxslt library that has support for EXSLT as I could get it. Yet any reference to exsl:node-set produces Thi is how I use it.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:exsl="http://exslt.org/common"
                    extension-element-prefixes="exsl">

<xsl:variable name="variable">
  <item />
  <item />
</xsl:variable>

    <xsl:variable name="result" select="exsl:node-set($variable)"/>

Any this is the error:

xmlXPathCompOpEval: function node-set not found XPath error : Unregistered function runtime error: file ./JayDataContextGenerator_OData_V2.xslt line 58 element for-each Failed to evaluate the 'select' expression.

UPDATE: Bahblah, author of the node_xslt plugin has updated the project in github, so the above mentioned transformation executes without any further ado.


回答1:


Finally figured it out inspecting xsltproc.c, I had to add the following additions to node_xslt.c

to the top:

#include <libexslt/exslt.h>
#include <libexslt/exsltconfig.h>

And to line 138, into FUNCTION( transform )

exsltRegisterAll();

Extend wscript so that:

obj.lib = ['xml2', 'xslt', 'exslt']

Then I had to rebuild node_xslt with

node-waf build

After this exsl:node-set() works like charm.



来源:https://stackoverflow.com/questions/11592856/how-to-use-exslnode-set-from-nodejs-node-xslt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!