open(FIn,"<uk.txt");
print"<?xml version = '1.0' encoding = 'windows-1251' ?>
<?xml-stylesheet href='uk.xsl' type='text/xsl'?>             
<?cocoon-process type='xslt'?>
<topics>\n";
while(<FIn>) {
  if (/^$/) {print "</topic>\n";}
  else {
    if (/^[GM]/) {
      s/^([GM])(\d+)\ (.*)/$3/;
      $class=$2;
      $subj=$1;
      s/ //g;
      $path=(($subj eq 'M')?'math':'geom').$class."/index";
      $russubj=(($subj eq 'M')?'Математика-':'Геометрия-');
      print "<class number='$class' subject='$russubj' />";
      while (/;/) {
        s/([^;]+);(.*)/$2/;
        $les=$1;
        $les=~/^(\d+)/;
        $firstles=$1;
        $les=~s/_/-/;
        print "  <lesson name='$les' file='${path}${firstles}.htm' />\n";
      }
    }                     
    else {chomp;print "<topic><title>$_</title>\n";
    }
  }
}
print"</topics>\n";
