Best way to perform XSL transformation in Ruby (XSLT 2.0)
What would be the best and most efficient way to to perform XSL transformation in Ruby? I have tried Nokogiri, but no matter what I tried it always results in:
compilation error: element stylesheet
The stylesheet works perfectly in my XML editor.
I'm using Ruby 1.9.3 on Linux.
After poking around, I found out that Nokogiri does not support XSLT 2.0:
Nokogiri uses libxml2, which only supports XPath 1.0/XSLT1.0
My stylesheet was written using XSLT 2.0 syntax. I updated the title of this question to reflect this. I wish Nokogiri responded to it in a more meaningful way.
Why do you want to perform an XSL transformation? Just curious.
I'm working on a website that submits XML feeds to other sites. Every feed has a different format, but the source of data for the feed is the same. So, instead of writing custom code for every feed I decided to use XSL stylesheets, served from a database. This wa开发者_开发技巧y I can create new feeds just by uploading a new stylesheet.
It is possible to use XSLT 2.0 in JRuby via the saxon-xslt gem. I don't think it's possible to do it via other Ruby implementations. Certainly MRI ruby would depend on libxml which hasn't implemented XPath 2.0 yet. See this thread for more information.
精彩评论