On Thu, 31 May 2001, Nick Afshartous wrote:

> 
> Adding a call to String.trim below in the Digester.endElement
> method below makes surrounding white space in text elements
> insignificant and consistent with the Digester documentation.
> 
> Any chance this change could get into the final 1.0 release ?
> -- 
> 

I just committed this fix for both 1.0 and 1.1.

>       Nick
> 

Craig


> 
>   public void endElement(String name) throws SAXException {
> 
>       //      if (debug >= 3)
>       //          log("endElement(" + match + ")");
>       List rules = getRules(match);
> 
>       // Fire "body" events for all relevant rules
>       if (rules != null) {
>           //      if (debug >= 3)
>           //          log("  Firing 'body' events for " + rules.size() + " rules");
>           String bodyText = this.bodyText.toString().trim();
>                                                        ********
>             ...
> 
> Nick Afshartous writes:
>  > 
>  > I'd like to follow up on my original post.  It looks like the
>  > digester.CallMethodRule.body method doesn't remove whitespace
>  > from both ends of the XML body text.  However, other rules
>  > like digester.CallParamRule.body actually do by calling method
>  > String.trim.
>  > 
>  > Maybe the call to String.trim should be in a central place 
>  > (i.e. digester.Digester) so that the individual rules don't 
>  > have to worry about removing the whitespace ?
>  > 
>  > I'd be happy to work on a patch.
>  > -- 
>  > 
>  >    Nick
>  > 
>  > 
>  > 
>  > From: Nick Afshartous <[EMAIL PROTECTED]>
>  > To: [EMAIL PROTECTED]
>  > Subject: digester and whitespace in XML text body
>  > Date: Wed, 23 May 2001 17:11:27 -0400 (EDT)
>  > 
>  > 
>  > Hi,
>  > 
>  > I'm using the digester to process the nested content in
>  > XML tags and am noticing that the leading/trailing whitespace
>  > doesn't seem to be removed as advertised in the doc.  
>  > 
>  > For instance, the rule
>  > 
>  >         digester.addCallMethod("gateway/application/app-name", 
>  >                                "setAppName", 0);
>  > 
>  > results in the method setAppName being called with the surrounding
>  > whitespace in 
>  > 
>  >        <app-name>    foo      </app-name>
>  > 
>  > If anyone has any idea how to tell the digester to ignore 
>  > the leading/trailing whitespace please let me now, thanks.
>  > -- 
>  > 
>  >    Nick
>  > 
> 

Reply via email to