Rev | Line | |
---|
[12334] | 1 | #! /usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | # Written by Dirk Stöcker <openstreetmap@dstoecker.de>
|
---|
| 4 | # Public domain, no rights reserved.
|
---|
| 5 |
|
---|
| 6 | use strict;
|
---|
[25613] | 7 | use LWP::Simple;
|
---|
[26592] | 8 | use encoding 'utf8';
|
---|
[12334] | 9 |
|
---|
| 10 | my $item;
|
---|
| 11 | my $comment = 0;
|
---|
| 12 |
|
---|
| 13 | # This is a simple conversion and in no way a complete XML parser
|
---|
| 14 | # but it works with a default Perl installation
|
---|
| 15 |
|
---|
[13392] | 16 | # Print a header to write valid Java code. No line break,
|
---|
| 17 | # so that the input and output line numbers will match.
|
---|
| 18 | print "class trans_wms { void tr(String s){} void f() {";
|
---|
| 19 |
|
---|
[25613] | 20 | my @lines;
|
---|
| 21 | if($ARGV[0] && $ARGV[0] =~ /^http:\/\//)
|
---|
[12334] | 22 | {
|
---|
[25613] | 23 | @lines = split("\r?\n", get($ARGV[0]));
|
---|
| 24 | }
|
---|
| 25 | else
|
---|
| 26 | {
|
---|
| 27 | @lines = <>;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | for my $line (@lines)
|
---|
| 31 | {
|
---|
| 32 | $line =~ s/\r//g;
|
---|
[12334] | 33 | chomp($line);
|
---|
[26589] | 34 | if($line =~ /<name>(.*)<\/name>/)
|
---|
[12334] | 35 | {
|
---|
[26593] | 36 | my $val = $1;
|
---|
| 37 | $val =~ s/&/&/g;
|
---|
[26654] | 38 | print "/* $line */ tr(\"$val\");\n";
|
---|
[12334] | 39 | }
|
---|
| 40 | else
|
---|
| 41 | {
|
---|
| 42 | print "/* $line */\n";
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
[13392] | 45 |
|
---|
| 46 | print "}}\n";
|
---|
Note:
See
TracBrowser
for help on using the repository browser.