while (<STDIN>) {
  $doc .= $_;
}

print qq'<?xml version="1.0" standalone="no"?>\n';
print qq'<!DOCTYPE suite SYSTEM "../conf/suite.dtd">\n';
print qq'<suite defaultHost="localhost" defaultPort="8080" label="Watchdog JSP tests">';

# remove junk
$doc =~ s#<property .*?/>##sg;
$doc =~ s#<taskdef .*?/>##sg;
$doc =~ s#</?target.*?>##sg;
$doc =~ s#</?project.*?>##sg;

# fix me - create sessions for each test category
$doc =~ s#testName=\".*?\"##sg;

# this is never relevant - latka has other ways to handle this
$doc =~ s#debug="0" host="\${host}" port ?="\${port}"##sg;

# make every gtest into a request
$doc =~ s#<gtest request="GET (.*?) HTTP/1.0"(.*?)assertion="(.*?)"\s*?testStrategy="(.*?)"\s*?/>#<request path="$1" label="$3">\n<validate>\n<TEMPLABEL>$4</TEMPLABEL>\n$2</validate>\n</request>#sg;

$doc =~ s#returncode="200"#<statusCode/>#sgi;
$doc =~ s#returncode="HTTP/1.0 200 OK"#<statusCode/>#sgi;
$doc =~ s#returncode="500"#<statusCode code="500"/>#sgi;
$doc =~ s#goldenFile="(.*?)"#<goldenFile fileName="$1" ignoreWhitespace="true"/>#sg;
$doc =~ s#responseMatch="(.*?)"#<regexp pattern="$1"/>#sg;

# apply the label to the first test
$doc =~ s#<validate>\s*<TEMPLABEL>(.*?)</TEMPLABEL>\s*?(<[^>]*?)/>#<validate>\n$2 label="$1"/>#sg;



print $doc;

print "\n</suite>";

#now someone beautify me and we're done
