Last change
on this file since 34920 was 33143, checked in by stoecker, 7 years ago |
add tag2link translation parsing
|
File size:
956 bytes
|
Line | |
---|
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;
|
---|
7 |
|
---|
8 | my $item;
|
---|
9 | my $src = "";
|
---|
10 | my $country = "";
|
---|
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 |
|
---|
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_tag2link { void tr(String s){} void f() {";
|
---|
19 |
|
---|
20 | while(my $line = <>)
|
---|
21 | {
|
---|
22 | chomp($line);
|
---|
23 | print "tr(\"---DUMMY-MARKER---\"); ";
|
---|
24 | if($line =~ /<link name="([^"]+)" /)
|
---|
25 | {
|
---|
26 | print "tr(\"$1\") /* src $src country code $country */\n";
|
---|
27 | }
|
---|
28 | elsif($line =~ /^$/)
|
---|
29 | {
|
---|
30 | print "\n";
|
---|
31 | }
|
---|
32 | else
|
---|
33 | {
|
---|
34 | if($line =~ /<src name="([^"]+)" country-code="([^"]+)"/)
|
---|
35 | {
|
---|
36 | $src = $1; $country = $2;
|
---|
37 | }
|
---|
38 | elsif($line =~ /<\/src/)
|
---|
39 | {
|
---|
40 | $src = ""; $country = ""
|
---|
41 | }
|
---|
42 | print "/* $line */\n";
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | print "}}\n";
|
---|
Note:
See
TracBrowser
for help on using the repository browser.