Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 19491 invoked from network); 13 Aug 2004 20:47:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 13 Aug 2004 20:47:59 -0000 Received: (qmail 66215 invoked by uid 500); 13 Aug 2004 20:47:56 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 66171 invoked by uid 500); 13 Aug 2004 20:47:55 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 66158 invoked by uid 99); 13 Aug 2004 20:47:55 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.18.33.10] (HELO exchange.sun.com) (192.18.33.10) by apache.org (qpsmtpd/0.27.1) with SMTP; Fri, 13 Aug 2004 13:47:52 -0700 Received: (qmail 2371 invoked by uid 50); 13 Aug 2004 20:49:26 -0000 Date: 13 Aug 2004 20:49:26 -0000 Message-ID: <20040813204926.2370.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: dev@ant.apache.org Cc: Subject: DO NOT REPLY [Bug 30660] New: - Vague parse error when using namespaces X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=30660 Vague parse error when using namespaces Summary: Vague parse error when using namespaces Product: Ant Version: 1.7Alpha (nightly) Platform: PC OS/Version: Windows XP Status: NEW Severity: Minor Priority: Other Component: Core AssignedTo: dev@ant.apache.org ReportedBy: kgreiner@xpediantsolutions.com I was playing around trying to learn how to use an antlib when I tried this build file. The build failed with this error: Unexpected element "project" project at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:223) at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:132) at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:92) at org.apache.tools.ant.Main.runBuild(Main.java:658) at org.apache.tools.ant.Main.startAnt(Main.java:188) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) Being completely confused by the 'Unexpected element "project" project', I started digging at the code. I found two problems that contributed to the uninformative message. 1) In ProjectHelper2.parse, there is a catch block for SAXParseException. This block extracts the cause exception from the SAXParseException using "exc.getException ()" then creates a BuildException with that cause exception. In this particular case, "exc.getException()" returned null so the BuildException had no cause. 2) The actual exception message comes from ProjectHelper2.MainHandler.onStartChild. The qname and name parameters supplied by the SAX parser are identical as my xmlns attribute did not set a namespace. I believe that the first problem can be fixed by using the SAXParseException as the cause when it does not itself contain a cause exception. As for the message text, it seems appropriate to display the namespace URIs when the qname and name are otherwise identical. I've attached a patch that implements both of these changes. Using this patch, the original exception changed into the following. Unexpected element "{antlib:any.resource}project" {antlib:org.apache.tools.ant}project at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:225) at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:132) at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:92) at org.apache.tools.ant.Main.runBuild(Main.java:658) at org.apache.tools.ant.Main.startAnt(Main.java:188) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55) Caused by: org.xml.sax.SAXParseException: Unexpected element "{antlib:any.resource}project" {antlib:org.apache.tools.ant}project at org.apache.tools.ant.helper.ProjectHelper2$MainHandler.onStartChild(ProjectHelper2.java:542) at org.apache.tools.ant.helper.ProjectHelper2$RootHandler.startElement(ProjectHelper2.java:437) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:209) ... --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org