classpathx-xml
[Top][All Lists]
Advanced

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

[Classpathx-xml] patch for JAXPFactory


From: Mike Gratton
Subject: [Classpathx-xml] patch for JAXPFactory
Date: Sat, 03 Nov 2001 00:49:01 +1030
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5+) Gecko/20011019


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]