/[ddp]/manuals/trunk/sgml-howto/condition.pl
ViewVC logotype

Contents of /manuals/trunk/sgml-howto/condition.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 854 - (hide annotations) (download)
Sun Oct 10 20:06:29 1999 UTC (13 years, 8 months ago) by bortz
File MIME type: text/plain
File size: 1531 byte(s)
First version in the Debian CVS site
1 bortz 854 #!/usr/bin/perl
2    
3     use XML::DOM;
4     use strict;
5    
6     $::valuetokeep = shift (@ARGV);
7     my $filename = shift (@ARGV);
8    
9     $::debug = 1;
10    
11     if ((! $filename) or (! $::valuetokeep)) {
12     die "Usage: $0 valuetokeep filename\n";
13     }
14    
15     my $parser = new XML::DOM::Parser;
16     my $doc = $parser->parsefile ($filename);
17     my $root = $doc->getDocumentElement;
18     my $attributes;
19    
20     &scanChildren ($root->getChildNodes);
21     $doc->printToFileHandle (\*STDOUT);
22    
23    
24     sub scanChildren {
25     my (@children) = @_;
26     my ($child);
27     child:
28     foreach $child (@children) {
29     if ($child->getNodeType == ELEMENT_NODE) {
30     my ($found, $nocondition);
31     my $versionequal = $child->getAttribute ("debianversionequal");
32     my $versionmin = $child->getAttribute ("debianversionmin");
33     my $versionmax = $child->getAttribute ("debianversionmax");
34     if ($versionequal) {
35     if ($versionmin or $versionmax) {
36     die "Cannot have Version-min or Version-max with Version-equal";
37     }
38     if ($versionequal == $::valuetokeep) {
39     $found = 1;
40     }
41     }
42     elsif ($versionmin) {
43     if ($versionmin <= $::valuetokeep) {
44     if ($versionmax and ($versionmax >= $::valuetokeep)) {
45     $found = 1;
46     }
47     elsif (! $versionmax) {
48     $found = 1;
49     }
50     }
51     }
52     elsif ($versionmax) {
53     if ($versionmax >= $::valuetokeep) {
54     $found = 1;
55     }
56     }
57     else {
58     # No attribute, no condition
59     $nocondition = 1;
60     $found = 1;
61     }
62     if (! $found) {
63     $child->getParentNode->removeChild ($child);
64     }
65     &scanChildren ($child->getChildNodes);
66     }
67     }
68     }

  ViewVC Help
Powered by ViewVC 1.1.5