Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add File_MARC_Lint for MARC syntax checking

Many thanks to Demian Katz <demian.katz@villanova.edu> for the contribution of
File_MARC_Lint. This gives users an easy way to check the validity of their
USMARC records.

Accordingly, we're bumping the version to 0.7.0 and adding Validate_ISPN to the
dependencies list.



git-svn-id: https://svn.php.net/repository/pear/packages/File_MARC/trunk@324943 c90b9560-bf6c-de11-be94-00142212c4b1
commit 257f5034476d251a7dd6ed3c27b53b4741b3051a 1 parent ddf43e7
Dan Scott authored
3,750 File/MARC/Lint.php
View
3,750 additions, 0 deletions not shown
166 File/MARC/Lint/CodeData.php
View
@@ -0,0 +1,166 @@
+<?php
+
+/* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 foldmethod=marker: */
+
+/**
+ * Code Data to support Lint for MARC records
+ *
+ * This module is adapted from the MARC::Lint::CodeData CPAN module for Perl,
+ * maintained by Bryan Baldus <eijabb@cpan.org> and available for download at
+ * http://search.cpan.org/~eijabb/
+ *
+ * Current MARC::Lint::CodeData version used as basis for this module: 1.28
+ *
+ * PHP version 5
+ *
+ * LICENSE: This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category File_Formats
+ * @package File_MARC
+ * @author Demian Katz <demian.katz@villanova.edu>
+ * @author Dan Scott <dscott@laurentian.ca>
+ * @copyright 2003-2008 Oy Realnode Ab, Dan Scott
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ * @version CVS: $Id: Record.php 308146 2011-02-08 20:36:20Z dbs $
+ * @link http://pear.php.net/package/File_MARC
+ */
+
+// {{{ class File_MARC_Lint
+/**
+ * Contains codes from the MARC code lists for Geographic Areas, Languages, and
+ * Countries.
+ *
+ * Code data is used for validating fields 008, 040, 041, and 043.
+ *
+ * Also, sources for subfield 2 in 600-651 and 655.
+ *
+ * Note: According to the official MARC documentation, Sears is not a valid 655
+ * term. The code data below treats it as valid, in anticipation of a change in
+ * the official documentation.
+ *
+ * @category File_Formats
+ * @package File_MARC
+ * @author Demian Katz <demian.katz@villanova.edu>
+ * @author Dan Scott <dscott@laurentian.ca>
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ * @link http://pear.php.net/package/File_MARC
+ */
+class File_MARC_Lint_CodeData
+{
+
+ // {{{ properties
+ /**
+ * Valid Geographic Area Codes
+ * @var array
+ */
+ public $geogAreaCodes;
+
+ /**
+ * Obsolete Geographic Area Codes
+ * @var array
+ */
+ public $obsoleteGeogAreaCodes;
+
+ /**
+ * Valid Language Codes
+ * @var array
+ */
+ public $languageCodes;
+
+ /**
+ * Obsolete Language Codes
+ * @var array
+ */
+ public $obsoleteLanguageCodes;
+
+ /**
+ * Valid Country Codes
+ * @var array
+ */
+ public $countryCodes;
+
+ /**
+ * Obsolete Country Codes
+ * @var array
+ */
+ public $obsoleteCountryCodes;
+
+ /**
+ * Valid sources for fields 600-651
+ * @var array
+ */
+ public $sources600_651;
+
+ /**
+ * Obsolete sources for fields 600-651
+ * @var array
+ */
+ public $obsoleteSources600_651;
+
+ /**
+ * Valid sources for field 655
+ * @var array
+ */
+ public $sources655;
+
+ /**
+ * Obsolete sources for field 655
+ * @var array
+ */
+ public $obsoleteSources655;
+
+ // }}}
+
+ // {{{ Constructor: function __construct()
+ /**
+ * Start function
+ *
+ * Initialize code arrays.
+ *
+ * @return true
+ */
+ public function __construct()
+ {
+ // @codingStandardsIgnoreStart
+ // fill the valid Geographic Area Codes array
+ $this->geogAreaCodes = explode("\t", "a-af--- f------ fc----- fe----- fq----- ff----- fh----- fs----- fb----- fw----- n-us-al n-us-ak e-aa--- n-cn-ab f-ae--- ea----- sa----- poas--- aa----- sn----- e-an--- f-ao--- nwxa--- a-cc-an t------ nwaq--- nwla--- n-usa-- ma----- ar----- au----- r------ s-ag--- n-us-az n-us-ar a-ai--- nwaw--- lsai--- u-ac--- a------ ac----- as----- l------ fa----- u------ u-at--- u-at-ac e-au--- a-aj--- lnaz--- nwbf--- a-ba--- ed----- eb----- a-bg--- nwbb--- a-cc-pe e-bw--- e-be--- ncbh--- el----- ab----- f-dm--- lnbm--- a-bt--- mb----- a-ccp-- s-bo--- nwbn--- a-bn--- e-bn--- f-bs--- lsbv--- s-bl--- n-cn-bc i-bi--- nwvb--- a-bx--- e-bu--- f-uv--- a-br--- f-bd--- n-us-ca a-cb--- f-cm--- n-cn--- nccz--- lnca--- lncv--- cc----- poci--- ak----- e-urk-- e-urr-- nwcj--- f-cx--- nc----- e-urc-- f-cd--- s-cl--- a-cc--- a-cc-cq i-xa--- i-xb--- q------ s-ck--- n-us-co b------ i-cq--- f-cf--- f-cg--- fg----- n-us-ct pocw--- u-cs--- nccr--- e-ci--- nwcu--- nwco--- a-cy--- e-xr--- e-cs--- f-iv--- eo----- zd----- n-us-de e-dk--- dd----- d------ f-ft--- nwdq--- nwdr--- x------ n-usr-- ae----- an----- a-em--- poea--- xa----- s-ec--- f-ua--- nces--- e-uk-en f-eg--- f-ea--- e-er--- f-et--- me----- e------ ec----- ee----- en----- es----- ew----- lsfk--- lnfa--- pofj--- e-fi--- n-us-fl e-fr--- h------ s-fg--- pofp--- a-cc-fu f-go--- pogg--- f-gm--- a-cc-ka awgz--- n-us-ga a-gs--- e-gx--- e-ge--- e-gw--- f-gh--- e-gi--- e-uk--- e-uk-ui nl----- np----- fr----- e-gr--- n-gl--- nwgd--- nwgp--- pogu--- a-cc-kn a-cc-kc ncgt--- f-gv--- f-pg--- a-cc-kw s-gy--- a-cc-ha nwht--- n-us-hi i-hm--- a-cc-hp a-cc-he a-cc-ho ah----- nwhi--- ncho--- a-cc-hk a-cc-hh n-cnh-- a-cc-hu e-hu--- e-ic--- n-us-id n-us-il a-ii--- i------ n-us-in ai----- a-io--- a-cc-im m------ c------ n-us-ia a-ir--- a-iq--- e-ie--- a-is--- e-it--- nwjm--- lnjn--- a-ja--- a-cc-ku a-cc-ki a-cc-kr poji--- a-jo--- zju---- n-us-ks a-kz--- n-us-ky f-ke--- poki--- pokb--- a-kr--- a-kn--- a-ko--- a-cck-- a-ku--- a-kg--- a-ls--- cl----- e-lv--- a-le--- nwli--- f-lo--- a-cc-lp f-lb--- f-ly--- e-lh--- poln--- e-li--- n-us-la e-lu--- a-cc-mh e-xn--- f-mg--- lnma--- n-us-me f-mw--- am----- a-my--- i-xc--- f-ml--- e-mm--- n-cn-mb poxd--- n-cnm-- zma---- poxe--- nwmq--- n-us-md n-us-ma f-mu--- i-mf--- i-my--- mm----- ag----- pome--- zme---- n-mx--- nm----- n-us-mi pott--- pomi--- n-usl-- aw----- n-usc-- poxf--- n-us-mn n-us-ms n-usm-- n-us-mo n-uss-- e-mv--- e-mc--- a-mp--- n-us-mt nwmj--- zmo---- f-mr--- f-mz--- f-sx--- ponu--- n-us-nb a-np--- zne---- e-ne--- nwna--- n-us-nv n-cn-nk ponl--- n-usn-- a-nw--- n-us-nh n-us-nj n-us-nm u-at-ne n-us-ny u-nz--- n-cn-nf ncnq--- f-ng--- fi----- f-nr--- fl----- a-cc-nn poxh--- n------ ln----- n-us-nc n-us-nd pn----- n-use-- xb----- e-uk-ni u-at-no n-cn-nt e-no--- n-cn-ns n-cn-nu po----- n-us-oh n-uso-- n-us-ok a-mk--- n-cn-on n-us-or zo----- p------ a-pk--- popl--- ncpn--- a-pp--- aopf--- s-py--- n-us-pa ap----- s-pe--- a-ph--- popc--- zpl---- e-pl--- pops--- e-po--- n-cnp-- n-cn-pi nwpr--- ep----- a-qa--- a-cc-ts u-at-qn n-cn-qu mr----- er----- n-us-ri sp----- nr----- e-rm--- e-ru--- e-ur--- e-urf-- f-rw--- i-re--- nwsd--- fd----- nweu--- lsxj--- nwxi--- nwxk--- nwst--- n-xl--- nwxm--- pows--- posh--- e-sm--- f-sf--- n-cn-sn zsa---- a-su--- ev----- e-uk-st f-sg--- i-se--- a-cc-ss a-cc-sp a-cc-sm a-cc-sh e-urs-- e-ure-- e-urw-- a-cc-sz f-sl--- a-si--- e-xo--- e-xv--- i-xo--- zs----- pobp--- f-so--- f-sa--- s------ az----- ls----- u-at-sa n-us-sc ao----- n-us-sd lsxs--- ps----- xc----- n-usu-- n-ust-- e-urn-- e-sp--- f-sh--- aoxp--- a-ce--- f-sj--- fn----- fu----- zsu---- s-sr--- lnsb--- nwsv--- f-sq--- e-sw--- e-sz--- a-sy--- a-ch--- a-ta--- f-tz--- u-at-tm n-us-tn i-fs--- n-us-tx a-th--- af----- a-cc-tn a-cc-ti at----- f-tg--- potl--- poto--- nwtr--- lstd--- w------ f-ti--- a-tu--- a-tk--- nwtc--- potv--- f-ug--- e-un--- a-ts--- n-us--- nwuc--- poup--- e-uru-- zur---- s-uy--- n-us-ut a-uz--- ponn--- e-vc--- s-ve--- zve---- n-us-vt u-at-vi a-vt--- nwvi--- n-us-va e-urp-- fv----- powk--- e-uk-wl powf--- n-us-dc n-us-wa n-usp-- awba--- nw----- n-us-wv u-at-we xd----- f-ss--- nwwi--- n-us-wi n-us-wy a-ccs-- a-cc-su a-ccg-- a-ccy-- ay----- a-ye--- e-yu--- n-cn-yk a-cc-yu fz----- f-za--- a-cc-ch f-rh--- u-atc-- u-ate-- u-atn-- e-rb--- e-mo--- e-kv---");
+
+ // fill the obsolete Geographic Area Codes array
+ $this->obsoleteGeogAreaCodes = explode("\t", "t-ay--- e-ur-ai e-ur-aj nwbc--- e-ur-bw f-by--- pocp--- e-url-- cr----- v------ e-ur-er et----- e-ur-gs pogn--- nwga--- nwgs--- a-hk--- ei----- f-if--- awiy--- awiw--- awiu--- e-ur-kz e-ur-kg e-ur-lv e-ur-li a-mh--- cm----- e-ur-mv n-usw-- a-ok--- a-pt--- e-ur-ru pory--- nwsb--- posc--- a-sk--- posn--- e-uro-- e-ur-ta e-ur-tk e-ur-un e-ur-uz a-vn--- a-vs--- nwvr--- e-urv-- a-ys---");
+
+ // fill the valid Language Codes array
+ $this->languageCodes = explode("\t", " aar abk ace ach ada ady afa afh afr ain aka akk alb ale alg alt amh ang anp apa ara arc arg arm arn arp art arw asm ast ath aus ava ave awa aym aze bad bai bak bal bam ban baq bas bat bej bel bem ben ber bho bih bik bin bis bla bnt bos bra bre btk bua bug bul bur byn cad cai car cat cau ceb cel cha chb che chg chi chk chm chn cho chp chr chu chv chy cmc cop cor cos cpe cpf cpp cre crh crp csb cus cze dak dan dar day del den dgr din div doi dra dsb dua dum dut dyu dzo efi egy eka elx eng enm epo est ewe ewo fan fao fat fij fil fin fiu fon fre frm fro frr frs fry ful fur gaa gay gba gem geo ger gez gil gla gle glg glv gmh goh gon gor got grb grc gre grn gsw guj gwi hai hat hau haw heb her hil him hin hit hmn hmo hrv hsb hun hup iba ibo ice ido iii ijo iku ile ilo ina inc ind ine inh ipk ira iro ita jav jbo jpn jpr jrb kaa kab kac kal kam kan kar kas kau kaw kaz kbd kha khi khm kho kik kin kir kmb kok kom kon kor kos kpe krc krl kro kru kua kum kur kut lad lah lam lao lat lav lez lim lin lit lol loz ltz lua lub lug lui lun luo lus mac mad mag mah mai mak mal man mao map mar mas may mdf mdr men mga mic min mis mkh mlg mlt mnc mni mno moh mon mos mul mun mus mwl mwr myn myv nah nai nap nau nav nbl nde ndo nds nep new nia nic niu nno nob nog non nor nqo nso nub nwc nya nym nyn nyo nzi oci oji ori orm osa oss ota oto paa pag pal pam pan pap pau peo per phi phn pli pol pon por pra pro pus que raj rap rar roa roh rom rum run rup rus sad sag sah sai sal sam san sas sat scn sco sel sem sga sgn shn sid sin sio sit sla slo slv sma sme smi smj smn smo sms sna snd snk sog som son sot spa srd srn srp srr ssa ssw suk sun sus sux swa swe syc syr tah tai tam tat tel tem ter tet tgk tgl tha tib tig tir tiv tkl tlh tli tmh tog ton tpi tsi tsn tso tuk tum tup tur tut tvl twi tyv udm uga uig ukr umb und urd uzb vai ven vie vol vot wak wal war was wel wen wln wol xal xho yao yap yid yor ypk zap zbl zen zha znd zul zun zxx zza");
+
+ // fill the obsolete Language Codes array
+ $this->obsoleteLanguageCodes = explode("\t", "ajm esk esp eth far fri gag gua int iri cam kus mla max mol lan gal lap sao gae scc scr sho snh sso swz tag taj tar tru tsw");
+
+ // fill the valid Country Codes array
+ $this->countryCodes = explode("\t", "aca af alu aku aa abc ae as an ao am ay aq ag azu aru ai aw at au aj bf ba bg bb bw be bh dm bm bt bo bn bs bv bl bcc bi vb bx bu uv br bd cau cb cm xxc cv cj cx cd cl cc ch xa xb ck cou cq cf cg ctu cw cr ci cu cy xr iv deu dk dcu ft dq dr em ec ua es enk eg ea er et fk fa fj fi flu fr fg fp go gm gz gau gs gw gh gi gr gl gd gp gu gt gv pg gy ht hiu hm ho hu ic idu ilu ii inu io iau ir iq iy ie is it jm ja ji jo ksu kv kz kyu ke gb kn ko ku kg ls lv le lo lb ly lh li lau lu xn mg meu mw my xc ml mm mbc xe mq mdu mau mu mf ot mx miu fm xf mnu msu mou mv mc mp mtu mj mr mz sx nu nbu np ne na nvu nkc nl nhu nju nmu nyu nz nfc nq ng nr xh xx nx ncu ndu nik nw ntc no nsc nuc ohu oku mk onc oru pk pw pn pp pf py pau pe ph pc pl po pic pr qa qea quc riu rm ru rw re xj xd xk xl xm ws sm sf snc su stk sg rb mo se sl si xo xv bp so sa scu sdu xs sp sh xp ce sj sr sq sw sz sy ta tz tnu fs txu th tg tl tma to tr ti tu tk tc tv ug un ts xxk uik xxu uc up uy utu uz nn vp vc ve vtu vm vi vau vra wea wk wlk wf wau wj wvu ss wiu wyu xga xna xoa xra ye ykc za rh ");
+
+ // fill the obsolete Country Codes array
+ $this->obsoleteCountryCodes = explode("\t", "ai air ac ajr bwr cn cz cp ln cs err gsr ge gn hk iw iu jn kzr kgr lvr lir mh mvr nm pt rur ry xi sk xxr sb sv tar tt tkr unr uk ui us uzr vn vs wb ys yu ");
+
+ // the codes cash, lcsh, lcshac, mesh, nal, and rvm are covered by 2nd
+ // indicators in 600-655
+ // they are only used when indicators are not available
+ $this->sources600_651 = explode("\t", "aass aat abne afset agrifors agrovoc agrovocf agrovocs aiatsisl aiatsisp aiatsiss aktp albt allars amg apaist asft asrcrfcd asrcseo asrctoa asth atla aucsh barn bella bet bgtchm bhammf bhashe bibalex biccbmc bicssc bidex bisacsh bisacmt bisacrt blmlsh bt cabt cash cct ccte cctf ceeus chirosh cht ciesiniv cilla conorsi csahssa csalsct csapa csh csht cstud czenas dacs dcs ddcrit dissao dit drama dtict ebfem eclas eet eflch eks embne ept ericd est eurovocen eurovocsl fast fgtpcm finmesh fire fmesh fnhl francis galestne gem georeft gst gtt hapi hkcan helecon henn hlasstg hoidokki huc iaat ica icpsr idas iescs iest ilot ilpt inist inspect ipat ipsp isis itglit itoamc itrt jhpb jhpk jlabsh kaa kao kaunokki kdm kitu kkts kssbar kta ktpt ktta kula kupu lacnaf larpcal lcsh lcshac lcstt lctgm lemac lemb liv lnmmbr local ltcsh lua maaq mar masa mech mesh mipfesd mmm mpirdes msh mtirdes musa muzeukc muzeukn muzeukv muzvukci nal nalnaf nasat ncjt ndllsh nicem nimacsc nlgaf nlgkk nlgsh nlmnaf nsbncf ntcpsc ntcsd ntissc nzggn nznb ogst onet opms pascal peri pha pkk pmbok pmcsg pmt poliscit popinte precis prvt psychit quiding qlsp qrma qrmak qtglit raam ram rasuqam renib reo rero rerovoc reveal rma rpe rswk rswkaf rugeo rurkp rvm sao sbiao scbi scgdst scisshl scot sears sfit sgc sgce shbe she sigle sipri sk skon slem smda snt socio sosa spines ssg swd swemesh taika taxhs tbit tesa test tgn tho thub tlka tlsh toit trt trtsa tsht ttka tucua ulan umitrist unbisn unbist unescot usaidt vmj waqaf watrest wgst wot wpicsh ysa");
+ $this->obsoleteSources600_651 = explode("\t", "cash lcsh lcshac mesh nal reroa rvm");
+ $this->sources655 = explode("\t", "aat afset aiatsisl aiatsisp aiatsiss aktp amg asrcrfcd asrcseo asrctoa asth aucsh barn bibalex biccbmc bgtchm bisacsh bisacmt bisacrt bt cash chirosh cct conorsi csht czenas dacs dcs dct eet eflch embne ept ericd estc eurovocen eurovocsl fast fbg finmesh fire galestne gem gmgpc gsafd gst gtlm hapi hkcan hoidokki ica ilot itglit itrt jhpb jhpk kkts lacnaf lcsh lcshac lcstt lctgm lemac local maaq mar marcgt mech mesh migfg mim msh muzeukc muzeukn muzeukv muzvukci nal nalnaf ngl nimafc nlgaf nlgkk nlgsh nlmnaf nmc nsbncf nzggn nznb onet opms pkk pmcsg pmt quiding qlsp qrmak qtglit raam radfg rbbin rbgenr rbpap rbpri rbprov rbpub rbtyp reo rerovoc reveal rma rswk rswkaf rugeo rvm sao scbi sears sgc sgce sgp sipri skon snt socio spines ssg swd swemesh tbit tesa tho thub toit tsht tucua ulan vmj waqaf");
+ $this->obsoleteSources655 = explode("\t", "cash ftamc lcsh lcshac mesh nal reroa rvm");
+ // @codingStandardsIgnoreEnd
+ }
+ // }}}
+}
+// }}}
24 package.xml
View
@@ -19,10 +19,10 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<email>dbs@php.net</email>
<active>yes</active>
</lead>
- <date>2011-02-08</date>
+ <date>2012-04-07</date>
<version>
- <release>0.6.2</release>
- <api>0.6.0</api>
+ <release>0.7.0</release>
+ <api>0.7.0</api>
</version>
<stability>
<release>beta</release>
@@ -30,8 +30,8 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">GNU Lesser General Public License</license>
<notes>
-0.6.2-beta
- * Improve handling of bad leader data, including declared length and overly long leaders in MARCXML
+0.7.0-beta
+ * Add MARC lint support (thanks to Demian Katz - demian.katz@villanova.edu)
</notes>
<contents>
<dir name="/" baseinstalldir="File">
@@ -46,9 +46,13 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<file name="Data_Field.php" role="php" />
<file name="Exception.php" role="php" />
<file name="Field.php" role="php" />
+ <file name="Lint.php" role="php" />
<file name="List.php" role="php" />
<file name="Record.php" role="php" />
<file name="Subfield.php" role="php" />
+ <dir name="Lint">
+ <file name="CodeData.php" role="php" />
+ </dir>
</dir>
</dir>
<dir name="examples">
@@ -60,6 +64,7 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<dir name="tests">
<file name="bad_example.mrc" role="test" />
<file name="bad_example.xml" role="test" />
+ <file name="camel.mrc" role="test" />
<file name="example.mrc" role="test" />
<file name="marc_001.phpt" role="test" />
<file name="marc_002.phpt" role="test" />
@@ -84,6 +89,11 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<file name="marc_field_002.phpt" role="test" />
<file name="marc_field_003.phpt" role="test" />
<file name="marc_field_004.phpt" role="test" />
+ <file name="marc_lint_001.phpt" role="test" />
+ <file name="marc_lint_002.phpt" role="test" />
+ <file name="marc_lint_003.phpt" role="test" />
+ <file name="marc_lint_004.phpt" role="test" />
+ <file name="marc_lint_005.phpt" role="test" />
<file name="marc_record_001.phpt" role="test" />
<file name="marc_subfield_001.phpt" role="test" />
<file name="marc_subfield_002.phpt" role="test" />
@@ -121,6 +131,10 @@ This package is based on the PHP MARC package, originally called "php-marc", tha
<name>Structures_LinkedList</name>
<channel>pear.php.net</channel>
</package>
+ <package>
+ <name>Validate_ISPN</name>
+ <channel>pear.php.net</channel>
+ </package>
</required>
</dependencies>
<phprelease>
1  tests/camel.mrc
View
@@ -0,0 +1 @@
+00755cam 22002414a 4500001001300000003000600013005001700019008004100036010001700077020004300094040001800137042000800155050002600163082001700189100003100206245005400237260004200291300007200333500003300405650003700438630002500475630001300500fol05731351 IMchF20000613133448.0000107s2000 nyua 001 0 eng  a 00020737  a0471383147 (paper/cd-rom : alk. paper) aDLCcDLCdDLC apcc00aQA76.73.P22bM33 200000a005.13/32211 aMartinsson, Tobias,d1976-10aActivePerl with ASP and ADO /cTobias Martinsson. aNew York :bJohn Wiley & Sons,c2000. axxi, 289 p. :bill. ;c23 cm. +e1 computer laser disc (4 3/4 in.) a"Wiley Computer Publishing." 0aPerl (Computer program language)00aActive server pages.00aActiveX.00647pam 2200241 a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002600135082001500161100002600176245006700202260003800269263000900307300001100316650003700327650002500364700001600389fol05754809 IMchF20000601115601.0000203s2000 mau 001 0 eng  a 00022023  a1565926994 aDLCcDLCdDLC apcc00aQA76.73.P22bD47 200000a005.742211 aDescartes, Alligator.10aProgramming the Perl DBI /cAlligator Descartes and Tim Bunce. aCmabridge, MA :bO'Reilly,c2000. a1111 ap. cm. 0aPerl (Computer program language) 0aDatabase management.1 aBunce, Tim.00605cam 22002054a 4500001001300000003000600013005001700019008004100036010001700077040001800094042000800112050002700120082001700147100002100164245005500185260004500240300002600285504005100311650003700362fol05843555 IMchF20000525142739.0000318s1999 cau b 001 0 eng  a 00501349  aDLCcDLCdDLC apcc00aQA76.73.P22bB763 199900a005.13/32211 aBrown, Martin C.10aPerl :bprogrammer's reference /cMartin C. Brown. aBerkeley :bOsborne/McGraw-Hill,cc1999. axix, 380 p. ;c22 cm. aIncludes bibliographical references and index. 0aPerl (Computer program language)00579cam 22002054a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002700135082001700162100002100179245005500200260004500255300003600300650003700336fol05843579 IMchF20000525142716.0000318s1999 caua 001 0 eng  a 00502116  a0072120002 aDLCcDLCdDLC apcc00aQA76.73.P22bB762 199900a005.13/32211 aBrown, Martin C.10aPerl :bthe complete reference /cMartin C. Brown. aBerkeley :bOsborne/McGraw-Hill,cc1999. axxxv, 1179 p. :bill. ;c24 cm. 0aPerl (Computer program language)00801nam 22002778a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001800156100002000174245008800194250003200282260004100314263000900355300001100364650003700375650003600412650002600448700002500474700002400499fol05848297 IMchF20000524125727.0000518s2000 mau 001 0 eng  a 00041664  a1565924193 aDLCcDLC apcc00aQA76.73.P22bG84 200000a005.2/7622211 aGuelich, Scott.10aCGI programming with Perl /cScott Guelich, Shishir Gundavaram & Gunther Birznieks. a2nd ed., expanded & updated aCambridge, Mass. :bO'Reilly,c2000. a0006 ap. cm. 0aPerl (Computer program language) 0aCGI (Computer network protocol) 0aInternet programming.1 aGundavaram, Shishir.1 aBirznieks, Gunther.00665nam 22002298a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002700130082001700157111005200174245008600226250001200312260004100324263000900365300001100374650005000385fol05865950 IMchF20000615103017.0000612s2000 mau 100 0 eng  a 00055759  a0596000138 aDLCcDLC apcc00aQA76.73.P22bP475 200000a005.13/32212 aPerl Conference 4.0d(2000 :cMonterey, Calif.)10aProceedings of the Perl Conference 4.0 :bJuly 17-20, 2000, Monterey, California. a1st ed. aCambridge, Mass. :bO'Reilly,c2000. a0006 ap. cm. 0aPerl (Computer program language)vCongresses.00579nam 22002178a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001700156100002800173245006200201260004100263263000900304300001100313650003700324fol05865956 IMchF20000615102948.0000612s2000 mau 000 0 eng  a 00055770  a1565926099 aDLCcDLC apcc00aQA76.73.P22bB43 200000a005.13/32211 aBlank-Edelman, David N.10aPerl for system administration /cDavid N. Blank-Edelman. aCambridge, Mass. :bO'Reilly,c2000. a0006 ap. cm. 0aPerl (Computer program language)00661nam 22002538a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001700156100001700173245006700190250001200257260004100269263000900310300001100319650003700330700002300367700001700390fol05865967 IMchF20000615102611.0000614s2000 mau 000 0 eng  a 00055799  a0596000278 aDLCcDLC apcc00aQA76.73.P22bW35 200000a005.13/32211 aWall, Larry.10aProgramming Perl /cLarry Wall, Tom Christiansen & Jon Orwant. a3rd ed. aCambridge, Mass. :bO'Reilly,c2000. a0007 ap. cm. 0aPerl (Computer program language)1 aChristiansen, Tom.1 aOrwant, Jon.00603cam 22002054a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002600135082001700161100003200178245006000210260005700270300003300327650003700360fol05872355 IMchF20000706095105.0000315s1999 njua 001 0 eng  a 00500678  a013020868X aDLCcDLCdDLC apcc00aQA76.73.P22bL69 199900a005.13/32211 aLowe, Vincentq(Vincent D.)10aPerl programmer's interactive workbook /cVincent Lowe. aUpper Saddle River, NJ :bPrentice Hall PTP,cc1999. axx, 633 p. :bill. ;c23 cm. 0aPerl (Computer program language)00696nam 22002538a 4500001001300000003000600013005001700019008004100036010001700077020002800094040001300122042000800135050002600143082001700169100002600186245004400212260005100256263000900307300001100316500002000327650003700347650001700384650004100401fol05882032 IMchF20000707091904.0000630s2000 cau 001 0 eng  a 00058174  a0764547291 (alk. paper) aDLCcDLC apcc00aQA76.73.P22bF64 200000a005.13/32212 aFoster-Johnson, Eric.10aCross-platform Perl /cEric F. Johnson. aFoster City, CA :bIDG Books Worldwide,c2000. a0009 ap. cm. aIncludes index. 0aPerl (Computer program language) 0aWeb servers. 0aCross-platform software development.00399ngm 2200121 a 4500001001300000003000700013007002800020008004100048245005600089260003800145300006000183538003400243ttt05000099 TEST avbfc dcebfaghhoiu050224s2005 ilu999 vleng d00aTest subfields in control fieldsh[videorecording]. aOregon, Ill. :bB. Baldus,c2005. a1 videocassette (ca. 1000 min.) :bsd., col. ;c1/2 in. aVHS format, SP playback mode.
184 tests/marc_lint_001.phpt
View
@@ -0,0 +1,184 @@
+--TEST--
+marc_lint_001: Full test of Lint suite
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+$dir = dirname(__FILE__);
+require 'File/MARC.php';
+require 'File/MARC/Lint.php';
+$marc_lint = new File_MARC_Lint();
+
+print "Test records in camel.mrc\n";
+$marc_file = new File_MARC($dir . '/' . 'camel.mrc');
+while ($marc_record = $marc_file->next()) {
+ $warnings = $marc_lint->checkRecord($marc_record);
+ foreach ($warnings as $warning) {
+ print $warning . "\n";
+ }
+}
+
+print "\nTest from a constructed record\n";
+$rec = new File_MARC_Record();
+$rec->setLeader("00000nam 22002538a 4500");
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '041',
+ array(
+ new File_MARC_Subfield('a', 'end'),
+ new File_MARC_Subfield('a', 'fren')
+ ),
+ "0", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '043',
+ array(
+ new File_MARC_Subfield('a', 'n-us-pn')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '082',
+ array(
+ new File_MARC_Subfield('a', '005.13/3'),
+ // typo 'R' for 'W' and missing 'b' subfield
+ new File_MARC_Subfield('R', 'all'),
+ new File_MARC_Subfield('2', '21')
+ ),
+ "0", "4"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '082',
+ array(
+ new File_MARC_Subfield('a', '005.13'),
+ new File_MARC_Subfield('b', 'Wall'),
+ new File_MARC_Subfield('2', '14')
+ ),
+ "1", "4"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '100',
+ array(
+ new File_MARC_Subfield('a', 'Wall, Larry')
+ ),
+ "1", "4"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '110',
+ array(
+ new File_MARC_Subfield('a', "O'Reilly & Associates.")
+ ),
+ "1", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '245',
+ array(
+ new File_MARC_Subfield('a', 'Programming Perl / '),
+ new File_MARC_Subfield('a', 'Big Book of Perl /'),
+ new File_MARC_Subfield('c', 'Larry Wall, Tom Christiansen & Jon Orwant.')
+ ),
+ "9", "0"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '250',
+ array(
+ new File_MARC_Subfield('a', '3rd ed.')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '250',
+ array(
+ new File_MARC_Subfield('a', '3rd ed.')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '260',
+ array(
+ new File_MARC_Subfield('a', 'Cambridge, Mass. : '),
+ new File_MARC_Subfield('b', "O'Reilly, "),
+ new File_MARC_Subfield('r', '2000.')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '590',
+ array(
+ new File_MARC_Subfield('a', 'Personally signed by Larry.')
+ ),
+ "4", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '650',
+ array(
+ new File_MARC_Subfield('a', 'Perl (Computer program language)'),
+ new File_MARC_Subfield('0', '(DLC)sh 95010633')
+ ),
+ "", "0"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '856',
+ array(
+ new File_MARC_Subfield('u', 'http://www.perl.com/')
+ ),
+ "4", "3"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '886',
+ array(
+ new File_MARC_Subfield('4', 'Some foreign thing'),
+ new File_MARC_Subfield('q', 'Another foreign thing')
+ ),
+ "0", ""
+ )
+);
+$warnings = $marc_lint->checkRecord($rec);
+foreach ($warnings as $warning) {
+ print $warning . "\n";
+}
+
+?>
+--EXPECT--
+Test records in camel.mrc
+100: Indicator 1 must be 0, 1 or 3 but it's "2"
+007: Subfields are not allowed in fields lower than 010
+
+Test from a constructed record
+1XX: Only one 1XX tag is allowed, but I found 2 of them.
+041: Subfield _a, end (end), is not valid.
+041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (fren).
+043: Subfield _a, n-us-pn, is not valid.
+082: Subfield _R is not allowed.
+100: Indicator 2 must be blank but it's "4"
+245: Indicator 1 must be 0 or 1 but it's "9"
+245: Subfield _a is not repeatable.
+250: Field is not repeatable.
+260: Subfield _r is not allowed.
+856: Indicator 2 must be blank, 0, 1, 2 or 8 but it's "3"
78 tests/marc_lint_002.phpt
View
@@ -0,0 +1,78 @@
+--TEST--
+marc_lint_002: Tests check041() and check043() called separately
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+$dir = dirname(__FILE__);
+require 'File/MARC.php';
+require 'File/MARC/Lint.php';
+
+// Create test harness to allow direct calls to check methods:
+class File_MARC_Lint_Test_Harness extends File_MARC_Lint
+{
+ public function check041($field)
+ {
+ return parent::check041($field);
+ }
+
+ public function check043($field)
+ {
+ return parent::check043($field);
+ }
+
+ // override warn method to echo instead of store in object:
+ protected function warn($msg)
+ {
+ echo $msg . "\n";
+ }
+}
+
+$marc_lint = new File_MARC_Lint_Test_Harness();
+
+$field = new File_MARC_Data_Field(
+ '041',
+ array(
+ new File_MARC_Subfield('a', 'end'), // invalid
+ new File_MARC_Subfield('a', 'span'), // too long
+ new File_MARC_Subfield('h', 'far') // obsolete
+ ),
+ "0", ""
+);
+$marc_lint->check041($field);
+
+$field = new File_MARC_Data_Field(
+ '041',
+ array(
+ new File_MARC_Subfield('a', 'endorviwo'), // invalid
+ new File_MARC_Subfield('a', 'spanowpalasba') // too long and invalid
+ ),
+ "1", ""
+);
+$marc_lint->check041($field);
+
+$field = new File_MARC_Data_Field(
+ '043',
+ array(
+ new File_MARC_Subfield('a', 'n-----'), // 6 chars vs. 7
+ new File_MARC_Subfield('a', 'n-us----'), // 8 chars vs. 7
+ new File_MARC_Subfield('a', 'n-ma-us'), // invalid code
+ new File_MARC_Subfield('a', 'e-ur-ai') // obsolete code
+ ),
+ "", ""
+);
+$marc_lint->check043($field);
+
+?>
+--EXPECT--
+041: Subfield _a, end (end), is not valid.
+041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (span).
+041: Subfield _h, far, may be obsolete.
+041: Subfield _a, endorviwo (end), is not valid.
+041: Subfield _a, endorviwo (orv), is not valid.
+041: Subfield _a, endorviwo (iwo), is not valid.
+041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (spanowpalasba).
+043: Subfield _a must be exactly 7 characters, n-----
+043: Subfield _a must be exactly 7 characters, n-us----
+043: Subfield _a, n-ma-us, is not valid.
+043: Subfield _a, e-ur-ai, may be obsolete.
126 tests/marc_lint_003.phpt
View
@@ -0,0 +1,126 @@
+--TEST--
+marc_lint_003: Tests for field 880 and for subfield 6
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+$dir = dirname(__FILE__);
+require 'File/MARC.php';
+require 'File/MARC/Lint.php';
+$marc_lint = new File_MARC_Lint();
+
+$rec = new File_MARC_Record();
+$rec->setLeader("00000nam 22002538a 4500");
+$rec->appendField(
+ new File_MARC_Control_Field(
+ '001', 'ttt07000001 '
+ )
+);
+$rec->appendField(
+ new File_MARC_Control_Field(
+ '003', 'TEST '
+ )
+);
+$rec->appendField(
+ new File_MARC_Control_Field(
+ '008', '070520s2007 ilu 000 0 eng d'
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '040',
+ array(
+ new File_MARC_Subfield('a', 'TEST'),
+ new File_MARC_Subfield('c', 'TEST')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '050',
+ array(
+ new File_MARC_Subfield('a', 'RZ999'),
+ new File_MARC_Subfield('b', '.J66 2007')
+ ),
+ "", "4"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '082',
+ array(
+ new File_MARC_Subfield('a', '615.8/9'),
+ new File_MARC_Subfield('2', '22')
+ ),
+ "0", "4"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '100',
+ array(
+ new File_MARC_Subfield('a', 'Jones, John')
+ ),
+ "1", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '245',
+ array(
+ new File_MARC_Subfield('6', '880-02'),
+ new File_MARC_Subfield('a', 'Test 880.')
+ ),
+ "1", "0"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '260',
+ array(
+ new File_MARC_Subfield('a', 'Mount Morris, Ill. :'),
+ new File_MARC_Subfield('b', "B. Baldus,"),
+ new File_MARC_Subfield('c', '2007.')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '300',
+ array(
+ new File_MARC_Subfield('a', '1 v. ;'),
+ new File_MARC_Subfield('c', '23 cm.')
+ ),
+ "", ""
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '880',
+ array(
+ new File_MARC_Subfield('6', '245-02/$1'),
+ new File_MARC_Subfield('a', '<Title in CJK script>.')
+ ),
+ "1", "0"
+ )
+);
+$rec->appendField(
+ new File_MARC_Data_Field(
+ '880',
+ array(
+ new File_MARC_Subfield('6', '245-02/$1'),
+ new File_MARC_Subfield('a', 'Illegal duplicate field.')
+ ),
+ "1", "0"
+ )
+);
+$warnings = $marc_lint->checkRecord($rec);
+foreach ($warnings as $warning) {
+ print $warning . "\n";
+}
+
+?>
+--EXPECT--
+245: Field is not repeatable.
102 tests/marc_lint_004.phpt
View
@@ -0,0 +1,102 @@
+--TEST--
+marc_lint_004: Tests check_245() called separately
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+$dir = dirname(__FILE__);
+require 'File/MARC.php';
+require 'File/MARC/Lint.php';
+
+// Create test harness to allow direct calls to check methods:
+class File_MARC_Lint_Test_Harness extends File_MARC_Lint
+{
+ public function check245($field)
+ {
+ return parent::check245($field);
+ }
+
+ // override warn method to echo instead of store in object:
+ protected function warn($msg)
+ {
+ echo $msg . "\n";
+ }
+}
+
+$marc_lint = new File_MARC_Lint_Test_Harness();
+
+$testData = array(
+ array(245, '0', '0', 'a', 'Subfield a.'),
+ array(245, '0', '0', 'b', 'no subfield a.'),
+ array(245, '0', '0', 'a', 'No period at end'),
+ array(245, '0', '0', 'a', 'Other punctuation not followed by period!'),
+ array(245, '0', '0', 'a', 'Other punctuation not followed by period?'),
+ array(245, '0', '0', 'a', 'Precedes sub c', 'c', 'not preceded by space-slash.'),
+ array(245, '0', '0', 'a', 'Precedes sub c/', 'c', 'not preceded by space-slash.'),
+ array(245, '0', '0', 'a', 'Precedes sub c /', 'c', 'initials in sub c B. B.'),
+ array(245, '0', '0', 'a', 'Precedes sub c /', 'c', 'initials in sub c B.B. (no warning).'),
+ array(245, '0', '0', 'a', 'Precedes sub b', 'b', 'not preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub b=', 'b', 'not preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub b:', 'b', 'not preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub b;', 'b', 'not preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub b =', 'b', 'preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub b :', 'b', 'preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub b ;', 'b', 'preceded by proper punctuation.'),
+ array(245, '0', '0', 'a', 'Precedes sub h ', 'h', '[videorecording].'),
+ array(245, '0', '0', 'a', 'Precedes sub h-- ', 'h', '[videorecording] :', 'b', 'with elipses dash before h.'),
+ array(245, '0', '0', 'a', 'Precedes sub h-- ', 'h', 'videorecording :', 'b', 'without brackets around GMD.'),
+ array(245, '0', '0', 'a', 'Precedes sub n.', 'n', 'Number 1.'),
+ array(245, '0', '0', 'a', 'Precedes sub n', 'n', 'Number 2.'),
+ array(245, '0', '0', 'a', 'Precedes sub n.', 'n', 'Number 3.', 'p', 'Sub n has period not comma.'),
+ array(245, '0', '0', 'a', 'Precedes sub n.', 'n', 'Number 3,', 'p', 'Sub n has comma.'),
+ array(245, '0', '0', 'a', 'Precedes sub p.', 'p', 'Sub a has period.'),
+ array(245, '0', '0', 'a', 'Precedes sub p', 'p', 'Sub a has no period.'),
+ array(245, '0', 'a', 'a', 'Invalid filing indicator.'),
+ array(245, '0', '0', 'a', 'The article.'),
+ array(245, '0', '4', 'a', 'The article.'),
+ array(245, '0', '2', 'a', 'An article.'),
+ array(245, '0', '0', 'a', "L'article."),
+ array(245, '0', '2', 'a', 'A la mode.'),
+ array(245, '0', '5', 'a', 'The "quoted article".'),
+ array(245, '0', '5', 'a', 'The (parenthetical article).'),
+ array(245, '0', '6', 'a', '(The) article in parentheses).'),
+ array(245, '0', '9', 'a', "\"(The)\" 'article' in quotes and parentheses)."),
+ array(245, '0', '5', 'a', '[The supplied title].')
+);
+
+foreach ($testData as $current) {
+ $subfields = array();
+ for ($i = 3; $i < count($current); $i+=2) {
+ $subfields[] = new File_MARC_Subfield($current[$i], $current[$i+1]);
+ }
+
+ $field = new File_MARC_Data_Field(
+ $current[0], $subfields, $current[1], $current[2]
+ );
+ $marc_lint->check245($field);
+}
+
+?>
+--EXPECT--
+245: Must have a subfield _a.
+245: First subfield must be _a, but it is _b
+245: Must end with . (period).
+245: MARC21 allows ? or ! as final punctuation but LCRI 1.0C, Nov. 2003, requires period.
+245: MARC21 allows ? or ! as final punctuation but LCRI 1.0C, Nov. 2003, requires period.
+245: Subfield _c must be preceded by /
+245: Subfield _c must be preceded by /
+245: Subfield _c initials should not have a space.
+245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.
+245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.
+245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.
+245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign.
+245: Subfield _h should not be preceded by space.
+245: Subfield _h must have matching square brackets, videorecording :.
+245: Subfield _n must be preceded by . (period).
+245: Subfield _p must be preceded by , (comma) when it follows subfield _n.
+245: Subfield _p must be preceded by . (period) when it follows a subfield other than _n.
+245: Non-filing indicator is non-numeric
+245: First word, the, may be an article, check 2nd indicator (0).
+245: First word, an, may be an article, check 2nd indicator (2).
+245: First word, l, may be an article, check 2nd indicator (0).
+245: First word, a, does not appear to be an article, check 2nd indicator (2).
66 tests/marc_lint_005.phpt
View
@@ -0,0 +1,66 @@
+--TEST--
+marc_lint_005: Tests check_020() called separately
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+$dir = dirname(__FILE__);
+require 'File/MARC.php';
+require 'File/MARC/Lint.php';
+
+// Create test harness to allow direct calls to check methods:
+class File_MARC_Lint_Test_Harness extends File_MARC_Lint
+{
+ public function check020($field)
+ {
+ return parent::check020($field);
+ }
+
+ // override warn method to echo instead of store in object:
+ protected function warn($msg)
+ {
+ echo $msg . "\n";
+ }
+}
+
+$marc_lint = new File_MARC_Lint_Test_Harness();
+
+$testData = array(
+ array('a' => "154879473"), //too few digits
+ array('a' => "1548794743"), //invalid checksum
+ array('a' => "15487947443"), //11 digits
+ array('a' => "15487947443324"), //14 digits
+ array('a' => "9781548794743"), //13 digit valid
+ array('a' => "9781548794745"), //13 digit invalid
+ array('a' => "1548794740 (10 : good checksum)"), //10 digit valid with qualifier
+ array('a' => "1548794745 (10 : bad checksum)"), //10 digit invalid with qualifier
+ array('a' => "1-54879-474-0 (hyphens and good checksum)"), //10 digit invalid with hyphens and qualifier
+ array('a' => "1-54879-474-5 (hyphens and bad checksum)"), //10 digit invalid with hyphens and qualifier
+ array('a' => "1548794740(10 : unspaced qualifier)"), //10 valid without space before qualifier
+ array('a' => "1548794745(10 : unspaced qualifier : bad checksum)"), //10 invalid without space before qualifier
+ array('z' => "1548794743"), //subfield z
+);
+
+foreach ($testData as $current) {
+ $subfields = array();
+ foreach ($current as $key => $value) {
+ $subfields[] = new File_MARC_Subfield($key, $value);
+ }
+ $field = new File_MARC_Data_Field('020', $subfields, '', '');
+ $marc_lint->check020($field);
+}
+
+?>
+--EXPECT--
+020: Subfield a has the wrong number of digits, 154879473.
+020: Subfield a has bad checksum, 1548794743.
+020: Subfield a has the wrong number of digits, 15487947443.
+020: Subfield a has the wrong number of digits, 15487947443324.
+020: Subfield a has bad checksum (13 digit), 9781548794745.
+020: Subfield a has bad checksum, 1548794745 (10 : bad checksum).
+020: Subfield a may have invalid characters.
+020: Subfield a may have invalid characters.
+020: Subfield a has bad checksum, 1-54879-474-5 (hyphens and bad checksum).
+020: Subfield a qualifier must be preceded by space, 1548794740(10 : unspaced qualifier).
+020: Subfield a qualifier must be preceded by space, 1548794745(10 : unspaced qualifier : bad checksum).
+020: Subfield a has bad checksum, 1548794745(10 : unspaced qualifier : bad checksum).
Please sign in to comment.
Something went wrong with that request. Please try again.