Menu

#54 selector (body>div>div) not working

closed
nobody
None
1
2015-01-10
2014-09-26
No

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);

Discussion

  • Radek Burget

    Radek Burget - 2014-10-03

    This was caused by another important bug in DirectAnalyzer. It should be fixed now.

     
    • Chetan Kothari

      Chetan Kothari - 2014-10-12

      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
  • Radek Burget

    Radek Burget - 2014-10-15
    • status: open --> accepted
     
  • Radek Burget

    Radek Burget - 2015-01-10
    • status: accepted --> closed
     
  • Radek Burget

    Radek Burget - 2015-01-10

    Closed in 1.19

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.