You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that if you try to load a Document via DefaultDOMSource, #getElementById() always returns null.
As far as I can tell, this is because cssbox is using NekoHTML as its XML parser, and it's not set up to be a validating parser, and Xerces is the underlying parser, that requires it to be a validating parser in order for id="..." to work . I think?
However I did find a fix on sourceforge by adding a custom filter to NekoHTML:
I think this could be added to DefaultDOMSource, or HTMLConfiguration, but I'd imagine you'd want to add test cases as well, and I'm not sure what the implications of this might be.
The text was updated successfully, but these errors were encountered:
Update: If you're trying to find IDs for elements that are naturally empty (such as <input>), turns out there's a separate filter for empty elements and normal elements. The XMLDocumentFilter should instead be:
XMLDocumentFilteridEnhancer = newDefaultFilter() {
/** * Makes #getElementById() work on any set of attributes */privatevoidpossiblyAddIdAttribute(XMLAttributesattributes) {
intidx = attributes.getIndex("id");
if (idx > -1) {
attributes.setType(idx, "ID");
AugmentationsattrsAugs = attributes.getAugmentations(idx);
attrsAugs.putItem(Constants.ATTRIBUTE_DECLARED, Boolean.TRUE);
}
}
@OverridepublicvoidstartElement(QNameelement, XMLAttributesattributes, Augmentationsaugs) throwsXNIException {
possiblyAddIdAttribute(attributes);
super.startElement(element, attributes, augs);
}
@OverridepublicvoidemptyElement(QNameelement, XMLAttributesattributes, Augmentationsaugs) throwsXNIException {
possiblyAddIdAttribute(attributes);
super.emptyElement(element, attributes, augs);
}
};
I found that if you try to load a Document via DefaultDOMSource,
#getElementById()
always returnsnull
.As far as I can tell, this is because cssbox is using NekoHTML as its XML parser, and it's not set up to be a validating parser, and Xerces is the underlying parser, that requires it to be a validating parser in order for id="..." to work . I think?
However I did find a fix on sourceforge by adding a custom filter to NekoHTML:
I think this could be added to
DefaultDOMSource
, orHTMLConfiguration
, but I'd imagine you'd want to add test cases as well, and I'm not sure what the implications of this might be.The text was updated successfully, but these errors were encountered: