root/Xml/Working/listElementsAndAttributes.pl
| Revision 42, 0.8 kB (checked in by andrew, 19 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strict; |
| 4 | |
| 5 | my @files = @ARGV; |
| 6 | #my @files = ("ome.xsd"); |
| 7 | #print `pwd`; |
| 8 | |
| 9 | unless( @files ) { |
| 10 | print "usage: \n./listElementsAndAttributes.pl *xsd\n"; |
| 11 | exit; |
| 12 | } |
| 13 | |
| 14 | my @elements; |
| 15 | my @attributes; |
| 16 | |
| 17 | foreach my $file (@files ) { |
| 18 | open( FILE, "< $file" ) |
| 19 | or die "Couldn't open $file"; |
| 20 | while( my $line = <FILE> ) { |
| 21 | chomp $line; |
| 22 | if( $line =~ m/<(xsd:)?element[^>*?]name\s*=\s*"(\w+)"/o ) { |
| 23 | push( @elements, $2 ); |
| 24 | } elsif( $line =~ m/<(xsd:)?attribute[^>*?]name\s*=\s*"(\w+)"/o ) { |
| 25 | push( @attributes, $2 ); |
| 26 | } |
| 27 | } |
| 28 | close( FILE ); |
| 29 | } |
| 30 | |
| 31 | print "Elements:\n\n"; |
| 32 | foreach my $name ( @elements ) { |
| 33 | $name =~ s/([[:upper:]])/ $1/g; |
| 34 | print "$name\n"; |
| 35 | } |
| 36 | print "\n"; |
| 37 | |
| 38 | print "Attributes:\n"; |
| 39 | foreach my $name ( @attributes ) { |
| 40 | $name =~ s/([[:upper:]])/ $1/g; |
| 41 | print "$name\n"; |
| 42 | } |
| 43 | print "\n"; |
| 44 |
Note: See TracBrowser
for help on using the browser.
