Erlang: Interaction with Xalan: port driver or nif?

I want to get a real XSLT processor working with erlang. What would be the best interface, nif or port driver? According to the nif documentation, no calls block the execution time, so they should not be time consuming. Is processing a long XML document too long?

In addition, I would like to allow erlang callbacks during conversion. Does this seem possible? Perhaps with nif, but not with port drivers, or vice versa?

I never wrote C, so I decided that it would be a good introduction. Xalan is C ++. I guess nif can work with this, right?

+4
source share
1 answer

I would recommend creating a port driver.

The NIF object is a way to add new built-in functions to the language and speed up work that will be too slow to implement in pure Erlang. In any case, NIFs are considered experimental, so the interface may change dramatically in future releases.

Writing a port driver means an implementation of C (or C ++) that behaves like an entire erlang process. This provides more flexibility since you can communicate with other processes when converting a document (callbacks ...), etc.

It doesn't even have to be a driver. If you don’t go through a lot of data between your port program and other Erlang code, you might consider writing a simple port (easier).

+5
source

Source: https://habr.com/ru/post/1310931/


All Articles