You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stefan Bodewig <bo...@bost.de> on 2000/04/04 13:31:26 UTC

More meaningfull parser errors (was Re: I want to become an Ant developer)

>>>>> "SM" == Stefano Mazzocchi <st...@apache.org> writes:

 SM> Stefan Bodewig wrote:

 >>  checking whether buld.xml is at least well formed and
 >>  providing better error messages would be helpfull.

 SM> +1, this is already in the todo list

 >>  Maybe Xerces would provide more usable error messages and thus >>
 >>  just switching the parser would help?

 SM> yes, xerces is much better at error codes than projectX, for what
 SM> I've seen, but maybe it's a problem with Ant that doesn't print
 SM> that information passed on the SAXExceptions...
 
No, I don't think so. I've downloaded Xerces, hacked together an
org.apache.tools.ant.Parser implementation for it (anybody
interested?) and tried the following part (surrounded by a valid
build file):

    <javac srcdir="${src.dir}"
           destdir="${build.classes}"
           classpath="${classpath}"
<!--           debug="on" -->
           deprecation="on"
           optimize="on" >

The result using projectX

BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to:
org.xml.sax.SAXParseException: com.sun.xml.parser/P-031 <

followed by a stack trace with no new information. I've also dumped
out the original stack trace of the SAXParseException, dind't really
help much.

The result using Xerces

BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to: org.xml.sax.SAXParseException: Element type "javac" must be followed by either attribute specifications, ">" or "/>".

and the stack trace.

So yes switching parser does help indeed.

Stefan

Re: More meaningfull parser errors (was Re: I want to become an Ant developer)

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "MC" == Michel CASABIANCA <ca...@sdv.fr> writes:

 MC> I don't agree : according to my experience, error messages from
 MC> ProjectX are better. But there is a localization bug that
 MC> produces "raw error codes" such as com.sun.xml.parser/P-031.

Thanks. I always knew I would regret installing a "german" Linux
distribution 8^). Indeed unsetting LC_ALL does the trick.

Stefan

Re: More meaningfull parser errors (was Re: I want to become an Ant developer)

Posted by Michel CASABIANCA <ca...@sdv.fr>.
Hi

Stefan Bodewig <bo...@bost.de> writes:
>  SM> yes, xerces is much better at error codes than projectX, for what
>  SM> I've seen, but maybe it's a problem with Ant that doesn't print
>  SM> that information passed on the SAXExceptions...
>  
> No, I don't think so. I've downloaded Xerces, hacked together an
> org.apache.tools.ant.Parser implementation for it (anybody
> interested?) and tried the following part (surrounded by a valid
> build file):
> 
>     <javac srcdir="${src.dir}"
>            destdir="${build.classes}"
>            classpath="${classpath}"
> <!--           debug="on" -->
>            deprecation="on"
>            optimize="on" >
> 
> The result using projectX
> 
> BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to:
> org.xml.sax.SAXParseException: com.sun.xml.parser/P-031 <
> 
> followed by a stack trace with no new information. I've also dumped
> out the original stack trace of the SAXParseException, dind't really
> help much.
> 
> The result using Xerces
> 
> BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to: org.xml.sax.SAXParseException: Element type "javac" must be followed by either attribute specifications, ">" or "/>".
> 
> and the stack trace.
> 
> So yes switching parser does help indeed.

I don't agree : according to my experience, error messages from
ProjectX are better. But there is a localization bug that produces
"raw error codes" such as com.sun.xml.parser/P-031.

I am french and have the same problem. The parser tries to apply
your local but fails because it doesn't have German messages. I
have writen a patch, see my home page :

http://www.sdv.fr/pages/casa/html/projectx.html

Sorry, it's in french (a localization bug ;o). To address this,
you can edit com/sun/xml/parser/Parser.java file :

replace :

  if (locale == null)
     locale = Locale.getDefault ();

with :

  if (locale == null) {
     locale = Locale.getDefault ();
     // casa: test if default locale is supported
     if(!messages.isLocaleSupported (locale.toString ()))
        locale = new Locale("en","US");
  }

If locale is not supported, I apply en_US. So you will have
english messages instead of code. You can also add localized
messages in property files (I've done it for french, see my
page).

If you apply that patch, parsing your buggy code would
produce :

  Attribute names must not start with "<" characters.

Does anybody from Sun reads this :o)
-- 
+---------------------------+--------------------------------+
| Michel CASABIANCA         | http://www.sdv.fr/pages/casa   |
| mailto:casa@sdv.fr        | Articles sur Java et XML       |
| Développement Java et XML | Applications et Applets de Jeu |
+---------------------------+--------------------------------+

Re: More meaningfull parser errors (was Re: I want to become an Ant developer)

