Menu

#91 tag balancer not handling non-xhtml ns element properly

1.9.7
open
5
2009-12-08
2009-10-02
Andrew Fang
No

In html, we have element <legend> in a none xhtml namespace. However, the tag balancer adds <fieldset> around the <legend> anyway. For example:
<legend xmlns="http://mynamespace"/> ends up like <fieldset><legend xmlns="http://mynamespace"/></fieldset>. This extra tag causing problem in the downstream process.

A suggestion on the fix is to modify getElement method in HTMLTagBalancer to add namespace checking code (between "begin change" and "end change") in the follow snippet.

protected HTMLElements.Element getElement(final QName elementName) {
String name = elementName.rawname;
if (fNamespaces && NamespaceBinder.XHTML_1_0_URI.equals(elementName.uri)) {
int index = name.indexOf(':');
if (index != -1) {
name = name.substring(index+1);
}
}
// ***** begin change ******
if (fNamespaces && elementName.uri != null && !NamespaceBinder.XHTML_1_0_URI.equals(elementName.uri))
return HTMLElements.NO_SUCH_ELEMENT;
//***** end change *******
return HTMLElements.getElement(name);
} // getElement(String):HTMLElements.Element

Discussion

  • Marc Guillemot

    Marc Guillemot - 2009-12-08
    • assigned_to: nobody --> mguillem
    • status: open --> pending
     
  • Marc Guillemot

    Marc Guillemot - 2009-12-08

    Why shouldn't NekoHTML add a fieldset around the <legend...>? Firefox does it.

     
  • Andrew Fang

    Andrew Fang - 2009-12-08

    The <legend> is not in html or xhtml namespace, but in my own namespace.

     
  • Andrew Fang

    Andrew Fang - 2009-12-08
    • status: pending --> open
     
  • Marc Guillemot

    Marc Guillemot - 2009-12-08

    even if it is in your own namespace, FF wraps it in a legend.

     
  • Marc Guillemot

    Marc Guillemot - 2009-12-08
    • status: open --> pending
     
  • Andrew Fang

    Andrew Fang - 2009-12-08

    If FF does it, then it is a bug. I believe the purpose of adding <legend> is to make the content valid according to DTD. However, I have an xml fragment in its own namespace inside of an (x)html and I don't expect that to be changed.

    I believe that nekohtml does try to handle this (#2551958), but didn't consider all situations.

     
  • Andrew Fang

    Andrew Fang - 2009-12-08
    • status: pending --> open
     

Log in to post a comment.