source: wsdl/make_topdl_standalone.pl @ b709861

compt_changesinfo-ops
Last change on this file since b709861 was 549830d, checked in by Ted Faber <faber@…>, 14 years ago

Set up a makefile to create a standalone version of topdl.xsd (called
topdl_stand.xsd) that can be used to validate topdl files.

validate.py uses lxml to validate such files locally, and fails gracefully without lxml.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use IO::File;
5
6my $usage = "Usage: $0 types schema [top_element_name]\n";
7
8my $type_fn = shift || die $usage;
9my $topdl_fn = shift || die $usage;
10my $ename = shift || 'experiment';
11
12my $id_type = "<!-- imported from $type_fn -->\n";
13my $first;
14my $v;
15
16my $f = new IO::File($type_fn) || die "Can't open $type_fn: $!\n";
17
18
19while (<$f>) {
20    (/<xsd:complexType name="IDType">/ .. m#</xsd:complexType>#) && do {
21        $id_type .= $_;
22    };
23}
24$id_type .= "<!-- end import -->\n\n";
25$f->close();
26$f = new IO::File($topdl_fn) || die "Can't open $topdl_fn: $!\n";
27
28while (<$f>) {
29    ($v = /<xsd:schema/ .. />/) && do { 
30        chomp;
31        if ($v == 1 ) {
32            print "<!-- old schema declaration $_ ";
33        }
34        elsif ($v =~ /E0/) {
35            print "$_ -->\n";
36            print "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/" .
37                "XMLSchema\">\n";
38        }
39        else { print "$_ "; }
40        next;
41    };
42       
43    m#xmlns:fns="http://www.isi.edu/fedd_types"# && next;
44    !$first && /<xsd:complexType/ && do {
45        print $id_type;
46        $first++;
47    };
48    m#</xsd:schema># && do {
49        print "<xsd:element name=\"$ename\" type=\"topologyType\"/>\n";
50    };
51    s/[tf]ns://g;
52    print;
53}
54$f->close();
Note: See TracBrowser for help on using the repository browser.