Ignore:
Timestamp:
2011-05-09T14:37:04+12:00 (13 years ago)
Author:
sjm84
Message:

Updating this branch to match the latest Greenstone3 changes

Location:
main/branches/64_bit_Greenstone/greenstone3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/branches/64_bit_Greenstone/greenstone3

  • main/branches/64_bit_Greenstone/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java

    r18434 r24007  
    4141import java.io.FileInputStream;
    4242import java.io.FileReader;
     43import java.util.regex.*;
    4344
    4445import org.apache.log4j.*;
     46
     47// Apache Commons
     48import org.apache.commons.lang3.*;
     49
     50import java.util.*;
     51import java.lang.reflect.*;
    4552
    4653/** XMLConverter - utility class for greenstone
     
    5966
    6067    private static boolean outputEscaping = true;
    61 
    6268
    6369     /** the no-args constructor */
     
    216222    }
    217223
     224    /* For the purposes of logger.debug statements, where this is called and hence outputted,
     225    returns an empty string if debugging is not enabled */
     226    public static String getPrettyStringLogger(Node xmlNode, Logger log) {
     227
     228    if(log.isDebugEnabled())
     229        return getPrettyString(xmlNode);
     230   
     231    return "";
     232
     233    }
     234
    218235    private static void getString(Node xmlNode, StringBuffer xmlRepresentation,
    219236                 int depth, boolean pretty)
     
    242259        String sid  = dt.getSystemId();
    243260       
    244         String doctype_str = "<!DOCTYPE " + dt.getName() + " PUBLIC \"" + pid + "\" \"" + sid + "\">\n";
     261        // Use previously assigned name, not dt.getName() again
     262        String doctype_str = "<!DOCTYPE " + name + " PUBLIC \"" + pid + "\" \"" + sid + "\">\n";
    245263       
    246264        xmlRepresentation.append(doctype_str);
     
    321339
    322340        // Perform output escaping, if required
     341        // Apache Commons replace method is far superior to String.replaceAll - very fast!
    323342        if (outputEscaping) {
    324         text = text.replaceAll("&", "&amp;");  // Must be done first!!
    325         text = text.replaceAll("<", "&lt;");
    326         text = text.replaceAll(">", "&gt;");
    327         text = text.replaceAll("\"", "&quot;");
    328         text = text.replaceAll("\'", "&apos;");
     343
     344        text = StringUtils.replace(text, "&", "&amp;");
     345        text = StringUtils.replace(text, "<", "&lt;");
     346        text = StringUtils.replace(text, ">", "&gt;");
     347        text = StringUtils.replace(text, "'", "&apos;");
     348        text = StringUtils.replace(text, "\"", "&quot;");
    329349        }
    330350
    331351        // Remove any control-C characters
    332         text = text.replaceAll("" + (char) 3, "");
     352        text = StringUtils.replace(text, "" + (char)3, "");
     353
    333354        xmlRepresentation.append(text);
    334355    }
Note: See TracChangeset for help on using the changeset viewer.