You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/08/18 20:39:10 UTC

cvs commit: jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser AtomFeedParser.java RSSFeedParser.java

burton      2004/08/18 11:39:10

  Modified:    feedparser/src/java/org/apache/commons/feedparser
                        AtomFeedParser.java RSSFeedParser.java
  Log:
  Always trim() element values... while its slower its needed becuase Xerces isnt always trimming them
  
  Revision  Changes    Path
  1.11      +11 -2     jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/AtomFeedParser.java
  
  Index: AtomFeedParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/AtomFeedParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AtomFeedParser.java	16 Aug 2004 23:17:44 -0000	1.10
  +++ AtomFeedParser.java	18 Aug 2004 18:39:10 -0000	1.11
  @@ -298,6 +298,7 @@
   
       }
   
  +    //FIXME: unify this with RSSFeedParser.getChildElementTextByName
       private static String selectText( String query, Element element ) throws Exception {
   
           XPath xpath = new XPath( query );
  @@ -305,10 +306,18 @@
           
           //perform onChannel method...  (title, link, description)
           Element e = (Element)xpath.selectSingleNode( element );
  +
           if ( e == null )
               return null;
   
  -        return e.getText();
  +        String result = e.getText();
  +
  +        //The normalize method of XML SHOULD take care of this but for some
  +        //reason it doesnt.
  +        if ( result != null )
  +            result = result.trim();
  +
  +        return result;
   
       }
   
  
  
  
  1.10      +4 -3      jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/RSSFeedParser.java
  
  Index: RSSFeedParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/RSSFeedParser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RSSFeedParser.java	18 Aug 2004 18:23:01 -0000	1.9
  +++ RSSFeedParser.java	18 Aug 2004 18:39:10 -0000	1.10
  @@ -237,8 +237,8 @@
        *
        * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
        */
  -    private static String getChildElementTextByName( FeedParserState state,
  -                                                     String name ) throws Exception {
  +    public static String getChildElementTextByName( FeedParserState state,
  +                                                    String name ) throws Exception {
   
           XPath xpath = new XPath( "descendant::*[local-name() = '" + name + "']" );
           Object resultNode = xpath.selectSingleNode( state.current );
  @@ -248,7 +248,8 @@
           if ( resultNode != null )
               resultText = ((Element)resultNode).getText();
   
  -        //The normalize method of XML SHOULD take care of this but for some reason it doesnt.
  +        //The normalize method of XML SHOULD take care of this but for some
  +        //reason it doesnt.
           if ( resultText != null )
               resultText = resultText.trim();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org