Re: Error messages from TagLibFactory xml validation...
Attila Szegedi <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
On 2008.03.20., at 17:55, Newman, John W wrote: > As soon as you say setValidation(false) the error messages stop, so > I'm not sure about the need for setErrorHandler() once it's turned > off. I think it's still good to have, at least to rethrow the SAXParseException passed to ErrorHandler.fatalError() -- I'm not sure if a compliant SAX parser would throw such an exception directly when there's no ErrorHandler set, but just to be on the safe side... > I also don't know how bad turning off validation really is, I > personally don't care but others might think it's important. It could only hurt if people actually developed their TLDs using FreeMarker exclusively as the test harness - I don't think that's likely. > Ideally I think it should be able to validate both the old doctype > way and the new xsd way. But again this is really trivial, if > something is invalid you shouldn't be relying on this class to find > out! Exactly my thinking. Attila. > > > Thanks > > > -----Original Message----- > From: [email protected] [mailto:[email protected] > ] On Behalf Of Attila Szegedi > Sent: Thursday, March 20, 2008 12:16 PM > To: FreeMarker-user > Subject: Re: [FreeMarker-user] Error messages from TagLibFactory xml > validation... > > I just remembered we have this reported in our tracker too as > > <http://sourceforge.net/tracker/index.php?func=detail&aid=1725107&group_id=794&atid=100794 >> > > Anyway, I committed changes that should fix this - can you try running > with the build linked below? > > <http://freemarker.org:8085/download/FM-BRANCH23/artifacts/build-57/Library/freemarker.jar >> > > Attila. > > On 2008.03.20., at 16:51, Attila Szegedi wrote: >> Now, this is curious -- I was under impression that not setting an >> error handler will simply cause a SAXParserException on the first >> validation problem. But if not, then yeah, we can remedy it by adding >> an error handler that'll do precisely that. >> >> Attila. >> >> On 2008.03.20., at 15:48, Newman, John W wrote: >>> Hi guys, >>> >>> For about 6 months I have been on a quest to find the source of this >>> >>> 13:38:17,393 ERROR [STDERR] Warning: validation was turned on but an >>> org.xml.sax.ErrorHandler was not >>> 13:38:17,393 ERROR [STDERR] set, which is probably not what is >>> desired.Parser will use a default >>> 13:38:17,393 ERROR [STDERR] ErrorHandler to print the first 10 >>> errors. Please call >>> 13:38:17,393 ERROR [STDERR] the 'setErrorHandler' method to fix >>> this. >>> 13:38:17,393 ERROR [STDERR] Error:URI=jndi:/localhost/dosimetry/WEB- >>> INF/web.xml Line=6: Document root >>> element "web-app", must match DOCTYPE root "null". >>> 13:38:17,393 ERROR [STDERR] Error:URI=jndi:/localhost/dosimetry/WEB- >>> INF/web.xml Line=6: Document is >>> invalid: no grammar found. >>> 13:38:17,409 ERROR [STDERR] Warning: validation was turned on but an >>> org.xml.sax.ErrorHandler was not >>> 13:38:17,409 ERROR [STDERR] set, which is probably not what is >>> desired.Parser will use a default >>> 13:38:17,409 ERROR [STDERR] ErrorHandler to print the first 10 >>> errors.Please call >>> 13:38:17,409 ERROR [STDERR] the 'setErrorHandler' method to fix >>> this. >>> >>> There's also more complaining about some tld... >>> >>> ? I thought it was my code, something off with web.xml or the >>> stripes framework, or even something with jboss or tomcat. Turns >>> out it is actually from >>> >>> public class TaglibFactory implements TemplateHashModel { >>> >>> private static void parseXml(InputStream in, String url, >>> DefaultHandler handler) throws >>> ParserConfigurationException, >>> IOException, SAXException { >>> InputSource is = new InputSource(); >>> is.setByteStream(in); >>> is.setSystemId(url); >>> SAXParserFactory factory = SAXParserFactory.newInstance(); >>> factory.setNamespaceAware(false); >>> factory.setValidating(true); >>> XMLReader reader = factory.newSAXParser().getXMLReader(); >>> reader.setEntityResolver(new LocalTaglibDtds()); >>> reader.setContentHandler(handler); >>> reader.parse(is); >>> } >>> } >>> >>> setValidating(false) suppresses the messages, but I don't know if >>> that's what we want. Does anybody know what the correct settings >>> are here? I think the answer is in >>> http://xerces.apache.org/xerces2-j/features.html .. I have 0 >>> knowledge about xml (in a way I think that's good) so I don't know >>> where to start. Any ideas what this really should look like? >>> >>> >>> The top of my web .xml is >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee >>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >>> version="2.4"> >>> >>> no doctype, and if I put one in there nothing works. The top of the >>> tld it complains about is >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee >>> http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" >>> version="2.0"> >>> >>> Thanks! ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/