// unknown node 't' has no parent set
  public void testParseUnknownElementInTable() throws ParseException {
    String code =
        "<!doctype html>"
            + "<html>"
            + "<head><title></title></head>"
            + "<body>"
            + "<table>"
            + "<t>"
            + "</table>"
            + "</body>"
            + "</html>";
    //      NodeTreeBuilder.DEBUG = true;
    HtmlParseResult result = parse(code);
    Node root = result.root();

    //      NodeUtils.dumpTree(root);

    // the 't' node is foster parented, so it goes to the table's parent, not table itself
    Node t = ElementUtils.query(root, "html/body/t");
    assertNotNull(t);
    Node body = ElementUtils.query(root, "html/body");
    assertNotNull(body);

    assertEquals(body, t.parent());
  }
  // Bug 196479 - Problem with finding end tag for style element
  public void testStyleTag() throws ParseException {
    //        NodeTreeBuilder.setLoggerLevel(Level.FINER);

    String code =
        "<!doctype html>"
            + "<html>"
            + "<head>"
            + "<title></title>"
            + "<style> div { } </style>"
            // 2345678901234        890123456
            + "</head>"
            + "<body>"
            + "</body>"
            + "</html>";

    HtmlParseResult result = parse(code);
    Node root = result.root();

    assertNotNull(root);
    //        ElementUtils.dumpTree(root);

    Node style = ElementUtils.query(root, "html/head/style");
    assertNotNull(style);

    assertEquals(42, style.from());
    assertEquals(49, style.to());

    // space after the style tag name
    code =
        "<!doctype html>"
            + "<html>"
            + "<head>"
            + "<title></title>"
            + "<style  > div { } </style>"
            // 2345678901234        890123456
            + "</head>"
            + "<body>"
            + "</body>"
            + "</html>";

    result = parse(code);
    root = result.root();

    assertNotNull(root);
    //        ElementUtils.dumpTree(root);

    style = ElementUtils.query(root, "html/head/style");
    assertNotNull(style);

    assertEquals(42, style.from());
    assertEquals(51, style.to());
  }
  public void testBodyTagHasNoParent() throws ParseException {
    String code =
        "<!doctype html> " + "<html> " + "<body >" + "      " + "<       " + "</body>" + "</html>";

    HtmlParseResult result = parse(code);
    Node root = result.root();

    assertNotNull(root);

    Node body = ElementUtils.query(result.root(), "html/body");
    assertNotNull(body);

    assertNotNull(body.parent());

    //        NodeUtils.dumpTree(root);
  }
  public void testParseUnfinishedCode() throws ParseException {
    String code =
        "<!DOCTYPE HTML>"
            + "<html>"
            + "<head>"
            + "<title>"
            + "</title>"
            + "</head>"
            + "<body>"
            + "</table>"
            + "</html>";

    HtmlParseResult result = parse(code);
    Node root = result.root();

    assertNotNull(root);

    //        NodeUtils.dumpTree(root);

    Node html = ElementUtils.query(root, "html");
    assertNotNull(html);

    Collection<Element> children = html.children();
    assertEquals(4, children.size()); // <head>, </head>,<body>,</table>
    Iterator<Element> childernItr = children.iterator();

    assertTrue(childernItr.hasNext());
    Element child = childernItr.next();
    assertEquals(ElementType.OPEN_TAG, child.type());
    assertEquals("head", ((OpenTag) child).name().toString());
    assertTrue(childernItr.hasNext());
    child = childernItr.next();
    assertEquals(ElementType.CLOSE_TAG, child.type());
    assertEquals("head", ((CloseTag) child).name().toString());
    assertTrue(childernItr.hasNext());
    child = childernItr.next();
    assertEquals(ElementType.OPEN_TAG, child.type());
    assertEquals("body", ((OpenTag) child).name().toString());
    assertTrue(childernItr.hasNext());
    child = childernItr.next();
    assertEquals(ElementType.CLOSE_TAG, child.type());
    assertEquals("table", ((CloseTag) child).name().toString());

    //        NodeUtils.dumpTree(root);

  }