X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=blobdiff_plain;f=zebra%2Fezeerex2pqfproperties.pl;h=2201b8394f823fd7c9be188f6b9f23ea09d1488a;hp=1155b4cbd284578006f17b09121d48530d7844da;hb=2185164008cd6dd14e31e44bb70027de83ce4316;hpb=0c7f526350e81439f54e5c2164855bde68a1013a diff --git a/zebra/ezeerex2pqfproperties.pl b/zebra/ezeerex2pqfproperties.pl index 1155b4c..2201b83 100755 --- a/zebra/ezeerex2pqfproperties.pl +++ b/zebra/ezeerex2pqfproperties.pl @@ -1,6 +1,6 @@ #! /usr/bin/perl -w -# $Id: ezeerex2pqfproperties.pl,v 1.5 2006-06-19 16:45:18 mike Exp $ +# $Id: ezeerex2pqfproperties.pl,v 1.7 2006-06-20 11:24:22 mike Exp $ # # Run like this: # ./ezeerex2pqfproperties.pl zeerex.xml @@ -17,8 +17,8 @@ my $root = $doc->getDocumentElement(); my $xc = XML::LibXML::XPathContext->new($root); $xc->registerNs(z => 'http://explain.z3950.org/dtd/2.0/'); -print_sets($xc); -print_default_set($xc); +my %setmap = print_sets($xc); +print_default_set($xc, \%setmap); print_indexes($xc); print_relations($xc); print_relation_modifiers($xc); @@ -30,27 +30,35 @@ print_truncations($xc); # SRU index: that way we could avoid defining # set.bib1 = 1.2.840.10003.3.1 # which is a Z39.50 attribute set that we don't need for CQL. But -# doing that would be a marginal gain. +# doing that would be a lot of work for marginal gain. # sub print_sets { my($xc) = @_; + my %setmap; my(@nodes) = $xc->findnodes('z:indexInfo/z:set'); foreach my $node (@nodes) { my $name = $node->findvalue('@name'); my $identifier = $node->findvalue('@identifier'); print "set.$name = $identifier\n"; + $setmap{$name} = $identifier; } + + return %setmap; } sub print_default_set { - my($xc) = @_; + my($xc, $setmap) = @_; my (@nodes) = $xc->findnodes('z:configInfo/' . 'z:default[@type="contextSet"]'); foreach my $node (@nodes) { - ### Look this up and render as a URI - print "set = ", $node->findvalue('.'), "\n"; + my $name = $node->findvalue('.'); + my $identifier = $setmap->{$name} + or die "no identifier for default context-set name '$name'"; + + print "# default context-set name '$name'\n"; + print "set = $identifier\n"; } } @@ -59,20 +67,23 @@ sub print_indexes { foreach my $node ($xc->findnodes('z:indexInfo/' . 'z:index[@search="true"]')) { - my @pqf = $xc->findnodes("z:map/z:attr", $node); + my @pqf = $xc->findnodes("z:map[z:attr]", $node); die("no PQF mapping for index '" . $xc->findvalue("z:title", $node) . "'") if @pqf == 0; - my $ptype = $xc->findvalue('@type', $pqf[0]); - my $pval = $xc->findvalue(".", $pqf[0]); + # Just pick one if there's more than one: they all work + + my $attrstr = ""; + foreach my $attr ($xc->findnodes("z:attr", $pqf[0])) { + my $ptype = $xc->findvalue('@type', $attr); + my $pval = $xc->findvalue(".", $attr); + $attrstr .= " $ptype=$pval"; + } foreach my $map ($xc->findnodes("z:map", $node)) { my $setname = $xc->findvalue('z:name/@set', $map); my $indexname = $xc->findvalue('z:name', $map); - ### We need a way for the ZeeRex record to specify other - # attributes to be specified along with the access-point, - # e.g. @attr 4=3 for whole-field indexes. - print "index.$setname.$indexname = $ptype=$pval\n" + print "index.$setname.$indexname =$attrstr\n" if $indexname ne ""; } }