Changeset 25786

Show
Ignore:
Timestamp:
13.06.2012 21:00:45 (7 years ago)
Author:
ak19
Message:

Modified the indentXML() method to clear empty text nodes (containing any type of spaces) before prefixing the custom start and end text nodes containing newlines and tabs. This fixes the bug where the ServiceRackList? in the collectionConfig.xml was peculiarly affected and would end up with an increasing number of new lines around its subelements each time GLI was quit.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java

    r25710 r25786  
    814814        while (child != null) 
    815815        { 
     816            // first clear all empty text nodes (those containing space characters like \n,\r,\t and such) 
     817            if(child.getNodeType() == Node.TEXT_NODE && child.getNodeValue().matches("^\\s*$"))  
     818            { 
     819                Node spaceTextNode = child; 
     820                child = child.getNextSibling(); 
     821                elem.removeChild(spaceTextNode); 
     822                 
     823                if(child == null) break; 
     824            } 
     825 
     826            // now process normal element nodes as intended 
    816827            if (child.getNodeType() == Node.ELEMENT_NODE) 
    817828            { 
     
    830841        while (child != null) 
    831842        { 
     843            // Again, need to first clear all empty text nodes (those containing space characters like \n,\r,\t and such) 
     844            // because the first while loop above would break out when it found an element node and wouldn't have got rid 
     845            // of all the empty text nodes yet. 
     846            // This time, beware not to delete the special end and start empty textnodes just added, since  
     847            // they've been created and inserted specifically. 
     848            if(child != endTextNode && child != startTextNode  
     849               && child.getNodeType() == Node.TEXT_NODE && child.getNodeValue().matches("^\\s*$")) 
     850            { 
     851                Node spaceTextNode = child; 
     852                child = child.getNextSibling(); 
     853                elem.removeChild(spaceTextNode); 
     854 
     855                if(child == null) break; 
     856            } 
     857 
     858            // go back to processing normal element nodes as intended 
    832859            if (child.getNodeType() == Node.ELEMENT_NODE) 
    833860            {