1 30 31 package test; 32 33 import java.io.*; 34 import com.steadystate.css.*; 35 import org.w3c.dom.*; 36 import org.w3c.dom.css.*; 37 38 45 public class TestException { 46 47 public static void main(String [] args) throws ParseException { 48 CSS2Parser parser = new CSS2Parser(System.in); 49 50 try { 51 CSSStyleSheet stylesheet = parser.styleSheet(); 52 53 stylesheet.insertRule("P { color: blue }", 1); 54 stylesheet.insertRule("@import url(http://www.steadystate.com/primary.css);", 0); 55 stylesheet.insertRule("@charset \"US-ASCII\";", 0); 56 stylesheet.deleteRule(1); 57 58 CSSRuleList rules = stylesheet.getCssRules(); 59 CSSRule rule = rules.item(1); 60 rule.setCssText("H2 { smell: strong }"); 62 63 int n = stylesheet.insertRule("@media speech { H1 { voice: male } }", 1); 64 rule = rules.item(n); 65 ((CSSMediaRule)rule).insertRule("P { voice: female }", 1); 66 67 System.out.println(((CSSMediaRule)rule).getMedia().getMediaText()); 68 ((CSSMediaRule)rule).getMedia().setMediaText("speech, signlanguage"); 69 System.out.println(((CSSMediaRule)rule).getMedia().getMediaText()); 70 ((CSSMediaRule)rule).getMedia().deleteMedium("signlanguage"); 71 System.out.println(((CSSMediaRule)rule).getMedia().getMediaText()); 72 ((CSSMediaRule)rule).getMedia().appendMedium("semaphore"); 73 75 for (int i = 0; i < rules.getLength(); i++) { 77 rule = rules.item(i); 78 System.out.println(rule.getCssText()); 79 } 80 } catch(Exception e) { 81 System.out.println("Error."); 82 System.out.println(e.getMessage()); 83 e.printStackTrace(); 84 } 85 } 86 } 87
| Popular Tags
|