1 package org.joshy.html.css; 2 3 import org.joshy.*; 4 import java.io.*; 5 6 import com.steadystate.css.*; 7 import com.steadystate.css.parser.*; 8 import org.w3c.dom.*; 9 import org.w3c.dom.css.*; 10 import org.w3c.css.sac.*; 11 12 public class CSSTest { 13 14 public static void main(String [] args) throws Exception { 15 Reader r = new FileReader("test.css"); 16 CSSOMParser parser = new CSSOMParser(); 18 InputSource is = new InputSource(r); 19 CSSStyleSheet stylesheet = parser.parseStyleSheet(is); 20 22 String css_text = "p { color: #f0f0f0; }"; 23 stylesheet.insertRule(css_text,stylesheet.getCssRules().getLength()); 24 stylesheet.insertRule("@import \"second.css\";",0); 25 u.p("stylesheet = " + stylesheet); 26 u.p("title = " + stylesheet.getTitle()); 27 u.p("type = " + stylesheet.getType()); 28 CSSRule rule = stylesheet.getCssRules().item(0); 29 u.p("first rule = " + rule); 30 CSSImportRule impru = (CSSImportRule)rule; 31 u.p("sub sheet = " + impru.getStyleSheet()); 32 33 50 } 51 52 } 53 | Popular Tags |