Bugzilla – Bug 663
HtmlParser.setFeature throws Exception when setting 'immutable' values
Last modified: 2011-05-19 15:53:25 CEST
In nu.validator.htmlparser version 1.2.0, setting "immutable" features to the supported value throws exceptions. I've tried using htmlparser with Saxon XSLT processor as follows: ... XMLReader htmlParser = new HtmlParser(ALTER_INFOSET); transformer.transform(new SAXSource(htmlParser, new InputSource(input)), new StreamResult(output)); but I've got: org.specs.runner.UserError: net.sf.saxon.trans.XPathException: The SAX2 parser nu.validator.htmlparser.sax.HtmlParser does not recognize the 'namespaces' feature at net.sf.saxon.event.Sender.configureParser(Sender.java:509) at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:304) at net.sf.saxon.event.Sender.send(Sender.java:193) at net.sf.saxon.event.Sender.send(Sender.java:50) at net.sf.saxon.Controller.transform(Controller.java:1611) because Saxon tries to configure the XML parser like this: // user-supplied parser: ensure that it meets the namespace requirements parser.setFeature("http://xml.org/sax/features/namespaces", true); parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false); I believe the current implementation is in violation of method's contract as specified in Javadoc for org.xml.sax.XMLReader.setFeature: ... All XMLReaders are required to support setting http://xml.org/sax/features/namespaces to true and http://xml.org/sax/features/namespace-prefixes to false.
Created attachment 119 [details] possible fix This patch solves the issue by checking if the value being set matches the immutable value. It also delegates the throwing of SAXNotRecognizedException to the getFeature.
This has already been fixed.