Posted by Pierpaolo Fumagalli <pi...@apache.org>.
James Duncan Davidson wrote:
> 
> > So +1 to make Xerces the default browser... BTW, ProjectX is now donated
> > to the ASF so to me it makes perfect sense since it will be integrated
> > into Xerces anyway :)
> 
> Hmmm... Just use Jaxp. Pick up whatever is intalled.

I proposed to modify ANT to use it... But noone seemed to care :( :(

	Pier

-- 
----------------------------------------------------------------------
pier: stable structure erected over water to allow docking of seacraft
<ma...@betaversion.org>      <http://www.betaversion.org/~pier/>
----------------------------------------------------------------------

Re: More meaningfull parser errors (was Re: I want to become an Ant developer)

Posted by James Duncan Davidson <ja...@eng.sun.com>.
> So +1 to make Xerces the default browser... BTW, ProjectX is now donated
> to the ASF so to me it makes perfect sense since it will be integrated
> into Xerces anyway :)

Hmmm... Just use Jaxp. Pick up whatever is intalled.

.duncan


Re: More meaningfull parser errors (was Re: I want to become an Ant developer)

Posted by Stefano Mazzocchi <st...@apache.org>.
Stefan Bodewig wrote:
> 
> >>>>> "SM" == Stefano Mazzocchi <st...@apache.org> writes:
> 
>  SM> Stefan Bodewig wrote:
> 
>  >>  checking whether buld.xml is at least well formed and
>  >>  providing better error messages would be helpfull.
> 
>  SM> +1, this is already in the todo list
> 
>  >>  Maybe Xerces would provide more usable error messages and thus >>
>  >>  just switching the parser would help?
> 
>  SM> yes, xerces is much better at error codes than projectX, for what
>  SM> I've seen, but maybe it's a problem with Ant that doesn't print
>  SM> that information passed on the SAXExceptions...
> 
> No, I don't think so. I've downloaded Xerces, hacked together an
> org.apache.tools.ant.Parser implementation for it (anybody
> interested?) and tried the following part (surrounded by a valid
> build file):
> 
>     <javac srcdir="${src.dir}"
>            destdir="${build.classes}"
>            classpath="${classpath}"
> <!--           debug="on" -->
>            deprecation="on"
>            optimize="on" >
> 
> The result using projectX
> 
> BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to:
> org.xml.sax.SAXParseException: com.sun.xml.parser/P-031 <
> 
> followed by a stack trace with no new information. I've also dumped
> out the original stack trace of the SAXParseException, dind't really
> help much.
> 
> The result using Xerces
> 
> BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to: org.xml.sax.SAXParseException: Element type "javac" must be followed by either attribute specifications, ">" or "/>".
> 
> and the stack trace.
> 
> So yes switching parser does help indeed.

Great!

So +1 to make Xerces the default browser... BTW, ProjectX is now donated
to the ASF so to me it makes perfect sense since it will be integrated
into Xerces anyway :)

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------

Re: More meaningfull parser errors (was Re: I want to become an Ant developer)

Posted by Rajiv Mordani <Ra...@eng.sun.com>.
This is because you are probably running in a different locale other than
en. In that case you need to provide a Messages_<lang>.properties for the
parser to use.

- Rajiv

--
:wq

On 4 Apr 2000, Stefan Bodewig wrote:

> >>>>> "SM" == Stefano Mazzocchi <st...@apache.org> writes:
> 
>  SM> Stefan Bodewig wrote:
> 
>  >>  checking whether buld.xml is at least well formed and
>  >>  providing better error messages would be helpfull.
> 
>  SM> +1, this is already in the todo list
> 
>  >>  Maybe Xerces would provide more usable error messages and thus >>
>  >>  just switching the parser would help?
> 
>  SM> yes, xerces is much better at error codes than projectX, for what
>  SM> I've seen, but maybe it's a problem with Ant that doesn't print
>  SM> that information passed on the SAXExceptions...
>  
> No, I don't think so. I've downloaded Xerces, hacked together an
> org.apache.tools.ant.Parser implementation for it (anybody
> interested?) and tried the following part (surrounded by a valid
> build file):
> 
>     <javac srcdir="${src.dir}"
>            destdir="${build.classes}"
>            classpath="${classpath}"
> <!--           debug="on" -->
>            deprecation="on"
>            optimize="on" >
> 
> The result using projectX
> 
> BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to:
> org.xml.sax.SAXParseException: com.sun.xml.parser/P-031 <
> 
> followed by a stack trace with no new information. I've also dumped
> out the original stack trace of the SAXParseException, dind't really
> help much.
> 
> The result using Xerces
> 
> BUILD CONFIG ERROR: Can't open config file: buildfail.xml due to: org.xml.sax.SAXParseException: Element type "javac" must be followed by either attribute specifications, ">" or "/>".
> 
> and the stack trace.
> 
> So yes switching parser does help indeed.
> 
> Stefan
>