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
Why shouldn't NekoHTML add a fieldset around the <legend...>? Firefox does it.
The <legend> is not in html or xhtml namespace, but in my own namespace.
even if it is in your own namespace, FF wraps it in a legend.
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.