selector (body>div>div) not working
Pure Java HTML / CSS rendering engine
Status: Beta
Brought to you by:
radkovo
for the given test case, we don't get any style for the inner most div
String css = "body > div > div {" + "color: green;" + "}"; String html = "<html>" + "<head>" + "<style>" + css + "</style>" + "</head>" + "<body>" + "<div>" + "<div id='d1'>Green text</div>" + "</div>" + "</body>" + "</html>"; InputStream is = new ByteArrayInputStream(html.getBytes()); DocumentSource docSrc = new StreamDocumentSource(is, new URL("http://localhost"), "text/html"); DOMSource domSrc = new DefaultDOMSource(docSrc); Document doc = domSrc.parse(); NodeList childrens = doc.getChildNodes(); // gives the innermost div Element div = (Element) childrens.item(0).getChildNodes().item(1).getChildNodes().item(0).getChildNodes().item(0); // this is to verify that we got the correct div System.out.println("Element " + div.getNodeName() + " #" + div.getAttribute("id")); StyleSheet styleSheet = CSSFactory.parse(css); DirectAnalyzer directAnalyser = new cz.vutbr.web.domassign.DirectAnalyzer(styleSheet); NodeData firstNodeData = directAnalyser.getElementStyle(div, null, "screen"); System.out.println("Style Sheet " + styleSheet); System.out.println("\n--------"); System.out.println("NodeData: " + firstNodeData);
Anonymous
This was caused by another important bug in DirectAnalyzer. It should be fixed now.
Hi,
As I was busy the last week, couldn't verify the fix.
Thanks for the fix, it works great.
Last edit: Chetan Kothari 2014-10-12
Closed in 1.19