This is a pivotal version to JRuby users. No libxml/libxslt behind
Nokogiri. When you use Nokogiri on JRuby, you don’t need any C
libraries. Instead, Xerces/NekoHtml and a couple more pure Java APIs
are used. Installing nokogiri gem is all. Java APIs are included in
the gem package. Right after the gem installation, nokogiri will work
on various platforms.
Just for JRuby users’ methods are added:
- You can wrap org.w3c.dom.Document to build Nokogiri::XML::Document
- You can get org.w3c.dom.Document from Nokogiri::XML::Document
I tried Java Nokogiri recently and premailer didn’t work. Are there
limitations on what Java Nokogiri can support? Or will it be able to do
anything regular Nokogiri can do?
On Sun, Jul 3, 2011 at 12:40 AM, consiliens [email protected]
wrote:
On 07/02/2011 08:25 PM, Yoko H. wrote:
Give it a try. Give us your feedback.
I tried Java Nokogiri recently and premailer didn’t work. Are there
limitations on what Java Nokogiri can support? Or will it be able to do
anything regular Nokogiri can do?
Did you use pure Java Nokogiri under the environment that a custom
class loader was involved? If so, you need to move Java archives to
the directory that the custom class loader sees. For example,
WEB-INF/lib.
If you have an error message, that will help to figure out.
which versions of the library are these ? which versions of xerces is
nokogiri compatible with ? servlets containers usually comes with some
xml libraries and xercesImpl is quite common ! is it possible not to
require those jar if xerces is already in the parent classloader ?
Did you use pure Java Nokogiri under the environment that a custom
class loader was involved? If so, you need to move Java archives to
the directory that the custom class loader sees. For example,
WEB-INF/lib.
If you have an error message, that will help to figure out.
-Yoko
There’s no error message and no custom class loader. I don’t have
hpricot installed so premailer is forced to use nokogiri.
I’ve ported one of our bigger nokogiri scripts to jruby/nokogiri 1.5.0
and found the following bug:
raise out.inspect unless out == “a b:c”
This should return a b:c, but it actually returns: a
c. It works fine with JRuby w/ Nokogiri 1.4.7 and with Ruby w/
Nokogiri 1.5.0
which versions of the library are these ? which versions of xerces is
nokogiri compatible with ? servlets containers usually comes with some
xml libraries and xercesImpl is quite common ! is it possible not to
require those jar if xerces is already in the parent classloader ?
It is possible not to require xercesImpl.jar. Please see “Google App
Engine” section of the wiki above. This is a hack for an old version
of Nokogiri.
However, using xerces of parent classloader is not a good idea. Since
a single web application, for example a single war, should be
portable, everything to run the app should be in the war including
xercesImpl.jar. You’d better allow custom classloader to load
everything for the web app.
There’s one more reason. Pure Java Nokogiri uses NekoHTML to parse
html files. Prior to Xerces, NekoHTML must be loaded to make it work.
In light of this, you should not to use the parent classloader.
To make it easy to reproduce I’ve used base.html which is included as a
sample file in the premailer repository. I couldn’t get any files to
work properly with premailer using Java Nokogiri.
I opened two bugs in github that are showstoppers for me. 493 and
492. They are easy to reproduce. For some reason I am not able to add
the label pure-java to them as requested.
Regards,
Erik
I opened two bugs in github that are showstoppers for me. 493 and
492. They are easy to reproduce. For some reason I am not able to add
the label pure-java to them as requested.
Regards,
Erik
Thank you! I’ll have a look.
-Yoko
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.