cz.vutbr.web.domassign.Analyzer Java Examples
The following examples show how to use
cz.vutbr.web.domassign.Analyzer.
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: GrammarRecovery1Test.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void invalidSelector() throws IOException, CSSException, SAXException { StyleSheet sheet = CSSFactory.parseString(TEST_INVALID_SELECTOR, null); DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/h1.html")); Document doc = ds.parse(); Analyzer analyzer = new Analyzer(sheet); StyleMap decl = analyzer.evaluateDOM(doc, "all", true); ElementMap elements = new ElementMap(doc); NodeData nd = decl.get(elements.getLastElementByName("h1")); Assert.assertNull("There is no color", nd.getProperty("color")); Assert.assertEquals("There is font-family", FontFamily.list_values, nd .getProperty("font-family")); Assert.assertEquals("Font is 'Times New Roman'", tf .createString("Times New Roman"), nd.getValue(TermList.class, "font-family").get(0)); }
Example #2
Source File: ImportTest1.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
private void checkDataCSS(StyleSheet ss) { Analyzer analyzer = new Analyzer(ss); StyleMap decl = analyzer.evaluateDOM(doc, "all", true); ElementMap elements = new ElementMap(doc); Element marginator = elements.getElementById("marginator"); assertNotNull("Element marginator exists", marginator); NodeData data = decl.get(marginator); assertEquals( "<div id=\"marginator\"> contains margin with for same values", Margin.length, data.getProperty("margin-top")); assertEquals( "<div id=\"marginator\"> contains margin with for same values", Margin.length, data.getProperty("margin-bottom")); assertEquals("Margin of 100px", new Float(100.0f), data.getValue( TermLength.class, "margin-top").getValue()); assertEquals("Margin of 100px", TermNumeric.Unit.px, data.getValue( TermLength.class, "margin-top").getUnit()); assertEquals("for all for both values", data.getValue(TermLength.class, "margin-bottom"), data .getValue(TermLength.class, "margin-left")); }
Example #3
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 #4
Source File: CSSFactory.java From jStyleParser with GNU Lesser General Public License v3.0 | 4 votes |
/** * This is the same as {@link CSSFactory#assignDOM(Document, String, URL, MediaSpec, boolean)} * with the possibility of specifying a custom network processor for obtaining data from URL * resources. * * @param doc * DOM tree * @param encoding * The default encoding used for the referenced style sheets * @param network * Custom network processor * @param base * Base URL against which all files are searched * @param media * Current media specification used for evaluating the media queries * @param useInheritance * Whether inheritance will be used to determine values * @param matchCond * The match condition to match the against. * @return Map between DOM element nodes and data structure containing CSS * information */ public static final StyleMap assignDOM(Document doc, String encoding, NetworkProcessor network, URL base, MediaSpec media, boolean useInheritance, final MatchCondition matchCond) { SourceData pair = new SourceData(base, network, media); Traversal<StyleSheet> traversal = new CSSAssignTraversal(doc, encoding, pair, NodeFilter.SHOW_ELEMENT); StyleSheet style = (StyleSheet) getRuleFactory().createStyleSheet() .unlock(); traversal.listTraversal(style); Analyzer analyzer = new Analyzer(style); if (matchCond != null) { analyzer.registerMatchCondition(matchCond); } return analyzer.evaluateDOM(doc, media, useInheritance); }
Example #5
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 #6
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 #7
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); }