用Java解析CSS [英] parsing CSS with Java
问题描述
我需要用Java解析CSS文件,并尝试成功使用Batik和CSSParser库。我遇到的问题是,当我遇到IE黑客时,我放弃了格式化;在我看来,org.w3c.css.sac使用的DOM将无法容纳IE Hacks。
I need to parse CSS files in Java, and have tried using the Batik and CSSParser libs with success. The issue I am having is that when I run into IE hacks, I loose the formatting; it appears to me that the DOM used by org.w3c.css.sac won't accommodate the IE Hacks.
例如 -
/* The '\' isn't retained */
someselector {
padding: 10px;
width: 200px;
w\idth: 180px;
height: 200px;
heigh\t: 180px;
}
div.content {
width:400px;
voice-family: "\"}\"";
voice-family:inherit;
width:300px;
}
/* the space between 'body' and the '.' isn't retained */
html>body .content {
width:300px;
}
有没有人有这方面的经验并且可以推荐一个好的解决方案?
Has anyone had any experience with this and can recommend a good solution?
推荐答案
可能不是你理想的解决方案......但是使用IE条件评论并将所有条件评论放在一起会更安全,尽管不太方便单独的CSS文件中的IE代码,以避免使用黑客。
Probably not your ideal solution ... but it would be safer, albeit much less convenient, to use IE conditional comments and put all the IE code in a separate CSS file to avoid using hacks.
这篇关于用Java解析CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!