From b71505ef4cfd8d30c679b642234e8d49334f3378 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 14 Oct 2010 16:03:47 +0000 Subject: fixes for parse-texcatalogue-keywords and add infos how to read the dump back in git-svn-id: svn://tug.org/texlive/trunk@20096 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/bin/parse-texcatalogue-keywords | 44 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/Master/tlpkg/bin/parse-texcatalogue-keywords b/Master/tlpkg/bin/parse-texcatalogue-keywords index 0dc78558681..281542022cc 100755 --- a/Master/tlpkg/bin/parse-texcatalogue-keywords +++ b/Master/tlpkg/bin/parse-texcatalogue-keywords @@ -9,10 +9,13 @@ $^W = 1; use strict; + + use XML::Parser; use XML::XPath; use XML::XPath::XMLParser; use Text::Unidecode; +use Data::Dumper; my $tcfile; if (@ARGV) { @@ -26,13 +29,30 @@ my %kw_pkg; my %cz_pkg; parse_texcatalogue($tcfile); -print_keywords(); -print "\n===================\nprimary characterizations\n"; -walk_cz_tree($cz_pkg{'primary'}, "PRIM"); -print "\n===================\nsecondary characterizations\n"; -walk_cz_tree($cz_pkg{'secondary'}, "SEC"); -print "\n===================\nby-function characterizations\n"; -walk_cz_tree($cz_pkg{'by-function'}, "BFUNC"); + +$Data::Dumper::Indent = 1; +print Data::Dumper->Dump([\%seikaku, \%kw_pkg, \%cz_pkg], + ["seikaku", "kw_pkg", "cz_pkg"]), $/; + + +# how to read in!!! +#my $seikaku; +#my $kw_pkg; +#my $cz_pkg; +#my $foo = `cat tc-dump`; +# the no strict "vars" is *ABSOLUT* necessary otherwise the file is not +# evaluated, no idea why! +#no strict "vars"; +#eval "$foo"; +#use strict "vars"; +# +#print_keywords($kw_pkg); +#print "\n===================\nprimary characterizations\n"; +#walk_cz_tree($cz_pkg->{'primary'}, "PRIM"); +#print "\n===================\nsecondary characterizations\n"; +#walk_cz_tree($cz_pkg->{'secondary'}, "SEC"); +#print "\n===================\nby-function characterizations\n"; +#walk_cz_tree($cz_pkg->{'by-function'}, "BFUNC"); ##### only subs from here ########## @@ -62,11 +82,11 @@ sub parse_texcatalogue { foreach my $e ($parser->find('/fullcat/catalogue/entry')->get_nodelist) { - my $pkg = $parser->findvalue('./name',$e); + my $pkg = $parser->findvalue('./name',$e)->value(); #print "FOUND: $pkg\n"; my $n = $parser->find('./keyword',$e); for my $kw ($n->get_nodelist) { - my $kwval = $parser->find('./@keyword',$kw); + my $kwval = $parser->find('./@keyword',$kw)->string_value(); push @{$seikaku{'keyword'}{$pkg}}, $kwval; #print "keyword = $kwval\n"; } @@ -130,8 +150,9 @@ sub parse_characterizations { sub print_keywords { - for my $k (keys %kw_pkg) { - my @pkgl = @{$kw_pkg{$k}}; + my $kw_pkg = shift; + for my $k (keys %$kw_pkg) { + my @pkgl = @{$kw_pkg->{$k}}; if (defined(@pkgl)) { print "keyword = $k\n package = @pkgl\n"; } else { @@ -140,6 +161,7 @@ sub print_keywords { } } + sub walk_cz_tree { my $cp = shift; my $prestring = shift; -- cgit v1.2.3