Debian Codegraph @

scripts/go-apply-xslt

raw ◀ ▶
1 Debian patch touch this file
1 #!/usr/bin/perl
2
3 # TODO: allow other xslt processors; eg xalan
4 if (system("which xsltproc > /dev/null")) {
5 print <<EOM
6 You need xsltproc (part of libxslt) for this.
7
8 See http://www.godatabase.org/dev/xml/xsl
9
10 [This script can easily be modified so that other xslt processors can
11 be used; eg java Xalan. I believe xsltproc to be the fastest. If you would
12 like this script to be extended to use a different xslt processor, please
13 email the gmod-ontol-sw-devel list]
14
15 EOM
16 ;
17 exit 1;
18 }
19 if (!@ARGV || $ARGV[0] =~ /^\-\-help/) {
20 print usage();
21 exit 0;
22 }
23 my $xsl = shift @ARGV;
24 my @files = ();
25 while ($ARGV[0] && $ARGV[0] !~ /^\-(.+)/) {
26 push(@files, shift @ARGV);
27 }
28
29 if (!$xsl) {
30 print "You must specify an XSLT logical name!\n";
31 exit 1;
32 }
33 #if (!@files) {
34 # print "You must specify an xml file to process!\n";
35 # exit 1;
36 #}
37 if (!@files) {
38 @files = ('-');
39 }
40
41 # if GO_ROOT is set then this specifies the location of the xslt dir
42 # if it is not set, assume we are using an installed version of go-perl,
43 # in which case, the xslts will be located along with the perl modules
44 my $xslt_file;
45 my $GO_ROOT = $ENV{GO_ROOT};
46 if ($GO_ROOT) {
47 # env var takes precedence;
48 # developers should use this
49 $xslt_file = "$GO_ROOT/xml/xsl/$xsl.xsl";
50 }
51
52 # default location is with perl modules
53 if (!$xslt_file || !-f $xslt_file) {
54 # user-mode; xsl will be wherever the GO modules are installed
55 require "GO/Parser.pm";
56 my $dir = $INC{'GO/Parser.pm'};
57 $dir =~ s/Parser\.pm/xsl/;
58 $xslt_file = "$dir/$xsl.xsl";
59 }
60
61 if (!-f $xslt_file) {
62 print <<EOM
63 I expected to find a file: "$xslt_file"
64
65 You may need to download the XSLT files from the go-dev distribution;
66 see
67
68 http://www.godatabase.org/dev/xml/xsl
69
70 Set the env var GO_ROOT to point to the directory containing the "xml"
71 rdirectory
72
73 EOM
74 ;
75 exit 1;
76 }
77
78 my $cmd = "xsltproc @ARGV $xslt_file @files";
79 if (system($cmd)) {
80 print STDERR "problem running: $cmd\n";
81 exit 1;
82 }
83 exit 0;
84
85 sub usage {
86 print <<EOM
87 go-apply-xslt XSLT-NAME [XML FILE...] [XSLTPROC-OPTIONS...]
88
89 processes Obo-XML files through an XSLT pipeline
90
91 examples:
92
93 go-apply-xslt oboxml_to_owl my.obo-xml
94 go-apply-xslt oboxml_filter my.obo-xml --stringparam namespace cell
95
96 If your input format is not obo-xml, you can transform it in a pipeline:
97
98 go2obo_xml so.obo | go-apply-xslt text_html -
99
100 Which is the same as:
101
•102 go2xml -x text_html so.obo
103
104 EOM
105 ;
106 }
107
108 __END__
109
110 =head1 NAME
111
112 go-apply-xslt - apply GO XSL on OBO-XML
113
114 =head1 DESCRIPTION
115
116 Will apply a GO XSL transform (by name) on an OBO-XML file
117
118 For a full list of XSLs available, see <http://www.godatabase.org/xml/xsl>
119
120 =head1 SEE ALSO
121
122 L<go-perl>