parsing CSS with Java

Question

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.

e.g.-

/*   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?

Solution

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.