1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24$ARGV = shift @ARGV; 25my %tokens; 26 27my @files = glob("$ARGV/*.rnc"); 28 29open( TOKEN, ">tokens.txt" ) || die "can't write token file"; 30 31foreach( @files ) 32{ 33 print( "parsing $_\n" ); 34 open ( XSD, $_ ) || die "can't open token file: $!"; 35 while( <XSD> ) 36 { 37 chomp($_); 38 if( /element (\S*:)?(\S*)/ ) 39 { 40 $tokens{$2} = 1; 41 print("."); 42 } 43 elsif( /attribute (\S*:)?(\S*)/ ) 44 { 45 $tokens{$2} = 1; 46 print("."); 47 } 48 elsif( /list\s*\{/ ) 49 { 50 while( <XSD> ) 51 { 52 chomp($_); 53 last if( /^\s*\}/ ); 54 if( /"(\S*?)\"/ ) 55 { 56 $tokens{$1} = 1; 57 print("."); 58 } 59 } 60 } 61 } 62 close ( XSD ); 63 64 print("\n" ); 65} 66 67foreach( sort(keys(%tokens)) ) 68{ 69 print TOKEN "$_\n"; 70} 71close( TOKEN ); 72