Revision: 6722 Author: [email protected] Date: Thu Nov 5 19:55:23 2009 Log: Send UiBinder's xml logging to the right place
Reviewed by jat http://code.google.com/p/google-web-toolkit/source/detail?r=6722 Modified: /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderGenerator.java /trunk/user/src/com/google/gwt/uibinder/rebind/W3cDomHelper.java /trunk/user/test/com/google/gwt/uibinder/parsers/DockLayoutPanelParserTest.java /trunk/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java ======================================= --- /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderGenerator.java Thu Nov 5 12:38:39 2009 +++ /trunk/user/src/com/google/gwt/uibinder/rebind/UiBinderGenerator.java Thu Nov 5 19:55:23 2009 @@ -144,7 +144,7 @@ Document doc = null; try { - doc = new W3cDomHelper().documentFor(url); + doc = new W3cDomHelper(logger.getTreeLogger()).documentFor(url); } catch (SAXParseException e) { logger.die("Error parsing XML (line " + e.getLineNumber() + "): " + e.getMessage(), e); ======================================= --- /trunk/user/src/com/google/gwt/uibinder/rebind/W3cDomHelper.java Thu Nov 5 12:38:39 2009 +++ /trunk/user/src/com/google/gwt/uibinder/rebind/W3cDomHelper.java Thu Nov 5 19:55:23 2009 @@ -15,7 +15,11 @@ */ package com.google.gwt.uibinder.rebind; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.TreeLogger.Type; + import org.w3c.dom.Document; +import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -30,14 +34,14 @@ import javax.xml.parsers.ParserConfigurationException; /** - * Simplifies instantiation of the w3c XML parser, in just the style - * that UiBinder likes it. Used by both prod and test. + * Simplifies instantiation of the w3c XML parser, in just the style that + * UiBinder likes it. Used by both prod and test. */ public class W3cDomHelper { private final DocumentBuilderFactory factory; private final DocumentBuilder builder; - public W3cDomHelper() { + public W3cDomHelper(final TreeLogger logger) { factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setExpandEntityReferences(true); @@ -47,6 +51,28 @@ throw new RuntimeException(e); } builder.setEntityResolver(new GwtResourceEntityResolver()); + builder.setErrorHandler(new ErrorHandler() { + + public void error(SAXParseException exception) throws SAXException { + logger.log(Type.ERROR, exception.getMessage()); + logger.log(Type.DEBUG, "SAXParseException", exception); + } + + public void fatalError(SAXParseException exception) throws SAXException { + /* + * Fatal errors seem to be no scarier than error errors, and + * simply happen due to badly formed XML. + */ + logger.log(Type.ERROR, exception.getMessage()); + logger.log(Type.DEBUG, "SAXParseException", exception); + } + + public void warning(SAXParseException exception) throws SAXException { + logger.log(Type.WARN, exception.getMessage()); + logger.log(Type.DEBUG, "SAXParseException", exception); + } + + }); } /** @@ -54,8 +80,7 @@ * * @param string the document contents */ - public Document documentFor(String string) throws SAXException, - IOException { + public Document documentFor(String string) throws SAXException, IOException { return builder.parse(new ByteArrayInputStream(string.getBytes())); } ======================================= --- /trunk/user/test/com/google/gwt/uibinder/parsers/DockLayoutPanelParserTest.java Thu Nov 5 14:09:06 2009 +++ /trunk/user/test/com/google/gwt/uibinder/parsers/DockLayoutPanelParserTest.java Thu Nov 5 19:55:23 2009 @@ -93,7 +93,7 @@ } } - private static final W3cDomHelper docHelper = new W3cDomHelper(); + private static final W3cDomHelper docHelper = new W3cDomHelper(TreeLogger.NULL); private static final String BINDER_URI = "binderUri"; private static final String fieldName = "fieldName"; ======================================= --- /trunk/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java Thu Nov 5 12:38:39 2009 +++ /trunk/user/test/com/google/gwt/uibinder/rebind/XMLElementTest.java Thu Nov 5 19:55:23 2009 @@ -39,7 +39,7 @@ */ public class XMLElementTest extends TestCase { private static final String STRING_WITH_DOUBLEQUOTE = "I have a \" quote in me"; - private static final W3cDomHelper docHelper = new W3cDomHelper(); + private static final W3cDomHelper docHelper = new W3cDomHelper(TreeLogger.NULL); private Document doc; private Element item; private XMLElement elm; --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
