<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2479.6" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#c8e0d8>
<DIV><FONT face="Comic Sans MS" size=2><FONT face="Comic Sans MS" size=2><EM>hi
All,</EM></FONT></DIV>
<DIV>
<DIV><FONT face="Comic Sans MS" size=2><EM></EM></FONT> </DIV>
<DIV><FONT face="Comic Sans MS" size=2><EM>Using this release I experienced a
bug in the class SAXBuilder which make any custom filter useless (try the
demos)</EM></FONT></DIV>
<DIV><FONT face="Comic Sans MS" size=2><EM></EM></FONT> </DIV>
<DIV><EM>I have patched the SAXBuilder and fix this bug ,using the faster
way. </EM></DIV>
<DIV><EM>( theres many way to fix it and they can also involve the design
structure) </EM></DIV>
<DIV><FONT face="Comic Sans MS" size=2><EM></EM></FONT> </DIV>
<DIV>
<DIV><STRONG><EM>the problem :</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><EM><STRONG> </STRONG>an error in the method "configureParser" or a
wrong position of the code which concatenate the chain of the custom
filters</EM></DIV>
<DIV><EM> anyway you can see that each time the "build" method is called a
call to configureParser is made before to parse the file</EM></DIV>
<DIV><EM> this method setup the chain of custom filter in order
to put the default parser as the main parent of the chain </EM></DIV>
<DIV> [ root.setParent(parser); ]</DIV>
<DIV><EM> and the custom filter as the top of the
chain</EM></DIV>
<DIV> [ parser = saxXMLFilter; ]<BR><EM> this is ok but doesn't make
any sense since the variable parser is a local variable of the method and it
will never be used after the configuration</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV>
<DIV><EM>-----------------------------------------------------------------------------------------------------------------------------------------</EM></DIV>
public Document build(InputSource in) throws JDOMException
{<BR> SAXHandler contentHandler =
null;</DIV>
<DIV><EM></EM> </DIV>
<DIV> try
{<BR> //
Create and configure the content
handler.<BR>
contentHandler =
createContentHandler();<BR>
configureContentHandler(contentHandler);</DIV>
<DIV><EM></EM> </DIV>
<DIV> //
Create and configure the
parser.<BR>
XMLReader parser =
createParser();<BR>
<STRONG>configureParser(parser, contentHandler);</STRONG></DIV>
<DIV><EM></EM> </DIV>
<DIV> // Parse
the
document.<BR> <STRONG>
parser.parse(in);<BR></STRONG></DIV></DIV>
<DIV>
<DIV><EM> ........ecc</EM></DIV>
<DIV><EM>-----------------------------------------------------------------------------------------------------------------------------------------</EM></DIV>
protected void configureParser(XMLReader parser, SAXHandler
contentHandler) throws Exception {</DIV>
<DIV><EM></EM> </DIV>
<DIV> // Install optional
filter<BR> if (saxXMLFilter != null)
{<BR> //
Connect filter chain to
parser<BR>
XMLFilter root =
saxXMLFilter;<BR>
while (root.getParent() instanceof XMLFilter)
{<BR>
root =
(XMLFilter)root.getParent();<BR>
}<BR>
root.setParent(parser);</DIV>
<DIV><EM></EM> </DIV>
<DIV> // Read
from
filter<BR><STRONG>
parser = saxXMLFilter;<BR></STRONG>
}</DIV>
<DIV><EM></EM> </DIV>
<DIV> // Setup SAX
handlers.<BR><EM><EM>
........ecc</EM></EM></DIV>
<DIV><EM><EM>-----------------------------------------------------------------------------------------------------------------------------------------</EM></DIV></EM>
<DIV><EM></EM> </DIV>
<DIV>
<DIV><STRONG><EM>one solution :</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><EM>make the method "configureParser" to return a value so when the method
"build" call the top filter it will be the correct one</EM></DIV>
<DIV><EM><EM>-----------------------------------------------------------------------------------------------------------------------------------------</EM></DIV></DIV>
<DIV> </EM> public Document build(InputSource in) throws
JDOMException {<BR> SAXHandler
contentHandler = null;</DIV>
<DIV><EM></EM> </DIV>
<DIV> try
{<BR> //
Create and configure the content
handler.<BR>
contentHandler =
createContentHandler();<BR>
configureContentHandler(contentHandler);</DIV>
<DIV><EM></EM> </DIV>
<DIV> //
Create and configure the
parser.<BR>
XMLReader parser =
createParser();<BR> <STRONG>
parser=configureParser(parser, contentHandler);</STRONG></DIV>
<DIV><EM></EM> </DIV>
<DIV> // Parse
the
document.<BR>
parser.parse(in);<BR>
<DIV><EM>
......................
ecc<BR>-----------------------------------------------------------------------------------------------------------------------------------------</EM></DIV></DIV>
<DIV> <STRONG> protected XMLReader configureParser(XMLReader
parser, SAXHandler contentHandler) throws Exception {</STRONG></DIV>
<DIV><EM></EM> </DIV>
<DIV> // Install optional
filter<BR> if (saxXMLFilter != null)
{<BR> //
Connect filter chain to
parser<BR>
XMLFilter root =
saxXMLFilter;<BR>
while (root.getParent() instanceof XMLFilter)
{<BR>
root =
(XMLFilter)root.getParent();<BR>
}<BR>
root.setParent(parser);</DIV>
<DIV><EM></EM> </DIV>
<DIV> // Read
from
filter<BR>
parser = saxXMLFilter;<BR> }</DIV>
<DIV> ....................... ecc<BR><STRONG>
return parser; </STRONG></DIV>
<DIV><EM>-----------------------------------------------------------------------------------------------------------------------------------------</EM></DIV>
<DIV><EM></EM> </DIV>
<DIV><EM>regards,</EM></DIV>
<DIV><EM>Paolo Lioy</EM></DIV></FONT></DIV>
<DIV><EM><FONT face="Comic Sans MS"
size=2></FONT></EM> </DIV></BODY></HTML>