Java Code Examples for cz.vutbr.web.css.CSSFactory#parse()
The following examples show how to use
cz.vutbr.web.css.CSSFactory#parse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnalyzerTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@BeforeClass public static void init() throws IOException, CSSException, SAXException { log.info("\n\n\n == AnalyzerTest test at {} == \n\n\n", new Date()); DOMSource ds = new DOMSource(AnalyzerTest.class.getResourceAsStream("/simple/data.html")); doc = ds.parse(); sheet = CSSFactory.parse(AnalyzerTest.class.getResource("/simple/data.css"), null); analyzer = new Analyzer(sheet); NodeList list = doc.getElementsByTagName("body"); assertEquals("There is one <body> element", 1, list.getLength()); //walker = new TidyTreeWalker(list.item(0), NodeFilter.SHOW_ELEMENT); DocumentTraversal traversal = (DocumentTraversal) doc; walker = traversal.createTreeWalker(list.item(0), NodeFilter.SHOW_ELEMENT, null, false); elements = new ElementMap(doc); }
Example 2
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testMediaImport() throws CSSException, IOException { CSSFactory.setAutoImportMedia(new MediaSpecAll()); //reset to default StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null); assertEquals("All rules have been imported", 8, ss.size()); }
Example 3
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testMediaImportLimit1() throws CSSException, IOException { CSSFactory.setAutoImportMedia(new MediaSpec("projection")); StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null); assertEquals("All rules have been imported", 8, ss.size()); }
Example 4
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testMediaImportLimit2() throws CSSException, IOException { CSSFactory.setAutoImportMedia(new MediaSpec("screen")); StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null); assertEquals("No rules have been imported", 0, ss.size()); }
Example 5
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testMediaImportLimit3() throws CSSException, IOException { CSSFactory.setAutoImportMedia(new MediaSpecNone()); StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/impmedia.css"), null); assertEquals("No rules have been imported", 0, ss.size()); }
Example 6
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testRealAndNested() throws CSSException, IOException { CSSFactory.parse(getClass().getResource("/abclinuxu/styles.css"), null); }
Example 7
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testExternAndNested() throws CSSException, IOException { CSSFactory.parse(new URL("http://www.abclinuxu.cz/styles.css"), null); }
Example 8
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testImportEscaped() throws CSSException,IOException{ StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/imp_escaped.css"), null); this.checkDataCSS(ss); }
Example 9
Source File: CharsetTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
@Test public void testString1() throws IOException, CSSException { URL url = getClass().getResource("/simple/charset1.css"); StyleSheet ss = CSSFactory.parse(url, "utf-8"); assertEquals("One rule is set", 1, ss.size()); RuleSet rule = (RuleSet) ss.get(0); assertArrayEquals("Rule contains one selector BODY ", SelectorsUtil.createSelectors("tést"), rule.getSelectors()); assertEquals("Rule contains one declaration", rule.size(), 1); }
Example 10
Source File: AdvancedCSSTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 3 votes |
@BeforeClass public static void init() throws IOException, CSSException, SAXException { log.info("\n\n\n == AdvancedTest test at {} == \n\n\n", new Date()); DOMSource ds = new DOMSource(AdvancedCSSTest.class.getResourceAsStream("/advanced/style.html")); doc = ds.parse(); sheet = CSSFactory.parse(AdvancedCSSTest.class.getResource("/advanced/style.css"), null); analyzer = new Analyzer(sheet); decl = analyzer.evaluateDOM(doc, "all", true); elements = new ElementMap(doc); }
Example 11
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 3 votes |
@Test public void testSimpleImport() throws CSSException, IOException { StyleSheet ss = CSSFactory.parse(getClass().getResource("/simple/imp.css"), null); this.checkDataCSS(ss); }
Example 12
Source File: UAConformancyTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 3 votes |
@BeforeClass public static void init() throws CSSException, IOException, SAXException { log.info("\n\n\n == UAConformancy test at {} == \n\n\n", new Date()); DOMSource ds = new DOMSource(UAConformancyTest.class.getResourceAsStream("/invalid/style.html")); Document doc = ds.parse(); em = new ElementMap(doc); StyleSheet sheet = CSSFactory.parse(UAConformancyTest.class.getResource("/invalid/style.css"), null); Analyzer analyzer = new Analyzer(sheet); decl = analyzer.evaluateDOM(doc, "screen", true); }
Example 13
Source File: NodeDataVariantTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 3 votes |
@BeforeClass public static void init() throws CSSException, IOException, SAXException { log.info("\n\n\n == NodeDataVariant test at {} == \n\n\n", new Date()); DOMSource ds = new DOMSource(new FileInputStream("data/simple/data.html")); doc = ds.parse(); StyleSheet style = CSSFactory.parse("data/simple/data.css", null); analyzer = new Analyzer(style); }
Example 14
Source File: ProfilerEntryPoint.java From jStyleParser with GNU Lesser General Public License v3.0 | 3 votes |
public static void main(String[] args) throws Exception { Date start = new Date(); StyleSheet sheet = CSSFactory.parse("src/test/resources/profiling/slate.css", "UTF-8"); System.out.println("Total rules: " + sheet.size()); Date end = new Date(); System.out.println("Parsing time: " + (end.getTime() - start.getTime()) + " ms"); }