tags:

views:

103

answers:

1

I'd like to get a real XSLT processor working with erlang. Which would be the best interface, nif or port driver? According to the nif documentation, nif calls block the runtime, so they should not take long. Is processing a long xml document too long?

Also, I'd like to allow erlang callbacks during the transformation. Does that seem possible? Possible with nif but not port drivers or vice versa?

I've never written any C, so I figured this would be good introduction. Xalan is C++. I assume nif can work with that, right?

+2  A: 

I would recommend building a port driver.

The NIF facility is a way to add new built-in functions to the language and speed up things that would be too slow to implement in pure Erlang. NIFs are considered experimental anyway, so the interface might change radically in future releases.

Writing a port driver means implementing a C (or C++) shared library that behaves like a whole erlang process. This allows for greater flexibility as you can communicate with other processes while transforming a document (callbacks...), etc.

It doesn't even have to be a driver. If you don't pass lots of data between your port program and other Erlang code you might consider writing a plain port instead (it's easier).

Felix Lange
I think the plain port is probably the best idea, certainly considering my inexperience with C. Getting anything working at all is my first concern.
mwt
i suggest starting with the erl_interface user's guide
Felix Lange