From fbb052cb397cbbaf65e1e5b3204262be74d4317f Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Mon, 5 Mar 2007 19:41:57 +0000 Subject: [PATCH] Add render_record() cql_target() works with single ID as well as with triple. --- lib/ZOOM/IRSpy/Utils.pm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/ZOOM/IRSpy/Utils.pm b/lib/ZOOM/IRSpy/Utils.pm index cbdb5c8..5942108 100644 --- a/lib/ZOOM/IRSpy/Utils.pm +++ b/lib/ZOOM/IRSpy/Utils.pm @@ -1,4 +1,4 @@ -# $Id: Utils.pm,v 1.24 2007-03-01 13:59:45 mike Exp $ +# $Id: Utils.pm,v 1.25 2007-03-05 19:41:57 mike Exp $ package ZOOM::IRSpy::Utils; @@ -13,7 +13,8 @@ our @EXPORT_OK = qw(isodate cql_target irspy_xpath_context modify_xml_document - bib1_access_point); + bib1_access_point + render_record); use XML::LibXML; use XML::LibXML::XPathContext; @@ -72,11 +73,13 @@ sub cql_quote { } -# Makes a CQL query that finds a specified target +# Makes a CQL query that finds a specified target. Arguments may be +# either an ID alone, or a (host, port, db) triple. sub cql_target { my($host, $port, $db) = @_; - return "rec.id=" . cql_quote("$host:$port/$db"); + $host .= ":$port/$db" if defined $port; + return "rec.id=" . cql_quote($host); } @@ -590,4 +593,18 @@ sub bib1_access_point { } +sub render_record { + my($rs, $which, $elementSetName) = @_; + + # There is a slight race condition here on the element-set name, + # but it shouldn't be a problem as this is (currently) only called + # from parts of the program that run single-threaded. + my $old = $rs->option(elementSetName => $elementSetName); + my $rec = $rs->record($which); + $rs->option(elementSetName => $old); + + return $rec->render(); +} + + 1; -- 1.7.10.4