Search in sources :

Example 1 with HTMLConfiguration

use of com.googlecode.html.HTMLConfiguration in project gwt-test-utils by gwt-test-utils.

the class Writer method main.

//
// Data
//
/**
     * Main.
     */
public static void main(String[] argv) throws Exception {
    if (argv.length == 0) {
        printUsage();
        System.exit(1);
    }
    XMLParserConfiguration parser = new HTMLConfiguration();
    parser.setFeature(NOTIFY_CHAR_REFS, true);
    parser.setFeature(NOTIFY_HTML_BUILTIN_REFS, true);
    String iencoding = null;
    String oencoding = "Windows-1252";
    boolean identity = false;
    boolean purify = false;
    for (int i = 0; i < argv.length; i++) {
        String arg = argv[i];
        if (arg.equals("-ie")) {
            iencoding = argv[++i];
            continue;
        }
        if (arg.equals("-e") || arg.equals("-oe")) {
            oencoding = argv[++i];
            continue;
        }
        if (arg.equals("-i")) {
            identity = true;
            continue;
        }
        if (arg.equals("-p")) {
            purify = true;
            continue;
        }
        if (arg.equals("-h")) {
            printUsage();
            System.exit(1);
        }
        java.util.Vector filtersVector = new java.util.Vector(2);
        if (identity) {
            filtersVector.addElement(new Identity());
        } else if (purify) {
            filtersVector.addElement(new Purifier());
        }
        filtersVector.addElement(new Writer(System.out, oencoding));
        XMLDocumentFilter[] filters = new XMLDocumentFilter[filtersVector.size()];
        filtersVector.copyInto(filters);
        parser.setProperty(FILTERS, filters);
        XMLInputSource source = new XMLInputSource(null, arg, null);
        source.setEncoding(iencoding);
        parser.parse(source);
    }
}
Also used : XMLInputSource(org.apache.xerces.xni.parser.XMLInputSource) HTMLConfiguration(com.googlecode.html.HTMLConfiguration) XMLDocumentFilter(org.apache.xerces.xni.parser.XMLDocumentFilter) XMLParserConfiguration(org.apache.xerces.xni.parser.XMLParserConfiguration) PrintWriter(java.io.PrintWriter) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

HTMLConfiguration (com.googlecode.html.HTMLConfiguration)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 XMLDocumentFilter (org.apache.xerces.xni.parser.XMLDocumentFilter)1 XMLInputSource (org.apache.xerces.xni.parser.XMLInputSource)1 XMLParserConfiguration (org.apache.xerces.xni.parser.XMLParserConfiguration)1