classpathx-xml
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Classpathx-xml] patch for JAXPFactory


From: David Brownell
Subject: Re: [Classpathx-xml] patch for JAXPFactory
Date: Fri, 02 Nov 2001 12:34:26 -0800

If you have CVS access, go ahead and commit that.
Else let me know, and I'll do it.  Thanks for the patch!

- Dave


----- Original Message ----- 
From: "Mike Gratton" <address@hidden>
To: <address@hidden>
Sent: Friday, November 02, 2001 6:19 AM
Subject: [Classpathx-xml] patch for JAXPFactory


> 
> Guys,
> 
> I've just tracked down an obscure problem with the GNU JAXP libs. For a
> bit of backgound, I was trying to use gnujaxp.jar with Apache's Ant.
> 
> Here's what it does when parsing a project file (from
> ProjectHelper.parse()):
> 
> 1:  SAXParser saxParser = getParserFactory().newSAXParser();
> 2:  parser = saxParser.getParser();
>     ...
> 3:  parser.parse(inputSource, new RootHandler());
> 
> It obtains a SAXParser on line 1, caches an instance of a SAX1 Parser in
> the 'parser' member variable on line 2, so it can change the document
> handler when needed, then starts parsing on line 3 by calling parse() on
> the SAXParser.
> 
> The problem is, when SAXParser.parse() is handed a HandlerBase as
> happens on line 3 (RootHandler extends HandlerBase), it calls
> getParser() again to obtain an instance of a Parser. Unfortunately,
> JAXPFactory$JaxpParser doesn't cache the instance of Parser it
> constructs when getParser() is called.
> 
> This causes Ant all sorts of greif.
> 
> Anyway, I've attached a short patch that fixes this. I'd like to commit
> this to tree ASAP, can I do this myself or will someone need to do it
> for me?
> 
> Thanks,
> Mike.
> 
> 
> -- 
> Mike Gratton <address@hidden>
> "Every motive escalate."
>   Blatant self-promotion: <http://web.vee.net/>
> 


--------------------------------------------------------------------------------


> Index: source/gnu/xml/aelfred2/JAXPFactory.java
> ===================================================================
> RCS file: /cvsroot/classpathx/jaxp/source/gnu/xml/aelfred2/JAXPFactory.java,v
> retrieving revision 1.5
> diff -u -r1.5 JAXPFactory.java
> --- source/gnu/xml/aelfred2/JAXPFactory.java 2001/10/23 17:42:24 1.5
> +++ source/gnu/xml/aelfred2/JAXPFactory.java 2001/11/02 14:03:35
> @@ -138,6 +138,7 @@
>      private static class JaxpParser extends SAXParser
>      {
>   private XmlReader ae2 = new XmlReader ();
> + private XMLReaderAdapter parser = null;
>  
>   JaxpParser () { }
>  
> @@ -151,7 +152,11 @@
>  
>   public Parser getParser ()
>   throws SAXException
> -     { return new XMLReaderAdapter (ae2); }
> + { 
> +     if (parser == null)
> + parser = new XMLReaderAdapter (ae2);
> +     return parser;
> + }
>  
>   public XMLReader getXMLReader ()
>   throws SAXException
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]