use strict; my ($exampleSource, @html, @css, $temp, $startHTML, $startCSS, %authorsDatabase, @cssKeyword); openDatabases(); assignParametersForCSSsourceProcessing(); if (!(open IN, "../ExampleSources/example$ARGV[0].xml")) { print "File example$ARGV[0].xml does not exist"; exit; } read IN, $exampleSource, 1000000; close IN; mkdir "../Examples/Example$ARGV[0]",755; generateDescription(); while ($exampleSource=~//gs) { my (@entryHtml, $entry, @entryCss); $entry = $1; $entry =~ / html *= *[",'] *(.*?) *[",']/s; @entryHtml = split (/ +/,$1); foreach $a (@entryHtml) { $html[$#html+1]=$a; }#foreach $entry =~ / css *= *[",'] *(.*?) *[",']/s; @entryCss = split (/ +/,$1); foreach $a (@entryCss) { $css[$#css+1]=$a; }#foreach }#while $startHTML = $html[0]; $startCSS = $css[0]; @html = sort @html; $temp = 'XXSAA'; @html = grep($_ ne $temp && ($temp = $_), @html); @css = sort @css; $temp = 'XXSAA'; @css = grep($_ ne $temp && ($temp = $_), @css); generateIndexFile(); foreach $a (@css) { generateCSS($a); } foreach $a (@html) { generateHTML($a); } sub generateCSS { my ($creator,$text, $finalCSS, $tmp, $finalCSSsource); if (!(open IN,"../CSSsource/css$_[0].xml")) {print "css$_[0].xml does not exist";exit;} read IN, $text, 1000000; close IN; $text =~ /(.*?)<\/cssSource *>/s; $finalCSS = $1; while ($finalCSS=~ /(.*?){(.*?)}/sg) { my (@def, $tmp, $d); @def = split (/;/,$2); $finalCSSsource = "$finalCSSsource$1\{"; foreach $d (@def) { my ($url, $n, $value); $d =~ / *(.*?) *:(.*)/s; $url = $1; $n = $1; $value = $2; $url =~ s/-/_/g; $n = "$n<\/A>"; $value = "$value<\/EM>"; $finalCSSsource = "$finalCSSsource$n\:$value;"; } $finalCSSsource = "$finalCSSsource\}"; } open OUT, ">../CSShtml/css$_[0].html"; print OUT "

$authorsDatabase{$creator}{'name'}:
CSS $_[0]

$finalCSSsource
"; close OUT; open OUT, ">../CSS/css$_[0].css"; print OUT $finalCSS; close OUT; return; } sub generateHTML { my ($creator,$htmlSource,$source, $htmloutput); if (!(open IN, "../HTMLSources/html$_[0].xml")) {print "html$_[0].xml does not exist"; exit;} read IN, $htmlSource, 1000000; close IN; $htmlSource =~ /(.*?)<\/htmlSource *>/s; $source = $1; $htmloutput = $1; open OUT, ">../HTMLs/HTML$_[0]/html$_[0]source.html"; $htmloutput =~ s/

$authorsDatabase{$creator}{'name'}:
HTML Source $_[0]

<body>\n$htmloutput\n</body>
"; close OUT; foreach $b (@css) { open OUT, ">../HTMLs/HTML$_[0]/html$_[0]_$b.html"; print OUT " $source "; close OUT; }#foreach #html without stylesheet open OUT, ">../HTMLs/HTML$_[0]/html$_[0]_0.html"; print OUT " $source "; close OUT; }#sub generateHTML sub generateIndexFile { my ($a); open INDEX, ">../Examples/Example$ARGV[0]/i.html"; print INDEX "
HTML: "; foreach $a (@html) { print INDEX "$a "; } print INDEX "
CSS: "; print INDEX "0 "; foreach $a (@css) { print INDEX "$a "; } print INDEX "
"; } sub openDatabases #same in XSLTutorial { my (@creators, $data, $cr,$email); open IN, "../Databases/authors.db"; read IN, $data, 1000000; close IN; @creators = split (/<\/creator/sg,$data); #> foreach $cr (@creators) { if ($cr=~/ *(.*?) *<\/email *>/s) { $email = $1; $cr=~/ *(.*?) *<\/name *>/s; $authorsDatabase{$email}{'name'} = $1; } }#foreach }#openDatabases sub generateDescription { my ($creator, $description); $exampleSource =~ / *(.*?)<\/description *>/s; $description = $1; $description =~ s//HTML $1<\/A>/g; $description =~ s//CSS $1<\/A>/g; open OUT,">../Examples/Example$ARGV[0]/description.html"; print OUT " [$ARGV[0]] $authorsDatabase{$creator}{'name'} :
$description
"; close OUT; } sub assignParametersForCSSsourceProcessing { my($attValues, $name, $i, $j, $file, @files); opendir DIR, "../Definitions"; @files = readdir(DIR); $i=0;$j=0; foreach $file (@files) { if ($file=~/(.*?)\.html/) { $name=$1; $name =~ s/_/-/g; @cssKeyword[$j++] = $name; } #if } #foreach }#sub assignParametersForCSSsourceProcessing