I am looking for a java library which can inline an external CSS file with a HTML document based on its ID/class attributes.
I’ve found jStyleParser but I am not sure if this is the right library for me. I seem to fail to understand if it can do the job of inlining the CSS on the elements from the HTML. The documentation and examples is not what I expected.
Is there anyone who can answer that question or does there exist another library for this?
Thanks
You may try CSSBox. Just take a look at the ComputeStyles demo contained in the package (see the doc/examples/README file in the distribution package for information about running the demo). It computes all the styles and creates a new HTML document (represented by a DOM) with the corresponding inline style definitions.
The source is in src/org/fit/cssbox/demo/ComputeStyles.java and it’s pretty short. Actually, it uses jStyleParser for doing the main job, CSSBox just provides a nicer interface for this.