dom/xslt/tests/buster/helper/generate-rdf.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xslt/tests/buster/helper/generate-rdf.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +use File::Spec;
     1.5 +
     1.6 +my(@chunks, @list, $entry, $main_cats, $spacing);
     1.7 +@list = ('conf', 'perf');
     1.8 +foreach $entry (@list) {
     1.9 +    $main_cats .= "     <rdf:li><rdf:Description about=\"urn:x-buster:$entry\" nc:dir=\"$entry\" /></rdf:li>\n";
    1.10 +    go_in($entry, '', $entry);
    1.11 +}
    1.12 +if ($ARGV[0]) {
    1.13 +    open OUTPUT, ">$ARGV[0]";
    1.14 +}
    1.15 +else {
    1.16 +    open OUTPUT, ">xalan.rdf";
    1.17 +};
    1.18 +select(OUTPUT);
    1.19 +print '<?xml version="1.0"?>
    1.20 +
    1.21 +<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    1.22 +         xmlns:nc="http://home.netscape.com/NC-rdf#">
    1.23 +  <rdf:Seq about="urn:root">
    1.24 +' . $main_cats . '  </rdf:Seq>
    1.25 +';
    1.26 +print join('',@chunks);
    1.27 +print '</rdf:RDF>
    1.28 +';
    1.29 +exit 0;
    1.30 +
    1.31 +sub go_in {
    1.32 +    my($current, $about, $cat) = @_;
    1.33 +    my (@list, $entry, @subdirs, @files, @purps, $rdf);
    1.34 +    chdir $current;
    1.35 +    @list = <*>;
    1.36 +    
    1.37 +    LOOP: foreach $entry (@list) {
    1.38 +        next LOOP if $entry=~/^CVS$/;
    1.39 +        if (! -d $entry) {
    1.40 +            if ($entry=~/^($current.*)\.xsl$/) {
    1.41 +		local $source = $entry;
    1.42 +		$source=~s/xsl$/xml/;
    1.43 +		next LOOP if ! -f $source;
    1.44 +		$entry=~/^($current.*)\.xsl$/;
    1.45 +                push(@files, $1);
    1.46 +                local ($purp, $purp_open);
    1.47 +                open STYLE, $entry;
    1.48 +                $purp_open = 0;
    1.49 +                while (<STYLE>) {
    1.50 +                    if (/<!--\s+purpose: (.+)\s*-->/i) {
    1.51 +                        $purp .= $1;
    1.52 +                    }
    1.53 +                    elsif (/<!--\s+purpose: (.+)\s*$/i) {
    1.54 +                        $purp_open = 1;
    1.55 +                        $purp .= $1;
    1.56 +                    }
    1.57 +                    elsif ($purp_open) {
    1.58 +                        if (/\s*(\s.+)\s*-->/) {
    1.59 +                            $purp_open = 0;
    1.60 +                            $purp .= $1;
    1.61 +                        }
    1.62 +                        elsif (/\s*(\s.+)\s*$/) {
    1.63 +                            $purp .= $1;
    1.64 +                        }
    1.65 +                    }
    1.66 +                }
    1.67 +                $purp=~s/"/'/g; $purp=~s/&/&amp;/g; $purp=~s/</&lt;/g;
    1.68 +                $purp=~s/\r/ /g; $purp=~s/\s\s/ /g; $purp=~s/\s$//g;
    1.69 +                push(@purps, $purp);
    1.70 +            }
    1.71 +        }
    1.72 +        else {
    1.73 +            push(@subdirs, $entry);
    1.74 +        }
    1.75 +    }
    1.76 +
    1.77 +    if (@subdirs > 0 || @files > 0) {
    1.78 +        my $topic = $about.$current; $topic=~s/\///g;
    1.79 +        $rdf = '  <rdf:Seq about="urn:x-buster:'.$topic."\">\n";
    1.80 +        foreach $entry (@subdirs) {
    1.81 +            if (go_in($entry, $about.$current.'/', $cat)) {
    1.82 +                my $id = 'urn:x-buster:'.$about.$current.$entry; $id=~s/\///g;
    1.83 +                $rdf .= "    <rdf:li><rdf:Description about=\"$id\" nc:dir=\"$entry\" /></rdf:li>\n";
    1.84 +            }
    1.85 +        }
    1.86 +        for (my $i=0; $i < @files; $i++) {
    1.87 +            my $uri = $about.$current.'/'.$files[$i];
    1.88 +            $uri=~s/[^\/]+\///;
    1.89 +            my $id = $uri; $id=~s/\///g;
    1.90 +            $rdf .= "    <rdf:li><rdf:Description about=\"urn:x-buster:$files[$i]\" nc:name=\"$files[$i]\" nc:purp=\"$purps[$i]\" nc:path=\"$uri\" nc:category=\"$cat\" /></rdf:li>\n";
    1.91 +        }
    1.92 +        $rdf .= "  </rdf:Seq>\n";
    1.93 +        push(@chunks, $rdf);
    1.94 +    }
    1.95 +
    1.96 +    chdir File::Spec->updir;
    1.97 +    return (@subdirs > 0 || @files > 0);
    1.98 +}

mercurial