├── .gitignore ├── .travis.yml ├── CHANGELOG ├── File ├── MARC.php ├── MARC │ ├── Control_Field.php │ ├── Data_Field.php │ ├── Exception.php │ ├── Field.php │ ├── Lint.php │ ├── Lint │ │ └── CodeData.php │ ├── List.php │ ├── Record.php │ └── Subfield.php ├── MARCBASE.php ├── MARCJSON.php └── MARCXML.php ├── LICENSE ├── README ├── composer.json ├── examples ├── example.mrc ├── marc_yaz.php ├── read.php └── subfields.php ├── index.html ├── package.xml ├── phpunit.xml └── tests ├── bad_example.mrc ├── bad_example.xml ├── bad_example2.mrc ├── bad_leader.xml ├── bigarchive.xml ├── bootstrap.php ├── camel.mrc ├── compressed.mrc.gz ├── example.mrc ├── marc_001.phpt ├── marc_002.phpt ├── marc_003.phpt ├── marc_004.phpt ├── marc_005.phpt ├── marc_006.phpt ├── marc_007.phpt ├── marc_008.phpt ├── marc_009.phpt ├── marc_010.phpt ├── marc_011.phpt ├── marc_012.phpt ├── marc_013.phpt ├── marc_014.phpt ├── marc_015.phpt ├── marc_016.phpt ├── marc_017.phpt ├── marc_018.phpt ├── marc_019.phpt ├── marc_020.phpt ├── marc_021.phpt ├── marc_022.phpt ├── marc_023.phpt ├── marc_024.phpt ├── marc_16783.phpt ├── marc_field_001.phpt ├── marc_field_002.phpt ├── marc_field_003.phpt ├── marc_field_004.phpt ├── marc_field_005.phpt ├── marc_field_006.phpt ├── marc_field_21246.phpt ├── marc_lint_001.phpt ├── marc_lint_002.phpt ├── marc_lint_003.phpt ├── marc_lint_004.phpt ├── marc_lint_005.phpt ├── marc_list_001.phpt ├── marc_record_001.phpt ├── marc_subfield_001.phpt ├── marc_subfield_002.phpt ├── marc_xml_001.phpt ├── marc_xml_002.phpt ├── marc_xml_003.phpt ├── marc_xml_004.phpt ├── marc_xml_005.phpt ├── marc_xml_006.phpt ├── marc_xml_007.phpt ├── marc_xml_008.phpt ├── marc_xml_009.phpt ├── marc_xml_010.phpt ├── marc_xml_011.phpt ├── marc_xml_012.phpt ├── marc_xml_16642.phpt ├── marc_xml_namespace.phpt ├── marc_xml_namespace_prefix.phpt ├── marc_xml_rsinger.phpt ├── music.mrc ├── music.xml ├── namespace.xml ├── onerecord.xml ├── parse_marc_php71.phpt ├── repeated_subfields.xml ├── rsinger.xml ├── sandburg.mrc ├── sandburg.xml ├── skipif.inc ├── skipif_noispn.inc ├── wronglen.mrc └── xmlescape.mrc /.gitignore: -------------------------------------------------------------------------------- 1 | # composer related 2 | composer.lock 3 | composer.phar 4 | vendor 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | sudo: false 3 | php: 4 | - 5.6 5 | - 7.2 6 | env: 7 | - USE_PEAR=true 8 | - USE_PEAR=false 9 | install: 10 | - if $USE_PEAR ; then pear install -f package.xml ; else composer install && composer require pear/validate_ispn ; fi 11 | script: 12 | - if $USE_PEAR ; then pear run-tests -r tests/ ; else phpunit ; fi 13 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 1.4.1 2 | * Reintroduce include_path to composer.json 3 | 4 | 1.4.0 5 | * Update File_MARC_Lint to match MARC::Lint 1.52 (thanks Demian Katz) 6 | * Warn about out-of-range skip indicators (thanks Demian Katz) 7 | * Support initialization from SimpleXMLELement object (thanks Dan Michael O. Heggø) 8 | * Fix Travis-CI support (thanks Daniel O'Connor) 9 | * Tweak composer.json to support Composer 2.0 10 | * Silence PEAR style errors and warnings in File/MARCBASE.php 11 | 12 | 1.3.0 13 | * Support reading MARC-in-JSON serializations 14 | * Fix positions using MARC_List's appendNode method (thanks Waldemar Bartikowski!) 15 | 16 | 1.2.0 17 | * Support injection of extended Record class (thanks Dan Michael O. Heggø!) 18 | * Support regular expression matching of subfields (thanks Waldemar Bartikowski!) 19 | * Fix deletion of multiple subfields at once (thanks Dan Michael O. Heggø!) 20 | 21 | 1.1.5 22 | * Drop support for PHP 5.3 and 5.4 23 | 24 | 1.1.4 25 | * Fix insertField() behaviour, which could truncate records (reported by Andreas Roussos) 26 | * Docs correction for Data_Field (thanks Daniel Walter) 27 | 28 | 1.1.3 29 | * Add a getContents() convenience method, contributed by Carsten Klee 30 | 31 | 1.1.2 32 | * Fetch pear_exception from Packagist [danmichaelo] 33 | 34 | 1.1.1 35 | * Add MARC-in-JSON serialization fix for subfield 0 json_encode() limitation 36 | (thanks to Bill Dueber for reporting the bug) 37 | 38 | 1.1.0 39 | * Enable namespaces in MARCXML handling (thanks Carsten Klee!) 40 | * Remove skip check for Structures/Linked_List 41 | 42 | 1.0.2 43 | * Update MARC_Lint set of rules (thanks Demian Katz!) 44 | 45 | 1.0.1 46 | * Fix bug in MARC binary serialization of subfields with value '0'. 47 | Thanks to Mark Jordan (mjordan@sfu.ca) for the bug report. 48 | 49 | 1.0.0 50 | * First stable release! 51 | 52 | 0.8.0-beta 53 | * Drop Structures_LinkedList dependency in favour of SplDoublyLinkedList. 54 | This bumps the minimum PHP version up to 5.2.0. 55 | 56 | 0.7.3-beta 57 | * Merge patch from Karen Coombs (librarywebchic@gmail.com) adding default 58 | namespace to record elements 59 | 60 | 0.7.2-beta 61 | * Fix bug #19845 - Record::toXML() returns nothing 62 | 63 | 0.7.1-beta 64 | * Make Validate_ISPN an optional dependency 65 | 66 | 0.6.2-beta 67 | * Improve handling of bad leader data, including declared length and overly 68 | long leaders in MARCXML 69 | 70 | 0.6.1-beta 71 | * Correct layout per bug #17704 72 | 73 | 0.6.0-beta 74 | * Add two flavours of JSON output from File_MARC_Record: toJSON() and 75 | toJSONHash() 76 | 77 | 0.5.2-beta 78 | * Enable File_MARC_Record to be invoked with a null constructor again, useful 79 | for building MARC records from scratch 80 | * Add a test to check that the null constructor works to avoid future 81 | regressions 82 | 83 | 0.5.1-beta 84 | * Explicitly cast results to strings to avoid returning XML objects when 85 | File_MARCXML is in effect; problem doesn't show up in the PHP CLI, but does 86 | cause problems on the Web 87 | 88 | 0.5.0-beta 89 | * Drop MARCFLAT as it is unmaintained and, to my knowledge, unused 90 | * Add the ability to generate a proper collection of MARCXML records 91 | * Factor out some of the common toXML()-related methods to a new base class 92 | * Add tests of the new toXML() functionality for both MARC and MARCXML sources 93 | 94 | 0.4.4-beta 95 | * Enable MARCXML to handle bad tags, to match MARC 96 | * Handle corner case where only one indicator might have been provided 97 | 98 | 0.4.3-beta 99 | * Fix bug #16783 - handle bad MARC tags via warnings instead of bubbling an 100 | exception all the way up 101 | 102 | 0.4.2-beta 103 | * Fix bug #16642 - MARCXML files return keys of an invalid type 104 | 105 | 0.4.1-beta 106 | * Fix suggested by Dan Field (surfrdan @ gmail.com) for addWarnings() typo 107 | 108 | 0.4.0-beta 109 | * Add formatField() convenience method to File_MARC_Field (courtesy Mark 110 | Matienzo @ matienzo.org) 111 | * Move from split() to explode() to avoid PHP 5.3 deprecation warning 112 | (courtesy bertrand.zuchuat @ rero.ch 113 | 114 | 0.3.0-beta 115 | * Add isControlField() and isDataField() convenience methods to File_MARC_Field 116 | 117 | 0.2.3-beta 118 | * Handle single-record MARC21XML files with "record" as the root element 119 | 120 | 0.1.1-alpha 121 | * Add File_MARC_Record::toXML() method for generating MARCXML output 122 | * Add File_MARCXML class for reading MARCXML source 123 | * Add tests for MARCXML methods 124 | 125 | 0.1.0-alpha 126 | * Split each class out into its own file 127 | * Do not return anything from constructors 128 | 129 | 0.0.9-alpha 130 | * Separate getFields() from getField(), getSubfields() from getSubfield() 131 | to avoid forcing users to test is_array() after every call 132 | * Add addWarnings() / getWarnings() for records to avoid throwing an 133 | exception for a non-fatal error 134 | * Fix examples, touch up phpdoc in preparation for call for votes 135 | 136 | 0.0.8-alpha 137 | * Switch to PEAR_Exception for error handling 138 | 139 | 0.0.7-alpha 140 | * Implement useful key() overrides for key=>value iteration through 141 | fields and subfields 142 | * Adjust to new Structures_LinkedList_Double names 143 | 144 | 0.0.6-alpha 145 | * Remove package globals, define class constants & static vars instead 146 | * Change addField/Subfield() to append..(), prepend...(), and insert...() 147 | 148 | 0.0.5-alpha 149 | * Work towards a more consistent API (delete getAllSubfields) 150 | * Make PCRE expressions in getFields() and deleteFields() optional. 151 | * Make duplicate() actually return a deep copy of a record. 152 | * Stronger, better, faster (now with typehints) 153 | * Iterate with foreach() everywhere now 154 | 155 | 0.0.4-alpha 156 | * Adjust to Structures_Linked_List package name change and minor API changes 157 | * Adhere to PEAR CS (thanks PHP_CodeSniffer!) 158 | * Correct sloppy use of references (thanks E_STRICT!) 159 | * Okay, this time real error handling using PEAR_ErrorStack 160 | * Prepare first package for PEPR 161 | 162 | 0.0.3-alpha 163 | * Split MARC into separate File_MARC and Structure_Linked_List packages (with corresponding renaming of classes and constants) 164 | * Adopt PEAR naming conventions (s/MARC/File_MARC/) 165 | * Initial stab at PEAR_ErrorStack error handling 166 | 167 | 0.0.2-alpha 168 | * Fix marc_004.phpt: explicitly compare object references with === operator 169 | * Document all constants. 170 | * Fix MARC_Field::deleteSubfield() function 171 | * Add this ChangeLog 172 | 173 | 0.0.1-alpha 174 | * First publicly available release, based on MARC decoding algorithm from 175 | the emilda.org php-marc package with a completely new API and class hierarchy 176 | -------------------------------------------------------------------------------- /File/MARC/Control_Field.php: -------------------------------------------------------------------------------- 1 | 32 | * @author Dan Scott 33 | * @copyright 2003-2008 Oy Realnode Ab, Dan Scott 34 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 35 | * @version CVS: $Id$ 36 | * @link http://pear.php.net/package/File_MARC 37 | */ 38 | 39 | // {{{ class File_MARC_Control_Field extends File_MARC_Field 40 | /** 41 | * The File_MARC_Control_Field class represents a single control field 42 | * in a MARC record. 43 | * 44 | * A MARC control field consists of a tag name and control data. 45 | * 46 | * @category File_Formats 47 | * @package File_MARC 48 | * @author Christoffer Landtman 49 | * @author Dan Scott 50 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 51 | * @link http://pear.php.net/package/File_MARC 52 | */ 53 | class File_MARC_Control_Field extends File_MARC_Field 54 | { 55 | 56 | // {{{ Properties 57 | /** 58 | * Value of field, if field is a Control field 59 | * @var string 60 | */ 61 | protected $data; 62 | // }}} 63 | 64 | // {{{ Constructor: function __construct() 65 | /** 66 | * Field init function 67 | * 68 | * Create a new {@link File_MARC_Control_Field} object from passed arguments 69 | * 70 | * @param string $tag tag 71 | * @param string $data control field data 72 | * @param string $ind1 placeholder for class strictness 73 | * @param string $ind2 placeholder for class strictness 74 | */ 75 | function __construct($tag, $data, $ind1 = null, $ind2 = null) 76 | { 77 | $this->data = $data; 78 | parent::__construct($tag); 79 | 80 | } 81 | // }}} 82 | 83 | // {{{ Destructor: function __destruct() 84 | /** 85 | * Destroys the control field 86 | */ 87 | function __destruct() 88 | { 89 | $this->data = null; 90 | parent::__destruct(); 91 | } 92 | // }}} 93 | 94 | // {{{ Explicit destructor: function delete() 95 | /** 96 | * Destroys the control field 97 | * 98 | * @return true 99 | */ 100 | function delete() 101 | { 102 | $this->__destruct(); 103 | } 104 | // }}} 105 | 106 | // {{{ getData() 107 | /** 108 | * Get control field data 109 | * 110 | * @return string returns data in control field 111 | */ 112 | function getData() 113 | { 114 | return (string)$this->data; 115 | } 116 | // }}} 117 | 118 | // {{{ isEmpty() 119 | /** 120 | * Is empty 121 | * 122 | * Checks if the field contains data 123 | * 124 | * @return bool Returns true if the field is empty, otherwise false 125 | */ 126 | function isEmpty(): bool 127 | { 128 | return ($this->data) ? false : true; 129 | } 130 | // }}} 131 | 132 | // {{{ setData() 133 | /** 134 | * Set control field data 135 | * 136 | * @param string $data data for the control field 137 | * 138 | * @return bool returns the new data in the control field 139 | */ 140 | function setData($data) 141 | { 142 | $this->data = $data; 143 | return $this->getData(); 144 | } 145 | // }}} 146 | 147 | // {{{ __toString() 148 | /** 149 | * Return as a formatted string 150 | * 151 | * Return the control field as a formatted string for pretty printing 152 | * 153 | * @return string Formatted output of control Field 154 | */ 155 | function __toString() 156 | { 157 | return sprintf("%3s %s", $this->tag, $this->data); 158 | } 159 | // }}} 160 | 161 | // {{{ toRaw() 162 | /** 163 | * Return as raw MARC 164 | * 165 | * Return the control field formatted in Raw MARC for saving into MARC files 166 | * 167 | * @return string Raw MARC 168 | */ 169 | function toRaw() 170 | { 171 | return (string)$this->data.File_MARC::END_OF_FIELD; 172 | } 173 | // }}} 174 | 175 | } 176 | // }}} 177 | 178 | -------------------------------------------------------------------------------- /File/MARC/Field.php: -------------------------------------------------------------------------------- 1 | 32 | * @author Dan Scott 33 | * @copyright 2003-2008 Oy Realnode Ab, Dan Scott 34 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 35 | * @version CVS: $Id$ 36 | * @link http://pear.php.net/package/File_MARC 37 | */ 38 | 39 | require_once 'File/MARC/List.php'; 40 | 41 | // {{{ class File_MARC_Field extends File_MARC_List 42 | /** 43 | * The File_MARC_Field class is expected to be extended to reflect the 44 | * requirements of control and data fields. 45 | * 46 | * Every MARC field contains a tag name. 47 | * 48 | * @category File_Formats 49 | * @package File_MARC 50 | * @author Christoffer Landtman 51 | * @author Dan Scott 52 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 53 | * @link http://pear.php.net/package/File_MARC 54 | */ 55 | class File_MARC_Field extends File_MARC_List 56 | { 57 | 58 | // {{{ properties 59 | /** 60 | * The tag name of the Field 61 | * @var string 62 | */ 63 | protected $tag; 64 | // }}} 65 | 66 | // {{{ Constructor: function __construct() 67 | /** 68 | * File_MARC_Field constructor 69 | * 70 | * Create a new {@link File_MARC_Field} object from passed arguments. We 71 | * define placeholders for the arguments required by child classes. 72 | * 73 | * @param string $tag tag 74 | * @param string $subfields placeholder for subfields or control data 75 | * @param string $ind1 placeholder for first indicator 76 | * @param string $ind2 placeholder for second indicator 77 | */ 78 | function __construct($tag, $subfields = null, $ind1 = null, $ind2 = null) 79 | { 80 | $this->tag = $tag; 81 | 82 | // Check if valid tag 83 | if (!preg_match("/^[0-9A-Za-z]{3}$/", $tag)) { 84 | $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_TAG], array("tag" => $tag)); 85 | throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_TAG); 86 | } 87 | 88 | } 89 | // }}} 90 | 91 | // {{{ Destructor: function __destruct() 92 | /** 93 | * Destroys the data field 94 | */ 95 | function __destruct() 96 | { 97 | $this->tag = null; 98 | } 99 | // }}} 100 | 101 | // {{{ getTag() 102 | /** 103 | * Returns the tag for this {@link File_MARC_Field} object 104 | * 105 | * @return string returns the tag number of the field 106 | */ 107 | function getTag() 108 | { 109 | return (string)$this->tag; 110 | } 111 | // }}} 112 | 113 | // {{{ setTag() 114 | /** 115 | * Sets the tag for this {@link File_MARC_Field} object 116 | * 117 | * @param string $tag new value for the tag 118 | * 119 | * @return string returns the tag number of the field 120 | */ 121 | function setTag($tag) 122 | { 123 | $this->tag = $tag; 124 | return $this->getTag(); 125 | } 126 | // }}} 127 | 128 | // {{{ isEmpty() 129 | /** 130 | * Is empty 131 | * 132 | * Checks if the field is empty. 133 | * 134 | * @return bool Returns true if the field is empty, otherwise false 135 | */ 136 | function isEmpty(): bool 137 | { 138 | if ($this->getTag()) { 139 | return false; 140 | } 141 | // It is empty 142 | return true; 143 | } 144 | // }}} 145 | 146 | // {{{ isControlField() 147 | /** 148 | * Is control field 149 | * 150 | * Checks if the field is a control field. 151 | * 152 | * @return bool Returns true if the field is a control field, otherwise false 153 | */ 154 | function isControlField() 155 | { 156 | if (get_class($this) == 'File_MARC_Control_Field') { 157 | return true; 158 | } 159 | return false; 160 | } 161 | // }}} 162 | 163 | // {{{ isDataField() 164 | /** 165 | * Is data field 166 | * 167 | * Checks if the field is a data field. 168 | * 169 | * @return bool Returns true if the field is a data field, otherwise false 170 | */ 171 | function isDataField() 172 | { 173 | if (get_class($this) == 'File_MARC_Data_Field') { 174 | return true; 175 | } 176 | return false; 177 | } 178 | // }}} 179 | 180 | 181 | /** 182 | * ========== OUTPUT METHODS ========== 183 | */ 184 | 185 | // {{{ __toString() 186 | /** 187 | * Return Field formatted 188 | * 189 | * Return Field as a formatted string. 190 | * 191 | * @return string Formatted output of Field 192 | */ 193 | function __toString() 194 | { 195 | return (string)$this->getTag(); 196 | } 197 | // }}} 198 | 199 | // {{{ toRaw() 200 | /** 201 | * Return field in raw MARC format (stub) 202 | * 203 | * Return the field formatted in raw MARC for saving into MARC files. This 204 | * stub method is extended by the child classes. 205 | * 206 | * @return bool Raw MARC 207 | */ 208 | function toRaw() 209 | { 210 | return false; 211 | } 212 | // }}} 213 | 214 | // {{{ formatField() 215 | /** 216 | * Pretty print a MARC_Field object without tags, indicators, etc. 217 | * 218 | * @param array $exclude Subfields to exclude from formatted output 219 | * 220 | * @return string Returns the formatted field data 221 | */ 222 | 223 | function formatField($exclude = array('2')) 224 | { 225 | if ($this->isControlField()) { 226 | return $this->getData(); 227 | } else { 228 | $out = ''; 229 | foreach ($this->getSubfields() as $subfield) { 230 | if (substr($this->getTag(), 0, 1) == '6' and (in_array($subfield->getCode(), array('v','x','y','z')))) { 231 | $out .= ' -- ' . $subfield->getData(); 232 | } elseif (!in_array($subfield->getCode(), $exclude)) { 233 | $out .= ' ' . $subfield->getData(); 234 | } 235 | } 236 | return trim($out); 237 | } 238 | } 239 | // }}} 240 | } 241 | // }}} 242 | 243 | -------------------------------------------------------------------------------- /File/MARC/Subfield.php: -------------------------------------------------------------------------------- 1 | 32 | * @author Dan Scott 33 | * @copyright 2003-2008 Oy Realnode Ab, Dan Scott 34 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 35 | * @version CVS: $Id$ 36 | * @link http://pear.php.net/package/File_MARC 37 | */ 38 | 39 | // {{{ class File_MARC_Subfield 40 | /** 41 | * The File_MARC_Subfield class represents a single subfield in a MARC 42 | * record field. 43 | * 44 | * Represents a subfield within a MARC field and implements all management 45 | * functions related to a single subfield. This class also implements 46 | * the possibility of duplicate subfields within a single field, for example 47 | * 650 _z Test1 _z Test2. 48 | * 49 | * @category File_Formats 50 | * @package File_MARC 51 | * @author Christoffer Landtman 52 | * @author Dan Scott 53 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 54 | * @link http://pear.php.net/package/File_MARC 55 | */ 56 | class File_MARC_Subfield 57 | { 58 | // {{{ properties 59 | /** 60 | * Subfield code, e.g. _a, _b 61 | * @var string 62 | */ 63 | protected $code; 64 | 65 | /** 66 | * Data contained by the subfield 67 | * @var string 68 | */ 69 | protected $data; 70 | 71 | /** 72 | * Position of the subfield 73 | * @var int 74 | */ 75 | protected $position; 76 | 77 | // }}} 78 | 79 | // {{{ Constructor: function __construct() 80 | /** 81 | * File_MARC_Subfield constructor 82 | * 83 | * Create a new subfield to represent the code and data 84 | * 85 | * @param string $code Subfield code 86 | * @param string $data Subfield data 87 | */ 88 | function __construct($code, $data) 89 | { 90 | $this->code = $code; 91 | $this->data = $data; 92 | } 93 | // }}} 94 | 95 | // {{{ Destructor: function __destruct() 96 | /** 97 | * Destroys the subfield 98 | */ 99 | function __destruct() 100 | { 101 | $this->code = null; 102 | $this->data = null; 103 | $this->position = null; 104 | } 105 | // }}} 106 | 107 | // {{{ Explicit destructor: function delete() 108 | /** 109 | * Destroys the subfield 110 | * 111 | * @return true 112 | */ 113 | function delete() 114 | { 115 | $this->__destruct(); 116 | } 117 | // }}} 118 | 119 | // {{{ getCode() 120 | /** 121 | * Return code of the subfield 122 | * 123 | * @return string Tag name 124 | */ 125 | function getCode() 126 | { 127 | return (string)$this->code; 128 | } 129 | // }}} 130 | 131 | // {{{ getData() 132 | /** 133 | * Return data of the subfield 134 | * 135 | * @return string data 136 | */ 137 | function getData() 138 | { 139 | return (string)$this->data; 140 | } 141 | // }}} 142 | 143 | // {{{ getPosition() 144 | /** 145 | * Return position of the subfield 146 | * 147 | * @return int data 148 | */ 149 | function getPosition() 150 | { 151 | return $this->position; 152 | } 153 | // }}} 154 | 155 | // {{{ __toString() 156 | /** 157 | * Return string representation of subfield 158 | * 159 | * @return string String representation 160 | */ 161 | public function __toString() 162 | { 163 | $pretty = '[' . $this->getCode() . ']: ' . $this->getData(); 164 | return $pretty; 165 | } 166 | // }}} 167 | 168 | // {{{ toRaw() 169 | /** 170 | * Return the USMARC representation of the subfield 171 | * 172 | * @return string USMARC representation 173 | */ 174 | function toRaw() 175 | { 176 | $result = File_MARC::SUBFIELD_INDICATOR.$this->code.$this->data; 177 | return (string)$result; 178 | } 179 | // }}} 180 | 181 | // {{{ setCode() 182 | /** 183 | * Sets code of the subfield 184 | * 185 | * @param string $code new code for the subfield 186 | * 187 | * @return string code 188 | */ 189 | function setCode($code) 190 | { 191 | if ($code) { 192 | // could check more stringently; m/[a-Z]/ or the likes 193 | $this->code = $code; 194 | } else { 195 | // code must be _something_; raise error 196 | return false; 197 | } 198 | return true; 199 | } 200 | // }}} 201 | 202 | // {{{ setData() 203 | /** 204 | * Sets data of the subfield 205 | * 206 | * @param string $data new data for the subfield 207 | * 208 | * @return string data 209 | */ 210 | function setData($data) 211 | { 212 | $this->data = $data; 213 | return true; 214 | } 215 | // }}} 216 | 217 | // {{{ setPosition() 218 | /** 219 | * Sets position of the subfield 220 | * 221 | * @param string $pos new position of the subfield 222 | * 223 | * @return void 224 | */ 225 | function setPosition($pos) 226 | { 227 | $this->position = $pos; 228 | } 229 | // }}} 230 | 231 | // {{{ isEmpty() 232 | /** 233 | * Checks whether the subfield is empty or not 234 | * 235 | * @return bool True or false 236 | */ 237 | function isEmpty() 238 | { 239 | // There is data 240 | if (strlen($this->data)) { 241 | return false; 242 | } 243 | 244 | // There is no data 245 | return true; 246 | } 247 | // }}} 248 | } 249 | // }}} 250 | 251 | -------------------------------------------------------------------------------- /File/MARCBASE.php: -------------------------------------------------------------------------------- 1 | 32 | * @copyright 2007-2010 Dan Scott 33 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 34 | * @version CVS: $Id: MARCXML.php 301727 2010-07-30 17:30:51Z dbs $ 35 | * @link http://pear.php.net/package/File_MARC 36 | * @example read.php Retrieve specific fields and subfields from a record 37 | * @example subfields.php Create new subfields and add them in specific order 38 | * @example marc_yaz.php Pretty print a MARC record retrieved via yaz extension 39 | */ 40 | 41 | require_once 'File/MARC/Record.php'; 42 | 43 | // {{{ class File_MARCBASE 44 | /** 45 | * The main File_MARCBASE class provides common methods for File_MARC and 46 | * File_MARCXML - primarily for generating MARCXML output. 47 | * 48 | * @category File_Formats 49 | * @package File_MARC 50 | * @author Dan Scott 51 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 52 | * @link http://pear.php.net/package/File_MARC 53 | */ 54 | class File_MARCBASE 55 | { 56 | 57 | /** 58 | * XMLWriter for writing collections 59 | * 60 | * @var XMLWriter 61 | */ 62 | protected $xmlwriter; 63 | 64 | /** 65 | * Record class 66 | * 67 | * @var string 68 | */ 69 | protected $record_class; 70 | // }}} 71 | 72 | // {{{ Constructor: function __construct() 73 | /** 74 | * Read in MARCXML records 75 | * 76 | * This function reads in files or strings that 77 | * contain one or more MARCXML records. 78 | * 79 | * 80 | * 87 | * 88 | * 89 | * @param string $source Name of the file, or a raw MARC string 90 | * @param int $type Source of the input: SOURCE_FILE or SOURCE_STRING 91 | * @param string $record_class Record class, defaults to File_MARC_Record 92 | */ 93 | function __construct($source, $type, $record_class) 94 | { 95 | $this->xmlwriter = new XMLWriter(); 96 | $this->xmlwriter->openMemory(); 97 | $this->xmlwriter->startDocument('1.0', 'UTF-8'); 98 | 99 | $this->record_class = $record_class ?: File_MARC_Record::class; 100 | } 101 | // }}} 102 | 103 | // {{{ toXMLHeader() 104 | /** 105 | * Initializes the MARCXML output of a record or collection of records 106 | * 107 | * This method produces an XML representation of a MARC record that 108 | * attempts to adhere to the MARCXML standard documented at 109 | * http://www.loc.gov/standards/marcxml/ 110 | * 111 | * @return bool true if successful 112 | */ 113 | function toXMLHeader() 114 | { 115 | $this->xmlwriter->startElement("collection"); 116 | $this->xmlwriter->writeAttribute("xmlns", "http://www.loc.gov/MARC21/slim"); 117 | return true; 118 | } 119 | // }}} 120 | 121 | // {{{ getXMLWriter() 122 | /** 123 | * Returns the XMLWriter object 124 | * 125 | * This method produces an XML representation of a MARC record that 126 | * attempts to adhere to the MARCXML standard documented at 127 | * http://www.loc.gov/standards/marcxml/ 128 | * 129 | * @return XMLWriter XMLWriter instance 130 | */ 131 | function getXMLWriter() 132 | { 133 | return $this->xmlwriter; 134 | } 135 | // }}} 136 | 137 | // {{{ toXMLFooter() 138 | /** 139 | * Returns the MARCXML collection footer 140 | * 141 | * This method produces an XML representation of a MARC record that 142 | * attempts to adhere to the MARCXML standard documented at 143 | * http://www.loc.gov/standards/marcxml/ 144 | * 145 | * @return string representation of MARC record in MARCXML format 146 | */ 147 | function toXMLFooter() 148 | { 149 | $this->xmlwriter->endElement(); // end collection 150 | $this->xmlwriter->endDocument(); 151 | return $this->xmlwriter->outputMemory(); 152 | } 153 | // }}} 154 | 155 | } 156 | // }}} 157 | -------------------------------------------------------------------------------- /File/MARCJSON.php: -------------------------------------------------------------------------------- 1 | 32 | * @copyright 2007-2010 Dan Scott 33 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 34 | * @version CVS: $Id$ 35 | * @link http://pear.php.net/package/File_MARC 36 | * @example read.php Retrieve specific fields and subfields from a record 37 | * @example subfields.php Create new subfields and add them in specific order 38 | * @example marc_yaz.php Pretty print a MARC record retrieved through the PECL yaz extension 39 | */ 40 | 41 | require_once 'PEAR/Exception.php'; 42 | require_once 'File/MARCBASE.php'; 43 | require_once 'File/MARC.php'; 44 | require_once 'File/MARC/Record.php'; 45 | require_once 'File/MARC/Field.php'; 46 | require_once 'File/MARC/Control_Field.php'; 47 | require_once 'File/MARC/Data_Field.php'; 48 | require_once 'File/MARC/Subfield.php'; 49 | require_once 'File/MARC/Exception.php'; 50 | require_once 'File/MARC/List.php'; 51 | 52 | // {{{ class File_MARCJSON 53 | /** 54 | * The main File_MARCJSON class enables you to return File_MARC_Record 55 | * objects from a MARC-in-JSON stream or string. 56 | * 57 | * @category File_Formats 58 | * @package File_MARC 59 | * @author Dan Scott 60 | * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 61 | * @link http://pear.php.net/package/File_MARC 62 | */ 63 | class File_MARCJSON extends File_MARCBASE 64 | { 65 | 66 | // {{{ constants 67 | 68 | /** 69 | * MARC records retrieved from a file 70 | */ 71 | const SOURCE_FILE = 1; 72 | 73 | /** 74 | * MARC records retrieved from a binary string 75 | */ 76 | const SOURCE_STRING = 2; 77 | // }}} 78 | 79 | // {{{ properties 80 | /** 81 | * Source containing raw records 82 | * 83 | * @var resource 84 | */ 85 | protected $source; 86 | 87 | /** 88 | * Source type (SOURCE_FILE or SOURCE_STRING) 89 | * 90 | * @var int 91 | */ 92 | protected $type; 93 | 94 | /** 95 | * Counter for MARCJSON records in a collection 96 | * 97 | * @var int 98 | */ 99 | protected $counter; 100 | 101 | // }}} 102 | 103 | 104 | // {{{ Constructor: function __construct() 105 | /** 106 | * Read in MARC-in-JSON records 107 | * 108 | * This function reads in a string that contains a single MARC-in-JSON 109 | * record. 110 | * 111 | * 112 | * 116 | * 117 | * 118 | * @param string $source A raw MARC-in-JSON string 119 | * @param string $record_class Record class, defaults to File_MARC_Record 120 | */ 121 | function __construct($source, $record_class = null) 122 | { 123 | parent::__construct($source, self::SOURCE_STRING, $record_class); 124 | 125 | $this->text = json_decode($source); 126 | 127 | if (!$this->text) { 128 | $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_FILE], array('filename' => $source)); 129 | throw new File_MARC_Exception($errorMessage, File_MARC_Exception::ERROR_INVALID_FILE); 130 | } 131 | } 132 | // }}} 133 | 134 | // {{{ next() 135 | /** 136 | * Return next {@link File_MARC_Record} object 137 | * 138 | * Decodes a MARCJSON record and returns the {@link File_MARC_Record} 139 | * object. There can only be one MARCJSON record per string but we use 140 | * the next() approach to maintain a unified API with XML and MARC21 141 | * readers. 142 | * 143 | * next()) { 150 | * print $record; 151 | * print "\n"; 152 | * } 153 | * 154 | * ?> 155 | * 156 | * 157 | * @return File_MARC_Record next record, or false if there are 158 | * no more records 159 | */ 160 | function next() 161 | { 162 | if ($this->text) { 163 | $marc = $this->_decode($this->text); 164 | $this->text = null; 165 | return $marc; 166 | } else { 167 | return false; 168 | } 169 | } 170 | // }}} 171 | 172 | 173 | // {{{ _decode() 174 | /** 175 | * Decode a given MARC-in-JSON record 176 | * 177 | * @param string $text MARC-in-JSON record element 178 | * 179 | * @return File_MARC_Record Decoded File_MARC_Record object 180 | */ 181 | private function _decode($text) 182 | { 183 | $marc = new $this->record_class($this); 184 | 185 | // Store leader 186 | $marc->setLeader($text->leader); 187 | 188 | // go through all fields 189 | foreach ($text->fields as $field) { 190 | foreach ($field as $tag => $values) { 191 | // is it a control field? 192 | if (strpos($tag, '00') === 0) { 193 | $marc->appendField(new File_MARC_Control_Field($tag, $values)); 194 | } else { 195 | // it's a data field -- get the subfields 196 | $subfield_data = array(); 197 | foreach ($values->subfields as $subfield) { 198 | foreach ($subfield as $sf_code => $sf_value) { 199 | $subfield_data[] = new File_MARC_Subfield($sf_code, $sf_value); 200 | } 201 | } 202 | // If the data is invalid, let's just ignore the one field 203 | try { 204 | $new_field = new File_MARC_Data_Field($tag, $subfield_data, $values->ind1, $values->ind2); 205 | $marc->appendField($new_field); 206 | } catch (Exception $e) { 207 | $marc->addWarning($e->getMessage()); 208 | } 209 | } 210 | } 211 | 212 | } 213 | return $marc; 214 | } 215 | // }}} 216 | 217 | } 218 | // }}} 219 | 220 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This package is http://pear.php.net/package/File_MARC and has been migrated from https://svn.php.net/repository/pear/packages/File_MARC 2 | 3 | Please report all new issues via the PEAR bug tracker. 4 | 5 | If this package is marked as unmaintained and you have fixes, please submit your pull requests and start discussion on the pear-qa mailing list. 6 | 7 | To test, run either 8 | $ phpunit tests/ 9 | or 10 | $ pear run-tests -r 11 | 12 | To build, simply 13 | $ pear package 14 | 15 | To install from scratch 16 | $ pear install package.xml 17 | 18 | To upgrade 19 | $ pear upgrade -f package.xml 20 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "authors": [ 3 | { 4 | "email": "dbs@php.net", 5 | "name": "Dan Scott", 6 | "role": "Lead", 7 | "homepage": "https://coffeecode.net" 8 | } 9 | ], 10 | "autoload": { 11 | "psr-0": { 12 | "File": "./" 13 | }, 14 | "classmap": [ 15 | "./File/MARC/Data_Field.php", 16 | "./File/MARC/Control_Field.php" 17 | ] 18 | }, 19 | "description": "Supports the MAchine Readable Cataloging (MARC) file format documented at http://loc.gov/marc/", 20 | "include-path": [ 21 | "./" 22 | ], 23 | "license": "LGPL-2.1", 24 | "name": "pear/file_marc", 25 | "support": { 26 | "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=File_MARC", 27 | "source": "https://github.com/pear/File_MARC" 28 | }, 29 | "type": "library", 30 | "require": { 31 | "pear/pear_exception": "1.*" 32 | }, 33 | "require-dev": { 34 | "phpunit/phpunit": "*", 35 | "squizlabs/php_codesniffer": "*" 36 | }, 37 | "suggest": { 38 | "pear/validate_ispn": "Install optionally via your project's composer.json" 39 | }, 40 | "minimum-stability": "dev", 41 | "prefer-stable": true 42 | } 43 | -------------------------------------------------------------------------------- /examples/example.mrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pear/File_MARC/7085b9e81ee433b5b75eb454d30ab619b8eccacc/examples/example.mrc -------------------------------------------------------------------------------- /examples/marc_yaz.php: -------------------------------------------------------------------------------- 1 | "1=4", 8 | "au" => "1=1", 9 | "isbn" => "1=7" 10 | ); 11 | 12 | // Declare the array that will hold the parsed results 13 | $ccl_results = array(); 14 | 15 | // Connect to the laurentian.ca Z39.50 server 16 | $conn = yaz_connect('142.51.8.7:2200/UNICORN'); 17 | yaz_ccl_conf($conn, $ccl_fields); 18 | 19 | // Define our query for a most excellent text 20 | $ccl_query = "ti='derby' and au='scott'"; 21 | 22 | // Parse the CCL query into yaz's native format 23 | $result = yaz_ccl_parse($conn, $ccl_query, $ccl_results); 24 | if (!$result) { 25 | echo "Error: " . $ccl_results['errorstring']; 26 | exit(); 27 | } 28 | 29 | // Submit the query 30 | $rpn = $ccl_results['rpn']; 31 | yaz_search($conn, 'rpn', $rpn); 32 | yaz_wait(); 33 | 34 | // Any errors trying to retrieve this record? 35 | $error = yaz_error($conn); 36 | if ($error) { 37 | print "Error: $error\n"; 38 | exit(); 39 | } 40 | 41 | // Retrieve the first MARC record as raw MARC 42 | $rec = yaz_record($conn, 1, "raw"); 43 | if (!$rec) { 44 | print "Error: Retrieved no results.\n"; 45 | exit(); 46 | } 47 | 48 | // Parse the retrieved MARC record 49 | $marc_file = new File_MARC($rec, File_MARC::SOURCE_STRING); 50 | 51 | while ($marc_record = $marc_file->next()) { 52 | print $marc_record; 53 | print "\n"; 54 | } 55 | ?> 56 | -------------------------------------------------------------------------------- /examples/read.php: -------------------------------------------------------------------------------- 1 | next(); 10 | 11 | // Retrieve a personal name field from the record 12 | $names = $marc_record->getFields('100'); 13 | 14 | foreach ($names as $name_field) { 15 | // Now print the $a subfield 16 | switch ($name_field->getIndicator(1)) { 17 | case 0: 18 | print "Forename: "; 19 | break; 20 | 21 | case 1: 22 | print "Surname: "; 23 | break; 24 | 25 | case 2: 26 | print "Family name: "; 27 | break; 28 | } 29 | 30 | $name = $name_field->getSubfields('a'); 31 | 32 | if (count($name) == 1) { 33 | print $name[0]->getData() . "\n"; 34 | } else { 35 | print "Error -- \$a subfield appears more than once in this field!"; 36 | } 37 | } 38 | 39 | print "\nPrint all series statement fields (4xx):\n"; 40 | // Retrieve all series statement fields 41 | // Series statement fields start with a 4 (PCRE) 42 | $subjects = $marc_record->getFields('^4', true); 43 | 44 | // Iterate through all of the returned series statement fields 45 | foreach ($subjects as $field) { 46 | // print with File_MARC_Field_Data's magic __toString() method 47 | print $field; 48 | } 49 | 50 | print "\n"; 51 | 52 | ?> 53 | -------------------------------------------------------------------------------- /examples/subfields.php: -------------------------------------------------------------------------------- 1 | appendSubfield($subfield1); 22 | 23 | // Insert a new subfield after the first subfield with code 'z' 24 | // Expected order: a-z-k-g 25 | $sf = $field->getSubfields('z'); 26 | // getSubfields() always returns an array; we just want the first subfield 27 | if (count($sf) > 0) { 28 | $field->insertSubfield($subfield2, $sf[0]); 29 | } 30 | 31 | // Insert a new subfield prior to the first subfield with code 'z' 32 | // Expected order: a-t-z-k-g 33 | $sf = $field->getSubfield('z'); 34 | // getSubfield() simply returns the first matching subfield 35 | if ($sf) { 36 | $field->insertSubfield($subfield3, $sf, true); 37 | } 38 | 39 | // let's see the results 40 | print $field; 41 | print "\n"; 42 | 43 | ?> 44 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | File_MARC package for PHP 7 | 8 | 9 |

File_MARC package for PHP

10 |

Hey, welcome to the File_MARC package for PHP. If you don't know 11 | what MARC is, then you probably don't need this package -- but you 12 | can find out more about MARC at Library of Congress: MARC standards.

14 |

Requirements

15 |

The basic requirement for File_MARC is PHP 5 with a working PEAR installer. The PEAR installer will install any dependencies for you.

16 |

17 | 18 |

Installation

19 |

Install the File_MARC package using the PEAR installer. You have to append -alpha to the package name as I have not yet created a stable release.

20 |
21 | # pear install File_MARC-alpha
22 | 
23 | 24 |

Documentation

25 |

Read the File_MARC API documentation.

26 |

Highlighted source files

27 | 37 | 38 |

Download

39 |

Current release: 0.1.0-alpha is hosted at PEAR.

40 | 41 |

Comments

42 |

Comments are welcome by email at dbs@php.net.

43 | 44 |

Future directions

45 |
    46 |
  • More user-oriented documentation
  • 47 |
  • Make MARC_Record->appendField() append the field to 48 | the end of the corresponding [0-9]xx range to keep records 49 | conformant with LOC guidelines
  • 50 |
  • Enable sorting the MARC fields
  • 51 |
  • Add levels of MARC standards compliance for error 52 | modes (e.g. only one 1XX field per bibliographic record)
  • 53 |
  • Add semantic shortcuts for a given record based on the fixed fields 54 | values (e.g. $record->getLanguage() or the like).
  • 55 |
  • Enable reading from and writing to MARCXML format.
  • 56 |
57 |

Previous releases

58 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | File_MARC 10 | pear.php.net 11 | Parse, modify, and create MARC records 12 | The standard for machine-readable cataloging (MARC) records is documented at http://loc.gov/marc/. This package enables you to read existing MARC records from a file, string, or (using the YAZ extension), from a Z39.50 source. You can also use this package to create new MARC records. 13 | 14 | This package is based on the PHP MARC package, originally called "php-marc", that is part of the Emilda Project (http://www.emilda.org). Christoffer Landtman generously agreed to make the "php-marc" code available under the GNU LGPL so it could be used as the basis of this PEAR package. 15 | 16 | 17 | Dan Scott 18 | dbs 19 | dbs@php.net 20 | yes 21 | 22 | 2019-11-13 23 | 24 | 1.4.1 25 | 1.4.0 26 | 27 | 28 | stable 29 | stable 30 | 31 | GNU Lesser General Public License 32 | 33 | 1.4.1 34 | * Reintroduce include_path to composer.json 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 5.6 136 | 137 | 138 | 1.4.0 139 | 140 | 141 | 142 | 143 | Validate_ISPN 144 | pear.php.net 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tests 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/bad_example.mrc: -------------------------------------------------------------------------------- 1 | 01853 a2200517 450000100110000000300070001100800390001802000260005703500150008304000070009804200120010508400180011708400180013508400210015308400220017410000300019624500630022625000130028926000580030230-0033003604400037003935000023004305990010004537400024004637750034004878410048005218410049005698410047006188410048006658410047007138410047007608520038008078520021008458520013008668520016008798520028008958520021009239000056009449000061010009000057010619000056011189000057011749000060012319760027012910050017013180000000044EMILDA980120s1998 fi j 000 0 swe a9515008808cFIM 72:00 99515008808 aNB 9NB9SEE aHcd,u2kssb/6 5NBauHc2kssb 5SEEaHcf2kssb/6 5QaHcd,uf2kssb/61 aJansson, Tove,d1914-200104aDet osynliga barnet och andra bert̃telser /cTove Jansson a7. uppl. aHelsingfors :bSchildt,c1998 ;e(Falun :fScandbook) a166, [4] s. :bill. ;c21 cm 0aMumin-biblioteket,x99-0698931-9 aOriginaluppl. 1962 aLi: S4 aDet osynliga barnet1 z951-50-0385-7w9515003857907 5Liaxab0201080u 0 4000uu |000000e1 5SEEaxab0201080u 0 4000uu |000000e1 5Laxab0201080u 0 4000uu |000000e1 5NBaxab0201080u 0 4000uu |000000e1 5Qaxab0201080u 0 4000uu |000000e1 5Saxab0201080u 0 4000uu |000000e1 5NBbNBcNB98:12hpliktjR, 980520 5LibLicCNBhh,u 5SEEbSEE 5QbQj98947 5LbLc0100h98/j3043 H 5SbShSv97j72351saYanson, Tobe,d1914-2001uJansson, Tove,d1914-20011saJanssonov,̀ Tove,d1914-2001uJansson, Tove,d1914-20011saJansone, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJansson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanssonova, Tove,d1914-2001uJansson, Tove,d1914-2001 2aHcd,ubSkn̲litteratur20050204111518.0 -------------------------------------------------------------------------------- /tests/bad_example2.mrc: -------------------------------------------------------------------------------- 1 | 0159700289224500010000800000100004100008101000800049102000700057181001900064181002400083182001000107182002000117210004300137215002900180300010800209300028400317305007500601423011500676461006500791600005900856701007400915701008400989701007501073701007201148701007401220830001301294 bBr. a20210630d1977 m y0frey50 ba0 afre aFR 0601ai bxxxe  602ctxt2rdacontent 0601an 602cn2rdamedia aPariscNouvelle revue françaised1977 a1 vol. (p. 64-90)d23 cm aHommage à Raymond Queneau paru dans "La Nouvelle revue française", ISSN 0029-4802, 290, février 1977 aContient : "Queneau, discours et rêve" par Jean Queval ; "Raymond Queneau et l'amalgame des mathématiques et de la littérature" par François Le Lionnais ; "Souriant et secret" par Henri Thomas ; "Si tu t'imagines..." par Jean Blot ; "Le savoir et la banlieue" par Hubert Juin aNuméro de : La Nouvelle revue française = ISSN 0029-4802, 290 (1977) 19a000000tRaymond Queneauf[textes de] Jean Queval, François Le Lionnais, Henri Thomas, Jean Blot, Hubert Juin 0032826254tLa Nouvelle revue françaisex0029-4802v(1977)290 |9a000000311920846aQueneaubRaymondf1903-19762rameau |9a000000311920877oISNI0000000121371861aQuevalbJeanf1913-19904070 |9a000000311911678oISNI0000000121469498aLe LionnaisbFrançoisf1901-19844070 |9a000000311926514oISNI0000000120354023aThomasbHenrif1912-19934070 |9a000000311892431oISNI000000010939581XaBlotbJeanf1923-20194070 |9a000000311886651oISNI0000000109296125aJuinbHubertf1926-19874070 a20210630 -------------------------------------------------------------------------------- /tests/bad_leader.xml: -------------------------------------------------------------------------------- 1 | 2 | 00711cam a2200229 45004500 3 | LIBN539044247 4 | OCoLC 5 | 20081030150430.0 6 | 070630||||| ||| 000 0 eng d 7 | 8 | 9781856075442 9 | 10 | 11 | 1856075443 12 | 13 | 14 | (OCoLC)156822300 15 | 16 | 17 | BTCTA 18 | BTCTA 19 | YDXCP 20 | BAKER 21 | EMT 22 | 23 | 24 | BL2747.2 25 | .W45 2006 26 | 27 | 28 | White, Stephen Ross. 29 | 30 | 31 | Space for unknowing : 32 | the place of agnosis in faith / 33 | Stephen R. White. 34 | 35 | 36 | Dublin : 37 | Columba Press, 38 | c2006. 39 | 40 | 41 | 160 p. ; 42 | 22 cm. 43 | 44 | 45 | Includes bibliographical references. 46 | 47 | 48 | Agnosticism. 49 | 50 | 51 | Belief and doubt. 52 | 53 | 54 | 1 55 | 230 WHI 56 | 11111027105040 57 | 6511254 58 | p26.95 59 | 60 | 61 | LIBN539044247 62 | System 63 | 64 | 65 | -------------------------------------------------------------------------------- /tests/bigarchive.xml: -------------------------------------------------------------------------------- 1 | 2 | 00000nam 2200277 450099865026eUnM19961010163452.0m g dcr bn |||a|bb|940112s1649 enk s 00| | eng dCL0051000003ProQuest Information and Learning. 300 N. Zeeb Rd., Ann Arbor, MI 48106Cu-RivESCu-RivESCStRLINdcrbWaOLNThe VVelsh embassador, or the happy newes his vvorship hath brought to London.[electronic resource] :Togetherwith her thirteen articles of acreements, which her propounds to all her cousens in her principality of Wales,and her Cities of London.Happy newes his vvorship hath brought to London[London] :Printed for George Roberts, and are to be soldat the Maiden Head on Snow-Hill neer Holborn Conduit,1649.[2], 6 p.Place of publication from Wing.Annotation on Thomason copy: "May 4th".Reproduction of the original in the British Library.Wing (2nd ed.)W1315.ThomasonE.552[19].Electronic reproduction.Ann Arbor, Mich. :UMI,1999-(Early English books online)Digital version of: (Thomason Tracts ; 85:E552[19])s1999 miun sGreat BritainPolitics and government1642-1649Early works to 1800.Early English books online.E-book (Onsite access at NYPL Research Libraries)http://gateway.proquest.com/openurl?ctx_ver=Z39.88-2003&res_id=xri:eebo&rft_val_fmt=&rft_id=xri:eebo:image:117259Not for export in OCLC Reclamation Project 3 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record; 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | LDR 01145ncm 2200277 i 4500 18 | 001 000073594 19 | 004 AAJ5802 20 | 005 20030415102100.0 21 | 008 801107s1977 nyujza 22 | 010 _a 77771106 23 | 035 _a(CaOTUIC)15460184 24 | 035 9 _aAAJ5802 25 | 040 _aLC 26 | 050 00 _aM1366 27 | _b.M62 28 | _dM1527.2 29 | 245 04 _aThe Modern Jazz Quartet : 30 | _bThe legendary profile. -- 31 | 260 _aNew York : 32 | _bM.J.Q. Music, 33 | _cc1977. 34 | 300 _ascore (72 p.) ; 35 | _c31 cm. 36 | 500 _aFor piano, vibraphone, drums, and double bass. 37 | 505 0 _aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 38 | 650 0 _aJazz. 39 | 650 0 _aMotion picture music 40 | _vExcerpts 41 | _vScores. 42 | 700 12 _aLewis, John, 43 | _d1920- 44 | _tSelections. 45 | _f1977. 46 | 700 12 _aJackson, Milt. 47 | _tMartyrs. 48 | _f1977. 49 | 700 12 _aJackson, Milt. 50 | _tLegendary profile. 51 | _f1977. 52 | 740 4 _aThe legendary profile. 53 | 852 00 _bMUSIC 54 | _cMAIN 55 | _kfolio 56 | _hM1366 57 | _iM62 58 | _91 59 | _4Marvin Duchow Music 60 | _5 61 | 62 | LDR 01293cjm 2200289 a 4500 63 | 001 001878039 64 | 005 20050110174900.0 65 | 007 sd fungnn|||e| 66 | 008 940202r19931981nyujzn i d 67 | 024 1 _a7464573372 68 | 028 02 _aJK 57337 69 | _bRed Baron 70 | 035 _a(OCoLC)29737267 71 | 040 _aSVP 72 | _cSVP 73 | _dLGG 74 | 100 1 _aDesmond, Paul, 75 | _d1924- 76 | 245 10 _aPaul Desmond & the Modern Jazz Quartet 77 | _h[sound recording] 78 | 260 _aNew York, N.Y. : 79 | _bRed Baron : 80 | _bManufactured by Sony Music Entertainment, 81 | _cp1993. 82 | 300 _a1 sound disc (39 min.) : 83 | _bdigital ; 84 | _c4 3/4 in. 85 | 511 0 _aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. 86 | 500 _aAll arrangements by John Lewis. 87 | 518 _aRecorded live on December 25, 1971 at Town Hall, NYC. 88 | 500 _aOriginally released in 1981 by Finesse as LP FW 27487. 89 | 500 _aProgram notes by Irving Townsend, June 1981, on container insert. 90 | 505 0 _aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 91 | 650 0 _aJazz 92 | _y1971-1980. 93 | 700 1 _aLewis, John, 94 | _d1920- 95 | 710 2 _aModern Jazz Quartet. 96 | 740 0 _aPaul Desmond and the Modern Jazz Quartet. 97 | 98 | LDR 01829cjm 2200385 a 4500 99 | 001 001964482 100 | 005 20060626132700.0 101 | 007 sd fzngnn|m|e| 102 | 008 871211p19871957nyujzn d 103 | 024 1 _a4228332902 104 | 028 01 _a833 290-2 105 | _bVerve 106 | 033 0 _a19571027 107 | _b6299 108 | _cD56 109 | 033 0 _a196112-- 110 | _b3804 111 | _cN4 112 | 033 0 _a19571019 113 | _b4104 114 | _cC6 115 | 033 0 _a197107-- 116 | _b6299 117 | _cV7 118 | 035 _a(OCoLC)17222092 119 | 040 _aCPL 120 | _cCPL 121 | _dOCL 122 | _dLGG 123 | 048 _apz01 124 | _aka01 125 | _asd01 126 | _apd01 127 | 110 2 _aModern Jazz Quartet. 128 | _4prf 129 | 245 14 _aThe Modern Jazz Quartet plus 130 | _h[sound recording]. 131 | 260 _a[New York] : 132 | _bVerve, 133 | _cp1987. 134 | 300 _a1 sound disc : 135 | _bdigital ; 136 | _c4 3/4 in. 137 | 440 0 _aCompact jazz 138 | 511 0 _aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. 139 | 518 _aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). 140 | 500 _aCompact disc. 141 | 500 _aAnalog recording. 142 | 505 0 _aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 143 | 650 0 _aJazz. 144 | 700 1 _aJackson, Milt. 145 | _4prf 146 | 700 1 _aPeterson, Oscar, 147 | _d1925- 148 | _4prf 149 | 700 1 _aBrown, Ray, 150 | _d1926-2002. 151 | _4prf 152 | 700 1 _aThigpen, Ed. 153 | _4prf 154 | 700 1 _aHayes, Louis, 155 | _d1937- 156 | _4prf 157 | 852 80 _bMUSIC 158 | _cAV 159 | _hCD 1131 160 | _4Marvin Duchow Music 161 | _5Audio-Visual 162 | -------------------------------------------------------------------------------- /tests/marc_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_003: getFields() with various regular expressions 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 13 | print "\nNext record:\n"; 14 | $fields = $marc_record->getFields('650'); 15 | foreach ($fields as $field) { 16 | print $field; 17 | print "\n"; 18 | } 19 | } 20 | 21 | print "\nTest with regular expression\n"; 22 | $marc_file = new File_MARC($dir . '/' . 'music.mrc'); 23 | while ($marc_record = $marc_file->next()) { 24 | print "\nNext record:\n"; 25 | $fields = $marc_record->getFields('00\d', true); 26 | foreach ($fields as $field) { 27 | print $field; 28 | print "\n"; 29 | } 30 | } 31 | 32 | ?> 33 | --EXPECT-- 34 | Test with a simple string 35 | 36 | Next record: 37 | 650 0 _aJazz. 38 | 650 0 _aMotion picture music 39 | _vExcerpts 40 | _vScores. 41 | 42 | Next record: 43 | 650 0 _aJazz 44 | _y1971-1980. 45 | 46 | Next record: 47 | 650 0 _aJazz. 48 | 49 | Test with regular expression 50 | 51 | Next record: 52 | 001 000073594 53 | 004 AAJ5802 54 | 005 20030415102100.0 55 | 008 801107s1977 nyujza 56 | 57 | Next record: 58 | 001 001878039 59 | 005 20050110174900.0 60 | 007 sd fungnn|||e| 61 | 008 940202r19931981nyujzn i d 62 | 63 | Next record: 64 | 001 001964482 65 | 005 20060626132700.0 66 | 007 sd fzngnn|m|e| 67 | 008 871211p19871957nyujzn d 68 | -------------------------------------------------------------------------------- /tests/marc_005.phpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pear/File_MARC/7085b9e81ee433b5b75eb454d30ab619b8eccacc/tests/marc_005.phpt -------------------------------------------------------------------------------- /tests/marc_006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_006: test read.php 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next(); 16 | 17 | // Retrieve a personal name field from the record 18 | $names = $marc_record->getFields('100'); 19 | foreach ($names as $name_field) { 20 | // Now print the $a subfield 21 | switch ($name_field->getIndicator(1)) { 22 | case 0: 23 | print "Forename: "; 24 | break; 25 | 26 | case 1: 27 | print "Surname: "; 28 | break; 29 | 30 | case 2: 31 | print "Family name: "; 32 | break; 33 | } 34 | $name = $name_field->getSubfields('a'); 35 | if (count($name) == 1) { 36 | print $name[0]->getData() . "\n"; 37 | } 38 | else { 39 | print "Error -- \$a subfield appears more than once in this field!"; 40 | } 41 | } 42 | 43 | // Retrieve all series statement fields 44 | // Series statement fields start with a 4 (PCRE) 45 | $subjects = $marc_record->getFields('^4', true); 46 | 47 | // Iterate through all of the returned series statement fields 48 | foreach ($subjects as $field) { 49 | // print with File_MARC_Field_Data's magic __toString() method 50 | print $field; 51 | } 52 | 53 | ?> 54 | --EXPECT-- 55 | Surname: Jansson, Tove, 56 | 440 0 _aMumin-biblioteket, 57 | _x99-0698931-9 58 | -------------------------------------------------------------------------------- /tests/marc_007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_007: Use key=>value iteration for tags and codes 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | foreach ($marc_record->getFields() as $tag=>$value) { 13 | print "$tag: "; 14 | if ($value instanceof File_MARC_Control_Field) { 15 | print $value->getData(); 16 | } 17 | else { 18 | foreach ($value->getSubfields() as $code=>$subdata) { 19 | print "_$code"; 20 | } 21 | } 22 | print "\n"; 23 | } 24 | } 25 | ?> 26 | --EXPECT-- 27 | 001: 0000000044 28 | 003: EMILDA 29 | 008: 980120s1998 fi j 000 0 swe 30 | 020: _a_c 31 | 035: _9 32 | 040: _a 33 | 042: _9_9 34 | 084: _a_2 35 | 084: _5_a_2 36 | 084: _5_a_2 37 | 084: _5_a_2 38 | 100: _a_d 39 | 245: _a_c 40 | 250: _a 41 | 260: _a_b_c_e_f 42 | 300: _a_b_c 43 | 440: _a_x 44 | 500: _a 45 | 599: _a 46 | 740: _a 47 | 775: _z_w_9 48 | 841: _5_a_b_e 49 | 841: _5_a_b_e 50 | 841: _5_a_b_e 51 | 841: _5_a_b_e 52 | 841: _5_a_b_e 53 | 841: _5_a_b_e 54 | 852: _5_b_c_h_j 55 | 852: _5_b_c_h 56 | 852: _5_b 57 | 852: _5_b_j 58 | 852: _5_b_c_h_j 59 | 852: _5_b_h_j 60 | 900: _a_d_u_d 61 | 900: _a_d_u_d 62 | 900: _a_d_u_d 63 | 900: _a_d_u_d 64 | 900: _a_d_u_d 65 | 900: _a_d_u_d 66 | 976: _a_b 67 | 005: 20050204111518.0 68 | -------------------------------------------------------------------------------- /tests/marc_008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_008: Attempt to open a file that does not exist 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage(); 15 | } 16 | 17 | ?> 18 | --EXPECTF-- 19 | Warning: fopen(super_bogus_file): failed to open stream: No such file or directory in %sMARC.php on line %d 20 | Invalid input file "super_bogus_file" 21 | -------------------------------------------------------------------------------- /tests/marc_009.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_009: Parse a record where leader record length != real record length 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record; 13 | print "\n"; 14 | print "WARNINGS:\n"; 15 | foreach ($marc_record->getWarnings() as $warning) { 16 | print " * $warning\n"; 17 | } 18 | } 19 | ?> 20 | --EXPECT-- 21 | LDR 00727nam 2200205 a 4500 22 | 001 03-0016458 23 | 005 19971103184734.0 24 | 008 970701s1997 oru u000 0 eng u 25 | 035 _a(Sirsi) a351664 26 | 050 00 _aML270.2 27 | _b.A6 1997 28 | 100 1 _aAnthony, James R. 29 | 245 00 _aFrench baroque music from Beaujoyeulx to Rameau 30 | 250 _aRev. and expanded ed. 31 | 260 _aPortland, OR : 32 | _bAmadeus Press, 33 | _c1997. 34 | 300 _a586 p. : 35 | _bmusic 36 | 650 0 _aMusic 37 | _ 5 | --FILE-- 6 | next()) { 13 | print $marc_record; 14 | print "\n"; 15 | } 16 | ?> 17 | --EXPECT-- 18 | LDR 01145ncm 2200277 i 4500 19 | 001 000073594 20 | 004 AAJ5802 21 | 005 20030415102100.0 22 | 008 801107s1977 nyujza 23 | 010 _a 77771106 24 | 035 _a(CaOTUIC)15460184 25 | 035 9 _aAAJ5802 26 | 040 _aLC 27 | 050 00 _aM1366 28 | _b.M62 29 | _dM1527.2 30 | 245 04 _aThe Modern Jazz Quartet : 31 | _bThe legendary profile. -- 32 | 260 _aNew York : 33 | _bM.J.Q. Music, 34 | _cc1977. 35 | 300 _ascore (72 p.) ; 36 | _c31 cm. 37 | 500 _aFor piano, vibraphone, drums, and double bass. 38 | 505 0 _aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 39 | 650 0 _aJazz. 40 | 650 0 _aMotion picture music 41 | _vExcerpts 42 | _vScores. 43 | 700 12 _aLewis, John, 44 | _d1920- 45 | _tSelections. 46 | _f1977. 47 | 700 12 _aJackson, Milt. 48 | _tMartyrs. 49 | _f1977. 50 | 700 12 _aJackson, Milt. 51 | _tLegendary profile. 52 | _f1977. 53 | 740 4 _aThe legendary profile. 54 | 852 00 _bMUSIC 55 | _cMAIN 56 | _kfolio 57 | _hM1366 58 | _iM62 59 | _91 60 | _4Marvin Duchow Music 61 | _5 62 | 63 | LDR 01293cjm 2200289 a 4500 64 | 001 001878039 65 | 005 20050110174900.0 66 | 007 sd fungnn|||e| 67 | 008 940202r19931981nyujzn i d 68 | 024 1 _a7464573372 69 | 028 02 _aJK 57337 70 | _bRed Baron 71 | 035 _a(OCoLC)29737267 72 | 040 _aSVP 73 | _cSVP 74 | _dLGG 75 | 100 1 _aDesmond, Paul, 76 | _d1924- 77 | 245 10 _aPaul Desmond & the Modern Jazz Quartet 78 | _h[sound recording] 79 | 260 _aNew York, N.Y. : 80 | _bRed Baron : 81 | _bManufactured by Sony Music Entertainment, 82 | _cp1993. 83 | 300 _a1 sound disc (39 min.) : 84 | _bdigital ; 85 | _c4 3/4 in. 86 | 511 0 _aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. 87 | 500 _aAll arrangements by John Lewis. 88 | 518 _aRecorded live on December 25, 1971 at Town Hall, NYC. 89 | 500 _aOriginally released in 1981 by Finesse as LP FW 27487. 90 | 500 _aProgram notes by Irving Townsend, June 1981, on container insert. 91 | 505 0 _aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 92 | 650 0 _aJazz 93 | _y1971-1980. 94 | 700 1 _aLewis, John, 95 | _d1920- 96 | 710 2 _aModern Jazz Quartet. 97 | 740 0 _aPaul Desmond and the Modern Jazz Quartet. 98 | 99 | LDR 01829cjm 2200385 a 4500 100 | 001 001964482 101 | 005 20060626132700.0 102 | 007 sd fzngnn|m|e| 103 | 008 871211p19871957nyujzn d 104 | 024 1 _a4228332902 105 | 028 01 _a833 290-2 106 | _bVerve 107 | 033 0 _a19571027 108 | _b6299 109 | _cD56 110 | 033 0 _a196112-- 111 | _b3804 112 | _cN4 113 | 033 0 _a19571019 114 | _b4104 115 | _cC6 116 | 033 0 _a197107-- 117 | _b6299 118 | _cV7 119 | 035 _a(OCoLC)17222092 120 | 040 _aCPL 121 | _cCPL 122 | _dOCL 123 | _dLGG 124 | 048 _apz01 125 | _aka01 126 | _asd01 127 | _apd01 128 | 110 2 _aModern Jazz Quartet. 129 | _4prf 130 | 245 14 _aThe Modern Jazz Quartet plus 131 | _h[sound recording]. 132 | 260 _a[New York] : 133 | _bVerve, 134 | _cp1987. 135 | 300 _a1 sound disc : 136 | _bdigital ; 137 | _c4 3/4 in. 138 | 440 0 _aCompact jazz 139 | 511 0 _aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. 140 | 518 _aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). 141 | 500 _aCompact disc. 142 | 500 _aAnalog recording. 143 | 505 0 _aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 144 | 650 0 _aJazz. 145 | 700 1 _aJackson, Milt. 146 | _4prf 147 | 700 1 _aPeterson, Oscar, 148 | _d1925- 149 | _4prf 150 | 700 1 _aBrown, Ray, 151 | _d1926-2002. 152 | _4prf 153 | 700 1 _aThigpen, Ed. 154 | _4prf 155 | 700 1 _aHayes, Louis, 156 | _d1937- 157 | _4prf 158 | 852 80 _bMUSIC 159 | _cAV 160 | _hCD 1131 161 | _4Marvin Duchow Music 162 | _5Audio-Visual 163 | -------------------------------------------------------------------------------- /tests/marc_011.phpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pear/File_MARC/7085b9e81ee433b5b75eb454d30ab619b8eccacc/tests/marc_011.phpt -------------------------------------------------------------------------------- /tests/marc_012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_012: test isControlField() and isDataField() convenience methods 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | $fields = $marc_record->getFields(); 13 | foreach ($fields as $field) { 14 | print $field->getTag(); 15 | if ($field->isControlField()) { 16 | print "\tControl field!"; 17 | } 18 | if ($field->isDataField()) { 19 | print "\tData field!"; 20 | } 21 | print "\n"; 22 | } 23 | } 24 | 25 | ?> 26 | --EXPECT-- 27 | 001 Control field! 28 | 004 Control field! 29 | 005 Control field! 30 | 008 Control field! 31 | 010 Data field! 32 | 035 Data field! 33 | 035 Data field! 34 | 040 Data field! 35 | 050 Data field! 36 | 245 Data field! 37 | 260 Data field! 38 | 300 Data field! 39 | 500 Data field! 40 | 505 Data field! 41 | 650 Data field! 42 | 650 Data field! 43 | 700 Data field! 44 | 700 Data field! 45 | 700 Data field! 46 | 740 Data field! 47 | 852 Data field! 48 | 001 Control field! 49 | 005 Control field! 50 | 007 Control field! 51 | 008 Control field! 52 | 024 Data field! 53 | 028 Data field! 54 | 035 Data field! 55 | 040 Data field! 56 | 100 Data field! 57 | 245 Data field! 58 | 260 Data field! 59 | 300 Data field! 60 | 511 Data field! 61 | 500 Data field! 62 | 518 Data field! 63 | 500 Data field! 64 | 500 Data field! 65 | 505 Data field! 66 | 650 Data field! 67 | 700 Data field! 68 | 710 Data field! 69 | 740 Data field! 70 | 001 Control field! 71 | 005 Control field! 72 | 007 Control field! 73 | 008 Control field! 74 | 024 Data field! 75 | 028 Data field! 76 | 033 Data field! 77 | 033 Data field! 78 | 033 Data field! 79 | 033 Data field! 80 | 035 Data field! 81 | 040 Data field! 82 | 048 Data field! 83 | 110 Data field! 84 | 245 Data field! 85 | 260 Data field! 86 | 300 Data field! 87 | 440 Data field! 88 | 511 Data field! 89 | 518 Data field! 90 | 500 Data field! 91 | 500 Data field! 92 | 505 Data field! 93 | 650 Data field! 94 | 700 Data field! 95 | 700 Data field! 96 | 700 Data field! 97 | 700 Data field! 98 | 700 Data field! 99 | 852 Data field! 100 | -------------------------------------------------------------------------------- /tests/marc_014.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_014: Add fields to a MARC record 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next(); 13 | 14 | // create some subfields 15 | $subfields[] = new File_MARC_Subfield('a', 'nothing'); 16 | $subfields[] = new File_MARC_Subfield('z', 'everything'); 17 | 18 | // create a data field 19 | $data_field = new File_MARC_Data_Field('100', $subfields, '0'); 20 | 21 | // append the data field 22 | $marc_record->appendField($data_field); 23 | 24 | // create a control field 25 | $ctrl_field = new File_MARC_Control_Field('001', '01234567890'); 26 | 27 | // prepend the control field 28 | $marc_record->prependField($ctrl_field); 29 | 30 | // reproduce test case reported by Mark Jordan 31 | $subfields_966_2[] = new File_MARC_Subfield('l', 'web'); 32 | $subfields_966_2[] = new File_MARC_Subfield('r', '0'); 33 | $subfields_966_2[] = new File_MARC_Subfield('s', 'b'); 34 | $subfields_966_2[] = new File_MARC_Subfield('i', '49'); 35 | $subfields_966_2[] = new File_MARC_Subfield('c', '1'); 36 | $field_966_2 = new File_MARC_Data_Field('966', $subfields_966_2, null, null); 37 | $marc_record->appendField($field_966_2); 38 | 39 | // let's see the results 40 | print utf8_encode($marc_record); 41 | print "\n"; 42 | 43 | ?> 44 | --EXPECT-- 45 | LDR 01850 2200517 4500 46 | 001 01234567890 47 | 001 0000000044 48 | 003 EMILDA 49 | 008 980120s1998 fi j 000 0 swe 50 | 020 _a9515008808 51 | _cFIM 72:00 52 | 035 _99515008808 53 | 040 _aNB 54 | 042 _9NB 55 | _9SEE 56 | 084 _aHcd,u 57 | _2kssb/6 58 | 084 _5NB 59 | _auHc 60 | _2kssb 61 | 084 _5SEE 62 | _aHcf 63 | _2kssb/6 64 | 084 _5Q 65 | _aHcd,uf 66 | _2kssb/6 67 | 100 1 _aJansson, Tove, 68 | _d1914-2001 69 | 245 04 _aDet osynliga barnet och andra berättelser / 70 | _cTove Jansson 71 | 250 _a7. uppl. 72 | 260 _aHelsingfors : 73 | _bSchildt, 74 | _c1998 ; 75 | _e(Falun : 76 | _fScandbook) 77 | 300 _a166, [4] s. : 78 | _bill. ; 79 | _c21 cm 80 | 440 0 _aMumin-biblioteket, 81 | _x99-0698931-9 82 | 500 _aOriginaluppl. 1962 83 | 599 _aLi: S 84 | 740 4 _aDet osynliga barnet 85 | 775 1 _z951-50-0385-7 86 | _w9515003857 87 | _907 88 | 841 _5Li 89 | _axa 90 | _b0201080u 0 4000uu |000000 91 | _e1 92 | 841 _5SEE 93 | _axa 94 | _b0201080u 0 4000uu |000000 95 | _e1 96 | 841 _5L 97 | _axa 98 | _b0201080u 0 4000uu |000000 99 | _e1 100 | 841 _5NB 101 | _axa 102 | _b0201080u 0 4000uu |000000 103 | _e1 104 | 841 _5Q 105 | _axa 106 | _b0201080u 0 4000uu |000000 107 | _e1 108 | 841 _5S 109 | _axa 110 | _b0201080u 0 4000uu |000000 111 | _e1 112 | 852 _5NB 113 | _bNB 114 | _cNB98:12 115 | _hplikt 116 | _jR, 980520 117 | 852 _5Li 118 | _bLi 119 | _cCNB 120 | _hh,u 121 | 852 _5SEE 122 | _bSEE 123 | 852 _5Q 124 | _bQ 125 | _j98947 126 | 852 _5L 127 | _bL 128 | _c0100 129 | _h98/ 130 | _j3043 H 131 | 852 _5S 132 | _bS 133 | _hSv97 134 | _j7235 135 | 900 1s _aYanson, Tobe, 136 | _d1914-2001 137 | _uJansson, Tove, 138 | _d1914-2001 139 | 900 1s _aJanssonová, Tove, 140 | _d1914-2001 141 | _uJansson, Tove, 142 | _d1914-2001 143 | 900 1s _aJansone, Tuve, 144 | _d1914-2001 145 | _uJansson, Tove, 146 | _d1914-2001 147 | 900 1s _aJanson, Tuve, 148 | _d1914-2001 149 | _uJansson, Tove, 150 | _d1914-2001 151 | 900 1s _aJansson, Tuve, 152 | _d1914-2001 153 | _uJansson, Tove, 154 | _d1914-2001 155 | 900 1s _aJanssonova, Tove, 156 | _d1914-2001 157 | _uJansson, Tove, 158 | _d1914-2001 159 | 976 2 _aHcd,u 160 | _bSkönlitteratur 161 | 005 20050204111518.0 162 | 100 0 _anothing 163 | _zeverything 164 | 966 _lweb 165 | _r0 166 | _sb 167 | _i49 168 | _c1 169 | -------------------------------------------------------------------------------- /tests/marc_015.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_015: ensure that pandemonium does not occur if a record doesn't have a given field 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | 13 | // Record #2 doesn't contain an 852; getField() returns false 14 | $mfhd = $marc_record->getField('852'); 15 | if ($mfhd) { 16 | $mfhd = $mfhd->getSubfield('b'); 17 | } 18 | 19 | print $marc_record; 20 | print "\n"; 21 | } 22 | ?> 23 | --EXPECT-- 24 | LDR 01145ncm 2200277 i 4500 25 | 001 000073594 26 | 004 AAJ5802 27 | 005 20030415102100.0 28 | 008 801107s1977 nyujza 29 | 010 _a 77771106 30 | 035 _a(CaOTUIC)15460184 31 | 035 9 _aAAJ5802 32 | 040 _aLC 33 | 050 00 _aM1366 34 | _b.M62 35 | _dM1527.2 36 | 245 04 _aThe Modern Jazz Quartet : 37 | _bThe legendary profile. -- 38 | 260 _aNew York : 39 | _bM.J.Q. Music, 40 | _cc1977. 41 | 300 _ascore (72 p.) ; 42 | _c31 cm. 43 | 500 _aFor piano, vibraphone, drums, and double bass. 44 | 505 0 _aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 45 | 650 0 _aJazz. 46 | 650 0 _aMotion picture music 47 | _vExcerpts 48 | _vScores. 49 | 700 12 _aLewis, John, 50 | _d1920- 51 | _tSelections. 52 | _f1977. 53 | 700 12 _aJackson, Milt. 54 | _tMartyrs. 55 | _f1977. 56 | 700 12 _aJackson, Milt. 57 | _tLegendary profile. 58 | _f1977. 59 | 740 4 _aThe legendary profile. 60 | 852 00 _bMUSIC 61 | _cMAIN 62 | _kfolio 63 | _hM1366 64 | _iM62 65 | _91 66 | _4Marvin Duchow Music 67 | _5 68 | 69 | LDR 01293cjm 2200289 a 4500 70 | 001 001878039 71 | 005 20050110174900.0 72 | 007 sd fungnn|||e| 73 | 008 940202r19931981nyujzn i d 74 | 024 1 _a7464573372 75 | 028 02 _aJK 57337 76 | _bRed Baron 77 | 035 _a(OCoLC)29737267 78 | 040 _aSVP 79 | _cSVP 80 | _dLGG 81 | 100 1 _aDesmond, Paul, 82 | _d1924- 83 | 245 10 _aPaul Desmond & the Modern Jazz Quartet 84 | _h[sound recording] 85 | 260 _aNew York, N.Y. : 86 | _bRed Baron : 87 | _bManufactured by Sony Music Entertainment, 88 | _cp1993. 89 | 300 _a1 sound disc (39 min.) : 90 | _bdigital ; 91 | _c4 3/4 in. 92 | 511 0 _aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. 93 | 500 _aAll arrangements by John Lewis. 94 | 518 _aRecorded live on December 25, 1971 at Town Hall, NYC. 95 | 500 _aOriginally released in 1981 by Finesse as LP FW 27487. 96 | 500 _aProgram notes by Irving Townsend, June 1981, on container insert. 97 | 505 0 _aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 98 | 650 0 _aJazz 99 | _y1971-1980. 100 | 700 1 _aLewis, John, 101 | _d1920- 102 | 710 2 _aModern Jazz Quartet. 103 | 740 0 _aPaul Desmond and the Modern Jazz Quartet. 104 | 105 | LDR 01829cjm 2200385 a 4500 106 | 001 001964482 107 | 005 20060626132700.0 108 | 007 sd fzngnn|m|e| 109 | 008 871211p19871957nyujzn d 110 | 024 1 _a4228332902 111 | 028 01 _a833 290-2 112 | _bVerve 113 | 033 0 _a19571027 114 | _b6299 115 | _cD56 116 | 033 0 _a196112-- 117 | _b3804 118 | _cN4 119 | 033 0 _a19571019 120 | _b4104 121 | _cC6 122 | 033 0 _a197107-- 123 | _b6299 124 | _cV7 125 | 035 _a(OCoLC)17222092 126 | 040 _aCPL 127 | _cCPL 128 | _dOCL 129 | _dLGG 130 | 048 _apz01 131 | _aka01 132 | _asd01 133 | _apd01 134 | 110 2 _aModern Jazz Quartet. 135 | _4prf 136 | 245 14 _aThe Modern Jazz Quartet plus 137 | _h[sound recording]. 138 | 260 _a[New York] : 139 | _bVerve, 140 | _cp1987. 141 | 300 _a1 sound disc : 142 | _bdigital ; 143 | _c4 3/4 in. 144 | 440 0 _aCompact jazz 145 | 511 0 _aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. 146 | 518 _aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). 147 | 500 _aCompact disc. 148 | 500 _aAnalog recording. 149 | 505 0 _aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 150 | 650 0 _aJazz. 151 | 700 1 _aJackson, Milt. 152 | _4prf 153 | 700 1 _aPeterson, Oscar, 154 | _d1925- 155 | _4prf 156 | 700 1 _aBrown, Ray, 157 | _d1926-2002. 158 | _4prf 159 | 700 1 _aThigpen, Ed. 160 | _4prf 161 | 700 1 _aHayes, Louis, 162 | _d1937- 163 | _4prf 164 | 852 80 _bMUSIC 165 | _cAV 166 | _hCD 1131 167 | _4Marvin Duchow Music 168 | _5Audio-Visual 169 | -------------------------------------------------------------------------------- /tests/marc_017.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_017: iterate and print a MARC record to JSON format 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record->toJSON(); 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | {"leader":"01850 2200517 4500","fields":[{"001":"0000000044"},{"003":"EMILDA"},{"008":"980120s1998 fi j 000 0 swe"},{"020":{"ind1":" ","ind2":" ","subfields":[{"a":"9515008808"},{"c":"FIM 72:00"}]}},{"035":{"ind1":" ","ind2":" ","subfields":[{"9":"9515008808"}]}},{"040":{"ind1":" ","ind2":" ","subfields":[{"a":"NB"}]}},{"042":{"ind1":" ","ind2":" ","subfields":[{"9":"NB"},{"9":"SEE"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"a":"Hcd,u"},{"2":"kssb\/6"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"5":"NB"},{"a":"uHc"},{"2":"kssb"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"5":"SEE"},{"a":"Hcf"},{"2":"kssb\/6"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"5":"Q"},{"a":"Hcd,uf"},{"2":"kssb\/6"}]}},{"100":{"ind1":"1","ind2":" ","subfields":[{"a":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"245":{"ind1":"0","ind2":"4","subfields":[{"a":"Det osynliga barnet och andra ber\u00e4ttelser \/"},{"c":"Tove Jansson"}]}},{"250":{"ind1":" ","ind2":" ","subfields":[{"a":"7. uppl."}]}},{"260":{"ind1":" ","ind2":" ","subfields":[{"a":"Helsingfors :"},{"b":"Schildt,"},{"c":"1998 ;"},{"e":"(Falun :"},{"f":"Scandbook)"}]}},{"300":{"ind1":" ","ind2":" ","subfields":[{"a":"166, [4] s. :"},{"b":"ill. ;"},{"c":"21 cm"}]}},{"440":{"ind1":" ","ind2":"0","subfields":[{"a":"Mumin-biblioteket,"},{"x":"99-0698931-9"}]}},{"500":{"ind1":" ","ind2":" ","subfields":[{"a":"Originaluppl. 1962"}]}},{"599":{"ind1":" ","ind2":" ","subfields":[{"a":"Li: S"}]}},{"740":{"ind1":"4","ind2":" ","subfields":[{"a":"Det osynliga barnet"}]}},{"775":{"ind1":"1","ind2":" ","subfields":[{"z":"951-50-0385-7"},{"w":"9515003857"},{"9":"07"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"Li"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"SEE"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"L"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"NB"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"Q"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"S"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"NB"},{"b":"NB"},{"c":"NB98:12"},{"h":"plikt"},{"j":"R, 980520"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"Li"},{"b":"Li"},{"c":"CNB"},{"h":"h,u"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"SEE"},{"b":"SEE"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"Q"},{"b":"Q"},{"j":"98947"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"L"},{"b":"L"},{"c":"0100"},{"h":"98\/"},{"j":"3043 H"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"S"},{"b":"S"},{"h":"Sv97"},{"j":"7235"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Yanson, Tobe,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Janssonov\u00e1, Tove,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Jansone, Tuve,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Janson, Tuve,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Jansson, Tuve,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Janssonova, Tove,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"976":{"ind1":" ","ind2":"2","subfields":[{"a":"Hcd,u"},{"b":"Sk\u00f6nlitteratur"}]}},{"005":"20050204111518.0"}]} 18 | -------------------------------------------------------------------------------- /tests/marc_018.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_018: iterate and print a MARC record to JSON MARC-HASH format 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record->toJSONHash(); 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | {"type":"marc-hash","version":[1,0],"leader":"01850 2200517 4500","fields":[["001","0000000044"],["003","EMILDA"],["008","980120s1998 fi j 000 0 swe"],["020"," "," ",[["a","9515008808"],["c","FIM 72:00"]]],["035"," "," ",[["9","9515008808"]]],["040"," "," ",[["a","NB"]]],["042"," "," ",[["9","NB"],["9","SEE"]]],["084"," "," ",[["a","Hcd,u"],["2","kssb\/6"]]],["084"," "," ",[["5","NB"],["a","uHc"],["2","kssb"]]],["084"," "," ",[["5","SEE"],["a","Hcf"],["2","kssb\/6"]]],["084"," "," ",[["5","Q"],["a","Hcd,uf"],["2","kssb\/6"]]],["100","1"," ",[["a","Jansson, Tove,"],["d","1914-2001"]]],["245","0","4",[["a","Det osynliga barnet och andra ber\u00e4ttelser \/"],["c","Tove Jansson"]]],["250"," "," ",[["a","7. uppl."]]],["260"," "," ",[["a","Helsingfors :"],["b","Schildt,"],["c","1998 ;"],["e","(Falun :"],["f","Scandbook)"]]],["300"," "," ",[["a","166, [4] s. :"],["b","ill. ;"],["c","21 cm"]]],["440"," ","0",[["a","Mumin-biblioteket,"],["x","99-0698931-9"]]],["500"," "," ",[["a","Originaluppl. 1962"]]],["599"," "," ",[["a","Li: S"]]],["740","4"," ",[["a","Det osynliga barnet"]]],["775","1"," ",[["z","951-50-0385-7"],["w","9515003857"],["9","07"]]],["841"," "," ",[["5","Li"],["a","xa"],["b","0201080u 0 4000uu |000000"],["e","1"]]],["841"," "," ",[["5","SEE"],["a","xa"],["b","0201080u 0 4000uu |000000"],["e","1"]]],["841"," "," ",[["5","L"],["a","xa"],["b","0201080u 0 4000uu |000000"],["e","1"]]],["841"," "," ",[["5","NB"],["a","xa"],["b","0201080u 0 4000uu |000000"],["e","1"]]],["841"," "," ",[["5","Q"],["a","xa"],["b","0201080u 0 4000uu |000000"],["e","1"]]],["841"," "," ",[["5","S"],["a","xa"],["b","0201080u 0 4000uu |000000"],["e","1"]]],["852"," "," ",[["5","NB"],["b","NB"],["c","NB98:12"],["h","plikt"],["j","R, 980520"]]],["852"," "," ",[["5","Li"],["b","Li"],["c","CNB"],["h","h,u"]]],["852"," "," ",[["5","SEE"],["b","SEE"]]],["852"," "," ",[["5","Q"],["b","Q"],["j","98947"]]],["852"," "," ",[["5","L"],["b","L"],["c","0100"],["h","98\/"],["j","3043 H"]]],["852"," "," ",[["5","S"],["b","S"],["h","Sv97"],["j","7235"]]],["900","1","s",[["a","Yanson, Tobe,"],["d","1914-2001"],["u","Jansson, Tove,"],["d","1914-2001"]]],["900","1","s",[["a","Janssonov\u00e1, Tove,"],["d","1914-2001"],["u","Jansson, Tove,"],["d","1914-2001"]]],["900","1","s",[["a","Jansone, Tuve,"],["d","1914-2001"],["u","Jansson, Tove,"],["d","1914-2001"]]],["900","1","s",[["a","Janson, Tuve,"],["d","1914-2001"],["u","Jansson, Tove,"],["d","1914-2001"]]],["900","1","s",[["a","Jansson, Tuve,"],["d","1914-2001"],["u","Jansson, Tove,"],["d","1914-2001"]]],["900","1","s",[["a","Janssonova, Tove,"],["d","1914-2001"],["u","Jansson, Tove,"],["d","1914-2001"]]],["976"," ","2",[["a","Hcd,u"],["b","Sk\u00f6nlitteratur"]]],["005","20050204111518.0"]]} 18 | -------------------------------------------------------------------------------- /tests/marc_019.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_019: generate a MARCXML record not in a collection element 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next(); 14 | 15 | // Change each 852 $c to "Audio-Visual" 16 | $holdings = $record->getFields('852'); 17 | foreach ($holdings as $holding) { 18 | 19 | // Get the $c subfields from this field 20 | $formats = $holding->getSubfields('c'); 21 | foreach ($formats as $format) { 22 | if ($format->getData('AV')) { 23 | $format->setData('Audio-Visual'); 24 | } 25 | } 26 | } 27 | 28 | // Generate the XML output for this record 29 | print($record->toXML('UTF-8', true, true)); 30 | --EXPECT-- 31 | 32 | 33 | 34 | 01145ncm 2200277 i 4500 35 | 000073594 36 | AAJ5802 37 | 20030415102100.0 38 | 801107s1977 nyujza 39 | 40 | 77771106 41 | 42 | 43 | (CaOTUIC)15460184 44 | 45 | 46 | AAJ5802 47 | 48 | 49 | LC 50 | 51 | 52 | M1366 53 | .M62 54 | M1527.2 55 | 56 | 57 | The Modern Jazz Quartet : 58 | The legendary profile. -- 59 | 60 | 61 | New York : 62 | M.J.Q. Music, 63 | c1977. 64 | 65 | 66 | score (72 p.) ; 67 | 31 cm. 68 | 69 | 70 | For piano, vibraphone, drums, and double bass. 71 | 72 | 73 | Lewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 74 | 75 | 76 | Jazz. 77 | 78 | 79 | Motion picture music 80 | Excerpts 81 | Scores. 82 | 83 | 84 | Lewis, John, 85 | 1920- 86 | Selections. 87 | 1977. 88 | 89 | 90 | Jackson, Milt. 91 | Martyrs. 92 | 1977. 93 | 94 | 95 | Jackson, Milt. 96 | Legendary profile. 97 | 1977. 98 | 99 | 100 | The legendary profile. 101 | 102 | 103 | MUSIC 104 | Audio-Visual 105 | folio 106 | M1366 107 | M62 108 | 1 109 | Marvin Duchow Music 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /tests/marc_020.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_020: Test MARC binary output 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next(); 13 | 14 | // create some subfields 15 | $subfields[] = new File_MARC_Subfield('a', 'nothing'); 16 | $subfields[] = new File_MARC_Subfield('z', 'everything'); 17 | 18 | // create a data field 19 | $data_field = new File_MARC_Data_Field('100', $subfields, '0'); 20 | 21 | // append the data field 22 | $marc_record->appendField($data_field); 23 | 24 | // create a control field 25 | $ctrl_field = new File_MARC_Control_Field('001', '01234567890'); 26 | 27 | // prepend the control field 28 | $marc_record->prependField($ctrl_field); 29 | 30 | // reproduce test case reported by Mark Jordan 31 | $subfields_966_2[] = new File_MARC_Subfield('l', 'web'); 32 | $subfields_966_2[] = new File_MARC_Subfield('r', '0'); 33 | $subfields_966_2[] = new File_MARC_Subfield('s', 'b'); 34 | $subfields_966_2[] = new File_MARC_Subfield('i', '49'); 35 | $subfields_966_2[] = new File_MARC_Subfield('c', '1'); 36 | $field_966_2 = new File_MARC_Data_Field('966', $subfields_966_2, null, null); 37 | $marc_record->appendField($field_966_2); 38 | 39 | // let's see the results 40 | print convert_uuencode($marc_record->toRaw()); 41 | 42 | ?> 43 | --EXPECT-- 44 | M,#$Y-#,@("`@(#(R,#`U-3,@("`T-3`P,#`Q,#`Q,C`P,#`P,#`Q,#`Q,3`P 45 | M,#$R,#`S,#`P-S`P,#(S,#`X,#`S.3`P,#,P,#(P,#`R-C`P,#8Y,#,U,#`Q 46 | M-3`P,#DU,#0P,#`P-S`P,3$P,#0R,#`Q,C`P,3$W,#@T,#`Q.#`P,3(Y,#@T 47 | M,#`Q.#`P,30W,#@T,#`R,3`P,38U,#@T,#`R,C`P,3@V,3`P,#`S,#`P,C`X 48 | M,C0U,#`V,C`P,C,X,C4P,#`Q,S`P,S`P,C8P,#`U.#`P,S$S,S`P,#`S,S`P 49 | M,S14U)3$1!'CDX 57 | M,#$R,',Q.3DX("`@(&9I("`@("!J("`@("`@,#`P(#`@("`?.3DU,34P,#@X,#@>("`?84Y"'B`@'SE. 59 | M0A\Y4T5%'B`@'V%(8V0L=1\R:W-S8B\V'B`@'S5.0A]A=4AC'S)K6YL:6=A(&)A 62 | M(#`?84UU;6EN+6)I8FQI;W1E:V5T+!]X.3DM,#8Y.#DS 66 | M,2TY'B`@'V%/("`?84QI.B!3'C0@'V%$970@ 67 | M;W-Y;FQI9V$@8F%R;F5T'C$@'WHY-3$M-3`M,#,X-2TW'W("`?-4P?87AA'V(P,C`Q,#@P=2`@("`P("`@-#`P,'5U 71 | M("`@?#`P,#`P,!]E,1X@(!\U3D(?87AA'V(P,C`Q,#@P=2`@("`P("`@-#`P 72 | M,'5U("`@?#`P,#`P,!]E,1X@(!\U41]A>&$?8C`R,#$P.#!U("`@(#`@("`T 73 | M,#`P=74@("!\,#`P,#`P'V4Q'B`@'S53'V%X81]B,#(P,3`X,'4@("`@,"`@ 74 | M(#0P,#!U=2`@('PP,#`P,#`?93$>("`?-4Y"'V).0A]C3D(Y.#HQ,A]H<&QI 75 | M:W0?:E(L(#DX,#4R,!X@(!\U3&D?8DQI'V-#3D(?:&@L=1X@(!\U4T5%'V)3 76 | M144>("`?-5$?8E$?:CDX.30W'B`@'S5,'V),'V,P,3`P'V@Y."\?:C,P-#,@ 77 | M2!X@(!\U4Q]B4Q]H4W8Y-Q]J-S(S-1XQ,7,?84IA;G-S;VXL(%1U=F4L 83 | M'V0Q.3$T+3(P,#$?=4IA;G-S;VXL(%1O=F4L'V0Q.3$T+3(P,#$>,7,?84IA 84 | M;G-S;VYO=F$L(%1O=F4L'V0Q.3$T+3(P,#$?=4IA;G-S;VXL(%1O=F4L'V0Q 85 | M.3$T+3(P,#$>(#(?84AC9"QU'V)3:_9N;&ET=&5R871U71H:6YG'B`@'VQW96(? 5 | --FILE-- 6 | next()) { 12 | // create some subfields 13 | $subfields[] = new File_MARC_Subfield('0', 'nothing'); 14 | $subfields[] = new File_MARC_Subfield('1', 'everything'); 15 | $field = new File_MARC_Data_Field('999', $subfields, '', ''); 16 | $marc_record->appendField($field); 17 | 18 | $subfields = null; 19 | $field = null; 20 | $subfields[] = new File_MARC_Subfield('a', 'bee'); 21 | $subfields[] = new File_MARC_Subfield('0', 'cee'); 22 | $subfields[] = new File_MARC_Subfield('d', 'eee'); 23 | $field = new File_MARC_Data_Field('999', $subfields, '', ''); 24 | 25 | $marc_record->appendField($field); 26 | 27 | print $marc_record->toJSON(); 28 | print "\n"; 29 | } 30 | ?> 31 | --EXPECT-- 32 | {"leader":"01850 2200517 4500","fields":[{"001":"0000000044"},{"003":"EMILDA"},{"008":"980120s1998 fi j 000 0 swe"},{"020":{"ind1":" ","ind2":" ","subfields":[{"a":"9515008808"},{"c":"FIM 72:00"}]}},{"035":{"ind1":" ","ind2":" ","subfields":[{"9":"9515008808"}]}},{"040":{"ind1":" ","ind2":" ","subfields":[{"a":"NB"}]}},{"042":{"ind1":" ","ind2":" ","subfields":[{"9":"NB"},{"9":"SEE"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"a":"Hcd,u"},{"2":"kssb\/6"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"5":"NB"},{"a":"uHc"},{"2":"kssb"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"5":"SEE"},{"a":"Hcf"},{"2":"kssb\/6"}]}},{"084":{"ind1":" ","ind2":" ","subfields":[{"5":"Q"},{"a":"Hcd,uf"},{"2":"kssb\/6"}]}},{"100":{"ind1":"1","ind2":" ","subfields":[{"a":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"245":{"ind1":"0","ind2":"4","subfields":[{"a":"Det osynliga barnet och andra ber\u00e4ttelser \/"},{"c":"Tove Jansson"}]}},{"250":{"ind1":" ","ind2":" ","subfields":[{"a":"7. uppl."}]}},{"260":{"ind1":" ","ind2":" ","subfields":[{"a":"Helsingfors :"},{"b":"Schildt,"},{"c":"1998 ;"},{"e":"(Falun :"},{"f":"Scandbook)"}]}},{"300":{"ind1":" ","ind2":" ","subfields":[{"a":"166, [4] s. :"},{"b":"ill. ;"},{"c":"21 cm"}]}},{"440":{"ind1":" ","ind2":"0","subfields":[{"a":"Mumin-biblioteket,"},{"x":"99-0698931-9"}]}},{"500":{"ind1":" ","ind2":" ","subfields":[{"a":"Originaluppl. 1962"}]}},{"599":{"ind1":" ","ind2":" ","subfields":[{"a":"Li: S"}]}},{"740":{"ind1":"4","ind2":" ","subfields":[{"a":"Det osynliga barnet"}]}},{"775":{"ind1":"1","ind2":" ","subfields":[{"z":"951-50-0385-7"},{"w":"9515003857"},{"9":"07"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"Li"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"SEE"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"L"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"NB"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"Q"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"841":{"ind1":" ","ind2":" ","subfields":[{"5":"S"},{"a":"xa"},{"b":"0201080u 0 4000uu |000000"},{"e":"1"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"NB"},{"b":"NB"},{"c":"NB98:12"},{"h":"plikt"},{"j":"R, 980520"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"Li"},{"b":"Li"},{"c":"CNB"},{"h":"h,u"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"SEE"},{"b":"SEE"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"Q"},{"b":"Q"},{"j":"98947"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"L"},{"b":"L"},{"c":"0100"},{"h":"98\/"},{"j":"3043 H"}]}},{"852":{"ind1":" ","ind2":" ","subfields":[{"5":"S"},{"b":"S"},{"h":"Sv97"},{"j":"7235"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Yanson, Tobe,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Janssonov\u00e1, Tove,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Jansone, Tuve,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Janson, Tuve,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Jansson, Tuve,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"900":{"ind1":"1","ind2":"s","subfields":[{"a":"Janssonova, Tove,"},{"d":"1914-2001"},{"u":"Jansson, Tove,"},{"d":"1914-2001"}]}},{"976":{"ind1":" ","ind2":"2","subfields":[{"a":"Hcd,u"},{"b":"Sk\u00f6nlitteratur"}]}},{"005":"20050204111518.0"},{"999":{"ind1":" ","ind2":" ","subfields":[{"0":"nothing"},{"1":"everything"}]}},{"999":{"ind1":" ","ind2":" ","subfields":[{"a":"bee"},{"0":"cee"},{"d":"eee"}]}}]} 33 | -------------------------------------------------------------------------------- /tests/marc_023.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_023: test extended Record interface 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getField('040')->getSubfield('a')->getData(); 13 | } 14 | } 15 | 16 | $marc_file = new File_MARC($dir . '/' . 'example.mrc', File_MARC::SOURCE_FILE, MyRecord::class); 17 | 18 | $rec = $marc_file->next(); 19 | print get_class($rec) . "\n"; 20 | print $rec->myNewMethod() . "\n"; 21 | 22 | ?> 23 | --EXPECT-- 24 | MyRecord 25 | NB 26 | -------------------------------------------------------------------------------- /tests/marc_024.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_024: read MARC-in-JSON serialization with subfield 0 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 15 | print $record->toRaw(); 16 | } 17 | print "\n"; 18 | ?> 19 | --EXPECT-- 20 | 01919 2200541 45000010011000000030007000110080039000180200026000570350015000830400007000980420012001050840018001170840018001350840021001530840022001741000030001962450063002262500013002892600058003023000033003604400037003935000023004305990010004537400024004637750034004878410048005218410049005698410047006188410048006658410047007138410047007608520038008078520021008458520013008668520016008798520028008958520021009239000056009449000061010009000057010619000056011189000057011749000060012319760027012910050017013189990024013359990018013590000000044EMILDA980120s1998 fi j 000 0 swe a9515008808cFIM 72:00 99515008808 aNB 9NB9SEE aHcd,u2kssb/6 5NBauHc2kssb 5SEEaHcf2kssb/6 5QaHcd,uf2kssb/61 aJansson, Tove,d1914-200104aDet osynliga barnet och andra berättelser /cTove Jansson a7. uppl. aHelsingfors :bSchildt,c1998 ;e(Falun :fScandbook) a166, [4] s. :bill. ;c21 cm 0aMumin-biblioteket,x99-0698931-9 aOriginaluppl. 1962 aLi: S4 aDet osynliga barnet1 z951-50-0385-7w9515003857907 5Liaxab0201080u 0 4000uu |000000e1 5SEEaxab0201080u 0 4000uu |000000e1 5Laxab0201080u 0 4000uu |000000e1 5NBaxab0201080u 0 4000uu |000000e1 5Qaxab0201080u 0 4000uu |000000e1 5Saxab0201080u 0 4000uu |000000e1 5NBbNBcNB98:12hpliktjR, 980520 5LibLicCNBhh,u 5SEEbSEE 5QbQj98947 5LbLc0100h98/j3043 H 5SbShSv97j72351saYanson, Tobe,d1914-2001uJansson, Tove,d1914-20011saJanssonová, Tove,d1914-2001uJansson, Tove,d1914-20011saJansone, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJansson, Tuve,d1914-2001uJansson, Tove,d1914-20011saJanssonova, Tove,d1914-2001uJansson, Tove,d1914-2001 2aHcd,ubSkönlitteratur20050204111518.0 0nothing1everything abee0ceedeee 21 | -------------------------------------------------------------------------------- /tests/marc_16783.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_16783: iterate and pretty print a non-compliant MARC record (tag = '30-') 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record; 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | LDR 01853 a2200517 4500 18 | 001 0000000044 19 | 003 EMILDA 20 | 008 980120s1998 fi j 000 0 swe 21 | 020 _a9515008808 22 | _cFIM 72:00 23 | 035 _99515008808 24 | 040 _aNB 25 | 042 _9NB 26 | _9SEE 27 | 084 _aHcd,u 28 | _2kssb/6 29 | 084 _5NB 30 | _auHc 31 | _2kssb 32 | 084 _5SEE 33 | _aHcf 34 | _2kssb/6 35 | 084 _5Q 36 | _aHcd,uf 37 | _2kssb/6 38 | 100 1 _aJansson, Tove, 39 | _d1914-2001 40 | 245 04 _aDet osynliga barnet och andra bert̃telser / 41 | _cTove Jansson 42 | 250 _a7. uppl. 43 | 260 _aHelsingfors : 44 | _bSchildt, 45 | _c1998 ; 46 | _e(Falun : 47 | _fScandbook) 48 | 440 0 _aMumin-biblioteket, 49 | _x99-0698931-9 50 | 500 _aOriginaluppl. 1962 51 | 599 _aLi: S 52 | 740 4 _aDet osynliga barnet 53 | 775 1 _z951-50-0385-7 54 | _w9515003857 55 | _907 56 | 841 _5Li 57 | _axa 58 | _b0201080u 0 4000uu |000000 59 | _e1 60 | 841 _5SEE 61 | _axa 62 | _b0201080u 0 4000uu |000000 63 | _e1 64 | 841 _5L 65 | _axa 66 | _b0201080u 0 4000uu |000000 67 | _e1 68 | 841 _5NB 69 | _axa 70 | _b0201080u 0 4000uu |000000 71 | _e1 72 | 841 _5Q 73 | _axa 74 | _b0201080u 0 4000uu |000000 75 | _e1 76 | 841 _5S 77 | _axa 78 | _b0201080u 0 4000uu |000000 79 | _e1 80 | 852 _5NB 81 | _bNB 82 | _cNB98:12 83 | _hplikt 84 | _jR, 980520 85 | 852 _5Li 86 | _bLi 87 | _cCNB 88 | _hh,u 89 | 852 _5SEE 90 | _bSEE 91 | 852 _5Q 92 | _bQ 93 | _j98947 94 | 852 _5L 95 | _bL 96 | _c0100 97 | _h98/ 98 | _j3043 H 99 | 852 _5S 100 | _bS 101 | _hSv97 102 | _j7235 103 | 900 1s _aYanson, Tobe, 104 | _d1914-2001 105 | _uJansson, Tove, 106 | _d1914-2001 107 | 900 1s _aJanssonov,̀ Tove, 108 | _d1914-2001 109 | _uJansson, Tove, 110 | _d1914-2001 111 | 900 1s _aJansone, Tuve, 112 | _d1914-2001 113 | _uJansson, Tove, 114 | _d1914-2001 115 | 900 1s _aJanson, Tuve, 116 | _d1914-2001 117 | _uJansson, Tove, 118 | _d1914-2001 119 | 900 1s _aJansson, Tuve, 120 | _d1914-2001 121 | _uJansson, Tove, 122 | _d1914-2001 123 | 900 1s _aJanssonova, Tove, 124 | _d1914-2001 125 | _uJansson, Tove, 126 | _d1914-2001 127 | 976 2 _aHcd,u 128 | _bSkn̲litteratur 129 | 005 20050204111518.0 130 | -------------------------------------------------------------------------------- /tests/marc_field_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_001: Exercise basic methods for File_MARC_Field class 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getTag() . "\n"; 19 | print "Get Ind1: " . $field->getIndicator(1) . "\n"; 20 | print "Get Ind2: " . $field->getIndicator(2) . "\n"; 21 | 22 | // test basic setter methods 23 | print "Set Ind1: " . $field->setIndicator(1, '3') . "\n"; 24 | 25 | // test pretty print 26 | print $field; 27 | print "\n"; 28 | 29 | // test raw print 30 | print $field->toRaw(); 31 | ?> 32 | --EXPECT-- 33 | Tag: 100 34 | Get Ind1: 0 35 | Get Ind2: 36 | Set Ind1: 3 37 | 100 3 _anothing 38 | _zeverything 39 | 3 anothingzeverything 40 | -------------------------------------------------------------------------------- /tests/marc_field_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_002: Create fields with invalid indicators 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMessage()}\n"; 20 | } 21 | --EXPECT-- 22 | Error: Illegal indicator "$@" in field "100" forced to blank 23 | -------------------------------------------------------------------------------- /tests/marc_field_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_003: Add subfields to an existing field 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | appendSubfield($subfield1); 26 | 27 | // insert a new subfield after the first subfield with code 'z' 28 | // expected order: a-z-k-g 29 | $sf = $field->getSubfields('z'); 30 | // we might get an array back; in this case, we want the first subfield 31 | if (is_array($sf)) { 32 | $field->insertSubfield($subfield2, $sf[0]); 33 | } 34 | else { 35 | $field->insertSubfield($subfield2, $sf); 36 | } 37 | 38 | // insert a new subfield prior to the first subfield with code 'z' 39 | // expected order: a-t-z-k-g 40 | $sf = $field->getSubfields('z'); 41 | // we might get an array back; in this case, we want the first subfield 42 | if (is_array($sf)) { 43 | $field->insertSubfield($subfield3, $sf[0], true); 44 | } 45 | else { 46 | $field->insertSubfield($subfield3, $sf, true); 47 | } 48 | 49 | // insert a new subfield at the very start of the field 50 | $field->prependSubfield($subfield4); 51 | 52 | // let's see the results 53 | print $field; 54 | print "\n"; 55 | 56 | ?> 57 | --EXPECT-- 58 | 100 0 _0first post 59 | _anothing 60 | _ta lot 61 | _zeverything 62 | _ka bit more 63 | _ga little 64 | -------------------------------------------------------------------------------- /tests/marc_field_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_004: Add subfields to an existing field (corner case) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getSubfields('a'); 22 | // we might get an array back; in this case, we want the first subfield 23 | if (is_array($sf)) { 24 | $field->insertSubfield($subfield1, $sf[0], true); 25 | } 26 | else { 27 | $field->insertSubfield($subfield1, $sf, true); 28 | } 29 | 30 | // let's see the results 31 | print $field; 32 | print "\n"; 33 | 34 | ?> 35 | --EXPECT-- 36 | 100 0 _ga little 37 | _anothing 38 | _zeverything 39 | -------------------------------------------------------------------------------- /tests/marc_field_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_005: Test method getContents 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getSubfields('a'); 22 | // we might get an array back; in this case, we want the first subfield 23 | if (is_array($sf)) { 24 | $field->insertSubfield($subfield1, $sf[0], true); 25 | } 26 | else { 27 | $field->insertSubfield($subfield1, $sf, true); 28 | } 29 | 30 | // let's see the results 31 | print $field->getContents(); 32 | print "\n"; 33 | print $field->getContents('###'); 34 | print "\n"; 35 | 36 | ?> 37 | --EXPECT-- 38 | a littlenothingeverything 39 | a little###nothing###everything 40 | -------------------------------------------------------------------------------- /tests/marc_field_006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_006: Test methods getSubfield and getSubfields 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getSubfield( '[a-z]', true ); 21 | $results = array_merge( $results, $field->getSubfields( 'a' ) ); 22 | $results = array_merge( $results, $field->getSubfields( '[a-z]', true ) ); 23 | $results = array_merge( $results, $field->getSubfields( '[0-9]', true ) ); 24 | $results = array_merge( $results, $field->getSubfields( '.', true ) ); 25 | 26 | foreach ($results AS $sf) { 27 | print $sf; 28 | print "\n"; 29 | } 30 | 31 | // Check for empty fields 32 | if ($field->getSubfield( 'd|4|n', true ) === false) { 33 | print "Nice! False as result for getSubfield.\n"; 34 | } 35 | 36 | $subfields_result = $field->getSubfields( 'd|4|n', true ); 37 | if ( is_array( $subfields_result ) && count( $subfields_result ) === 0 ) { 38 | print "Nice! Empty array as result for getSubfields.\n"; 39 | } 40 | ?> 41 | --EXPECT-- 42 | [a]: character 43 | [a]: character 44 | [a]: character 45 | [z]: another character 46 | [3]: number 47 | [3]: number 48 | [a]: character 49 | [z]: another character 50 | Nice! False as result for getSubfield. 51 | Nice! Empty array as result for getSubfields. 52 | -------------------------------------------------------------------------------- /tests/marc_field_21246.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_field_21246: Delete multiple subfields 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getSubfields('9') as $subfield) { 19 | echo "Deleting subfield: $subfield\n"; 20 | $field->deleteSubfield($subfield); 21 | } 22 | echo "\n--- After: ---\n$field\n\n"; 23 | ?> 24 | --EXPECT-- 25 | --- Before: --- 26 | 650 _9test1 27 | _9test2 28 | _0test3 29 | _9test4 30 | 31 | Deleting subfield: [9]: test1 32 | Deleting subfield: [9]: test2 33 | Deleting subfield: [9]: test4 34 | 35 | --- After: --- 36 | 650 _0test3 37 | -------------------------------------------------------------------------------- /tests/marc_lint_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_lint_001: Full test of Lint suite 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | next()) { 15 | $warnings = $marc_lint->checkRecord($marc_record); 16 | foreach ($warnings as $warning) { 17 | print $warning . "\n"; 18 | } 19 | } 20 | 21 | print "\nTest from a constructed record\n"; 22 | $rec = new File_MARC_Record(); 23 | $rec->setLeader("00000nam 22002538a 4500"); 24 | $rec->appendField( 25 | new File_MARC_Data_Field( 26 | '041', 27 | array( 28 | new File_MARC_Subfield('a', 'end'), 29 | new File_MARC_Subfield('a', 'fren') 30 | ), 31 | "0", "" 32 | ) 33 | ); 34 | $rec->appendField( 35 | new File_MARC_Data_Field( 36 | '043', 37 | array( 38 | new File_MARC_Subfield('a', 'n-us-pn') 39 | ), 40 | "", "" 41 | ) 42 | ); 43 | $rec->appendField( 44 | new File_MARC_Data_Field( 45 | '082', 46 | array( 47 | new File_MARC_Subfield('a', '005.13/3'), 48 | // typo 'R' for 'W' and missing 'b' subfield 49 | new File_MARC_Subfield('R', 'all'), 50 | new File_MARC_Subfield('2', '21') 51 | ), 52 | "0", "4" 53 | ) 54 | ); 55 | $rec->appendField( 56 | new File_MARC_Data_Field( 57 | '082', 58 | array( 59 | new File_MARC_Subfield('a', '005.13'), 60 | new File_MARC_Subfield('b', 'Wall'), 61 | new File_MARC_Subfield('2', '14') 62 | ), 63 | "1", "4" 64 | ) 65 | ); 66 | $rec->appendField( 67 | new File_MARC_Data_Field( 68 | '100', 69 | array( 70 | new File_MARC_Subfield('a', 'Wall, Larry') 71 | ), 72 | "1", "4" 73 | ) 74 | ); 75 | $rec->appendField( 76 | new File_MARC_Data_Field( 77 | '110', 78 | array( 79 | new File_MARC_Subfield('a', "O'Reilly & Associates.") 80 | ), 81 | "1", "" 82 | ) 83 | ); 84 | $rec->appendField( 85 | new File_MARC_Data_Field( 86 | '245', 87 | array( 88 | new File_MARC_Subfield('a', 'Programming Perl / '), 89 | new File_MARC_Subfield('a', 'Big Book of Perl /'), 90 | new File_MARC_Subfield('c', 'Larry Wall, Tom Christiansen & Jon Orwant.') 91 | ), 92 | "9", "0" 93 | ) 94 | ); 95 | $rec->appendField( 96 | new File_MARC_Data_Field( 97 | '250', 98 | array( 99 | new File_MARC_Subfield('a', '3rd ed.') 100 | ), 101 | "", "" 102 | ) 103 | ); 104 | $rec->appendField( 105 | new File_MARC_Data_Field( 106 | '250', 107 | array( 108 | new File_MARC_Subfield('a', '3rd ed.') 109 | ), 110 | "", "" 111 | ) 112 | ); 113 | $rec->appendField( 114 | new File_MARC_Data_Field( 115 | '260', 116 | array( 117 | new File_MARC_Subfield('a', 'Cambridge, Mass. : '), 118 | new File_MARC_Subfield('b', "O'Reilly, "), 119 | new File_MARC_Subfield('r', '2000.') 120 | ), 121 | "", "" 122 | ) 123 | ); 124 | $rec->appendField( 125 | new File_MARC_Data_Field( 126 | '590', 127 | array( 128 | new File_MARC_Subfield('a', 'Personally signed by Larry.') 129 | ), 130 | "4", "" 131 | ) 132 | ); 133 | $rec->appendField( 134 | new File_MARC_Data_Field( 135 | '650', 136 | array( 137 | new File_MARC_Subfield('a', 'Perl (Computer program language)'), 138 | new File_MARC_Subfield('0', '(DLC)sh 95010633') 139 | ), 140 | "", "0" 141 | ) 142 | ); 143 | $rec->appendField( 144 | new File_MARC_Data_Field( 145 | '856', 146 | array( 147 | new File_MARC_Subfield('u', 'http://www.perl.com/') 148 | ), 149 | "4", "3" 150 | ) 151 | ); 152 | $rec->appendField( 153 | new File_MARC_Data_Field( 154 | '886', 155 | array( 156 | new File_MARC_Subfield('4', 'Some foreign thing'), 157 | new File_MARC_Subfield('q', 'Another foreign thing') 158 | ), 159 | "0", "" 160 | ) 161 | ); 162 | $warnings = $marc_lint->checkRecord($rec); 163 | foreach ($warnings as $warning) { 164 | print $warning . "\n"; 165 | } 166 | 167 | ?> 168 | --EXPECT-- 169 | Test records in camel.mrc 170 | 100: Indicator 1 must be 0, 1 or 3 but it's "2" 171 | 007: Subfields are not allowed in fields lower than 010 172 | 173 | Test from a constructed record 174 | 1XX: Only one 1XX tag is allowed, but I found 2 of them. 175 | 041: Subfield _a, end (end), is not valid. 176 | 041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (fren). 177 | 043: Subfield _a, n-us-pn, is not valid. 178 | 082: Subfield _R is not allowed. 179 | 100: Indicator 2 must be blank but it's "4" 180 | 245: Indicator 1 must be 0 or 1 but it's "9" 181 | 245: Subfield _a is not repeatable. 182 | 260: Subfield _r is not allowed. 183 | 856: Indicator 2 must be blank, 0, 1, 2 or 8 but it's "3" 184 | -------------------------------------------------------------------------------- /tests/marc_lint_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_lint_002: Tests check041() and check043() called separately 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | check041($field); 43 | 44 | $field = new File_MARC_Data_Field( 45 | '041', 46 | array( 47 | new File_MARC_Subfield('a', 'endorviwo'), // invalid 48 | new File_MARC_Subfield('a', 'spanowpalasba') // too long and invalid 49 | ), 50 | "1", "" 51 | ); 52 | $marc_lint->check041($field); 53 | 54 | $field = new File_MARC_Data_Field( 55 | '043', 56 | array( 57 | new File_MARC_Subfield('a', 'n-----'), // 6 chars vs. 7 58 | new File_MARC_Subfield('a', 'n-us----'), // 8 chars vs. 7 59 | new File_MARC_Subfield('a', 'n-ma-us'), // invalid code 60 | new File_MARC_Subfield('a', 'e-ur-ai') // obsolete code 61 | ), 62 | "", "" 63 | ); 64 | $marc_lint->check043($field); 65 | 66 | ?> 67 | --EXPECT-- 68 | 041: Subfield _a, end (end), is not valid. 69 | 041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (span). 70 | 041: Subfield _h, far, may be obsolete. 71 | 041: Subfield _a, endorviwo (end), is not valid. 72 | 041: Subfield _a, endorviwo (orv), is not valid. 73 | 041: Subfield _a, endorviwo (iwo), is not valid. 74 | 041: Subfield _a must be evenly divisible by 3 or exactly three characters if ind2 is not 7, (spanowpalasba). 75 | 043: Subfield _a must be exactly 7 characters, n----- 76 | 043: Subfield _a must be exactly 7 characters, n-us---- 77 | 043: Subfield _a, n-ma-us, is not valid. 78 | 043: Subfield _a, e-ur-ai, may be obsolete. 79 | -------------------------------------------------------------------------------- /tests/marc_lint_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_lint_003: Tests for field 880 and for subfield 6 3 | --SKIPIF-- 4 | 5 | 6 | --FILE-- 7 | setLeader("00000nam 22002538a 4500"); 15 | $rec->appendField( 16 | new File_MARC_Control_Field( 17 | '001', 'ttt07000001 ' 18 | ) 19 | ); 20 | $rec->appendField( 21 | new File_MARC_Control_Field( 22 | '003', 'TEST ' 23 | ) 24 | ); 25 | $rec->appendField( 26 | new File_MARC_Control_Field( 27 | '008', '070520s2007 ilu 000 0 eng d' 28 | ) 29 | ); 30 | $rec->appendField( 31 | new File_MARC_Data_Field( 32 | '040', 33 | array( 34 | new File_MARC_Subfield('a', 'TEST'), 35 | new File_MARC_Subfield('c', 'TEST') 36 | ), 37 | "", "" 38 | ) 39 | ); 40 | $rec->appendField( 41 | new File_MARC_Data_Field( 42 | '050', 43 | array( 44 | new File_MARC_Subfield('a', 'RZ999'), 45 | new File_MARC_Subfield('b', '.J66 2007') 46 | ), 47 | "", "4" 48 | ) 49 | ); 50 | $rec->appendField( 51 | new File_MARC_Data_Field( 52 | '082', 53 | array( 54 | new File_MARC_Subfield('a', '615.8/9'), 55 | new File_MARC_Subfield('2', '22') 56 | ), 57 | "0", "4" 58 | ) 59 | ); 60 | $rec->appendField( 61 | new File_MARC_Data_Field( 62 | '100', 63 | array( 64 | new File_MARC_Subfield('a', 'Jones, John') 65 | ), 66 | "1", "" 67 | ) 68 | ); 69 | $rec->appendField( 70 | new File_MARC_Data_Field( 71 | '245', 72 | array( 73 | new File_MARC_Subfield('6', '880-02'), 74 | new File_MARC_Subfield('a', 'Test 880.') 75 | ), 76 | "1", "0" 77 | ) 78 | ); 79 | $rec->appendField( 80 | new File_MARC_Data_Field( 81 | '260', 82 | array( 83 | new File_MARC_Subfield('a', 'Mount Morris, Ill. :'), 84 | new File_MARC_Subfield('b', "B. Baldus,"), 85 | new File_MARC_Subfield('c', '2007.') 86 | ), 87 | "", "" 88 | ) 89 | ); 90 | $rec->appendField( 91 | new File_MARC_Data_Field( 92 | '300', 93 | array( 94 | new File_MARC_Subfield('a', '1 v. ;'), 95 | new File_MARC_Subfield('c', '23 cm.') 96 | ), 97 | "", "" 98 | ) 99 | ); 100 | $rec->appendField( 101 | new File_MARC_Data_Field( 102 | '880', 103 | array( 104 | new File_MARC_Subfield('6', '245-02/$1'), 105 | new File_MARC_Subfield('a', '.') 106 | ), 107 | "1", "0" 108 | ) 109 | ); 110 | $rec->appendField( 111 | new File_MARC_Data_Field( 112 | '880', 113 | array( 114 | new File_MARC_Subfield('6', '245-02/$1'), 115 | new File_MARC_Subfield('a', 'Illegal duplicate field.') 116 | ), 117 | "1", "0" 118 | ) 119 | ); 120 | $warnings = $marc_lint->checkRecord($rec); 121 | foreach ($warnings as $warning) { 122 | print $warning . "\n"; 123 | } 124 | 125 | ?> 126 | --EXPECT-- 127 | 245: Field is not repeatable. 128 | -------------------------------------------------------------------------------- /tests/marc_lint_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_lint_004: Tests check_245() called separately 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | <?php include('tests/skipif_noispn.inc'); ?> 6 | --FILE-- 7 | <?php 8 | $dir = dirname(__FILE__); 9 | require __DIR__ . '/bootstrap.php'; 10 | 11 | // Create test harness to allow direct calls to check methods: 12 | class File_MARC_Lint_Test_Harness extends File_MARC_Lint 13 | { 14 | public function check245($field) 15 | { 16 | return parent::check245($field); 17 | } 18 | 19 | // override warn method to echo instead of store in object: 20 | protected function warn($msg) 21 | { 22 | echo $msg . "\n"; 23 | } 24 | } 25 | 26 | $marc_lint = new File_MARC_Lint_Test_Harness(); 27 | 28 | $testData = array( 29 | array(245, '0', '0', 'a', 'Subfield a.'), 30 | array(245, '0', '0', 'b', 'no subfield a.'), 31 | array(245, '0', '0', 'a', 'No period at end'), 32 | array(245, '0', '0', 'a', 'Other punctuation not followed by period!'), 33 | array(245, '0', '0', 'a', 'Other punctuation not followed by period?'), 34 | array(245, '0', '0', 'a', 'Precedes sub c', 'c', 'not preceded by space-slash.'), 35 | array(245, '0', '0', 'a', 'Precedes sub c/', 'c', 'not preceded by space-slash.'), 36 | array(245, '0', '0', 'a', 'Precedes sub c /', 'c', 'initials in sub c B. B.'), 37 | array(245, '0', '0', 'a', 'Precedes sub c /', 'c', 'initials in sub c B.B. (no warning).'), 38 | array(245, '0', '0', 'a', 'Precedes sub b', 'b', 'not preceded by proper punctuation.'), 39 | array(245, '0', '0', 'a', 'Precedes sub b=', 'b', 'not preceded by proper punctuation.'), 40 | array(245, '0', '0', 'a', 'Precedes sub b:', 'b', 'not preceded by proper punctuation.'), 41 | array(245, '0', '0', 'a', 'Precedes sub b;', 'b', 'not preceded by proper punctuation.'), 42 | array(245, '0', '0', 'a', 'Precedes sub b =', 'b', 'preceded by proper punctuation.'), 43 | array(245, '0', '0', 'a', 'Precedes sub b :', 'b', 'preceded by proper punctuation.'), 44 | array(245, '0', '0', 'a', 'Precedes sub b ;', 'b', 'preceded by proper punctuation.'), 45 | array(245, '0', '0', 'a', 'Precedes sub h ', 'h', '[videorecording].'), 46 | array(245, '0', '0', 'a', 'Precedes sub h-- ', 'h', '[videorecording] :', 'b', 'with elipses dash before h.'), 47 | array(245, '0', '0', 'a', 'Precedes sub h-- ', 'h', 'videorecording :', 'b', 'without brackets around GMD.'), 48 | array(245, '0', '0', 'a', 'Precedes sub n.', 'n', 'Number 1.'), 49 | array(245, '0', '0', 'a', 'Precedes sub n', 'n', 'Number 2.'), 50 | array(245, '0', '0', 'a', 'Precedes sub n.', 'n', 'Number 3.', 'p', 'Sub n has period not comma.'), 51 | array(245, '0', '0', 'a', 'Precedes sub n.', 'n', 'Number 3,', 'p', 'Sub n has comma.'), 52 | array(245, '0', '0', 'a', 'Precedes sub p.', 'p', 'Sub a has period.'), 53 | array(245, '0', '0', 'a', 'Precedes sub p', 'p', 'Sub a has no period.'), 54 | array(245, '0', 'a', 'a', 'Invalid filing indicator.'), 55 | array(245, '0', '0', 'a', 'The article.'), 56 | array(245, '0', '4', 'a', 'The article.'), 57 | array(245, '0', '2', 'a', 'An article.'), 58 | array(245, '0', '0', 'a', "L'article."), 59 | array(245, '0', '2', 'a', 'A la mode.'), 60 | array(245, '0', '5', 'a', 'The "quoted article".'), 61 | array(245, '0', '5', 'a', 'The (parenthetical article).'), 62 | array(245, '0', '6', 'a', '(The) article in parentheses).'), 63 | array(245, '0', '9', 'a', "\"(The)\" 'article' in quotes and parentheses)."), 64 | array(245, '0', '5', 'a', '[The supplied title].') 65 | ); 66 | 67 | foreach ($testData as $current) { 68 | $subfields = array(); 69 | for ($i = 3; $i < count($current); $i+=2) { 70 | $subfields[] = new File_MARC_Subfield($current[$i], $current[$i+1]); 71 | } 72 | 73 | $field = new File_MARC_Data_Field( 74 | $current[0], $subfields, $current[1], $current[2] 75 | ); 76 | $marc_lint->check245($field); 77 | } 78 | 79 | ?> 80 | --EXPECT-- 81 | 245: Must have a subfield _a. 82 | 245: First subfield must be _a, but it is _b 83 | 245: Must end with . (period). 84 | 245: MARC21 allows ? or ! as final punctuation but LCRI 1.0C, Nov. 2003 (LCPS 1.7.1 for RDA records), requires period. 85 | 245: MARC21 allows ? or ! as final punctuation but LCRI 1.0C, Nov. 2003 (LCPS 1.7.1 for RDA records), requires period. 86 | 245: Subfield _c must be preceded by / 87 | 245: Subfield _c must be preceded by / 88 | 245: Subfield _c initials should not have a space. 89 | 245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign. 90 | 245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign. 91 | 245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign. 92 | 245: Subfield _b should be preceded by space-colon, space-semicolon, or space-equals sign. 93 | 245: Subfield _h should not be preceded by space. 94 | 245: Subfield _h must have matching square brackets, videorecording :. 95 | 245: Subfield _n must be preceded by . (period). 96 | 245: Subfield _p must be preceded by , (comma) when it follows subfield _n. 97 | 245: Subfield _p must be preceded by . (period) when it follows a subfield other than _n. 98 | 245: Non-filing indicator is non-numeric 99 | 245: First word, the, may be an article, check 2nd indicator (0). 100 | 245: First word, an, may be an article, check 2nd indicator (2). 101 | 245: First word, l, may be an article, check 2nd indicator (0). 102 | 245: First word, a, does not appear to be an article, check 2nd indicator (2). 103 | -------------------------------------------------------------------------------- /tests/marc_lint_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_lint_005: Tests check_020() called separately 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | <?php include('tests/skipif_noispn.inc'); ?> 6 | --FILE-- 7 | <?php 8 | $dir = dirname(__FILE__); 9 | require __DIR__ . '/bootstrap.php'; 10 | 11 | // Create test harness to allow direct calls to check methods: 12 | class File_MARC_Lint_Test_Harness extends File_MARC_Lint 13 | { 14 | public function check020($field) 15 | { 16 | return parent::check020($field); 17 | } 18 | 19 | // override warn method to echo instead of store in object: 20 | protected function warn($msg) 21 | { 22 | echo $msg . "\n"; 23 | } 24 | } 25 | 26 | $marc_lint = new File_MARC_Lint_Test_Harness(); 27 | 28 | $testData = array( 29 | array('a' => "154879473"), //too few digits 30 | array('a' => "1548794743"), //invalid checksum 31 | array('a' => "15487947443"), //11 digits 32 | array('a' => "15487947443324"), //14 digits 33 | array('a' => "9781548794743"), //13 digit valid 34 | array('a' => "9781548794745"), //13 digit invalid 35 | array('a' => "1548794740 (10 : good checksum)"), //10 digit valid with qualifier 36 | array('a' => "1548794745 (10 : bad checksum)"), //10 digit invalid with qualifier 37 | array('a' => "1-54879-474-0 (hyphens and good checksum)"), //10 digit invalid with hyphens and qualifier 38 | array('a' => "1-54879-474-5 (hyphens and bad checksum)"), //10 digit invalid with hyphens and qualifier 39 | array('a' => "1548794740(10 : unspaced qualifier)"), //10 valid without space before qualifier 40 | array('a' => "1548794745(10 : unspaced qualifier : bad checksum)"), //10 invalid without space before qualifier 41 | array('z' => "1548794743"), //subfield z 42 | ); 43 | 44 | foreach ($testData as $current) { 45 | $subfields = array(); 46 | foreach ($current as $key => $value) { 47 | $subfields[] = new File_MARC_Subfield($key, $value); 48 | } 49 | $field = new File_MARC_Data_Field('020', $subfields, '', ''); 50 | $marc_lint->check020($field); 51 | } 52 | 53 | ?> 54 | --EXPECT-- 55 | 020: Subfield a has the wrong number of digits, 154879473. 56 | 020: Subfield a has bad checksum, 1548794743. 57 | 020: Subfield a has the wrong number of digits, 15487947443. 58 | 020: Subfield a has the wrong number of digits, 15487947443324. 59 | 020: Subfield a has bad checksum (13 digit), 9781548794745. 60 | 020: Subfield a has bad checksum, 1548794745 (10 : bad checksum). 61 | 020: Subfield a may have invalid characters. 62 | 020: Subfield a may have invalid characters. 63 | 020: Subfield a has bad checksum, 1-54879-474-5 (hyphens and bad checksum). 64 | 020: Subfield a qualifier must be preceded by space, 1548794740(10 : unspaced qualifier). 65 | 020: Subfield a qualifier must be preceded by space, 1548794745(10 : unspaced qualifier : bad checksum). 66 | 020: Subfield a has bad checksum, 1548794745(10 : unspaced qualifier : bad checksum). 67 | -------------------------------------------------------------------------------- /tests/marc_list_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_list_001: Check File_MARC_List methods 3 | --SKIPIF-- 4 | <?php include('skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require 'File/MARC.php'; 9 | 10 | $list = new File_MARC_List(); 11 | 12 | // Create fields 13 | $field1 = new File_MARC_Control_Field( '001', '00001' ); 14 | $field2 = new File_MARC_Control_Field( '002', '00002' ); 15 | $field3 = new File_MARC_Control_Field( '003', '00003' ); 16 | $field4 = new File_MARC_Control_Field( '004', '00004' ); 17 | 18 | // Check appendNode 19 | $list->appendNode( $field2 ); 20 | $list->appendNode( $field4 ); 21 | foreach ( $list as $el ) { 22 | echo $el->getPosition() . ': ' . $el . "\n"; 23 | } 24 | echo $list->count() . " nodes\n"; 25 | 26 | // Check prependNode 27 | echo "---\n"; 28 | $list->prependNode( $field1 ); 29 | foreach ( $list as $el ) { 30 | echo $el->getPosition() . ': ' . $el . "\n"; 31 | } 32 | echo $list->count() . " nodes\n"; 33 | 34 | // Check insertNode 35 | echo "---\n"; 36 | $list->insertNode( $field3, $field2 ); 37 | foreach ( $list as $el ) { 38 | echo $el->getPosition() . ': ' . $el . "\n"; 39 | } 40 | echo $list->count() . " nodes\n"; 41 | 42 | // Check deleteNode 43 | echo "---\n"; 44 | $list->deleteNode( $field2 ); 45 | foreach ( $list as $el ) { 46 | echo $el->getPosition() . ': ' . $el . "\n"; 47 | } 48 | echo $list->count() . " nodes\n"; 49 | 50 | // Check key method 51 | echo "---\n"; 52 | $list->rewind(); 53 | echo 'Key (field): ' . $list->key() . "\n"; 54 | 55 | $subfield = new File_MARC_Subfield( 'a', 'test' ); 56 | $list->prependNode( $subfield ); 57 | $list->rewind(); 58 | echo 'Key (subfield): ' . $list->key(). "\n"; 59 | ?> 60 | --EXPECT-- 61 | 0: 002 00002 62 | 1: 004 00004 63 | 2 nodes 64 | --- 65 | 0: 001 00001 66 | 1: 002 00002 67 | 2: 004 00004 68 | 3 nodes 69 | --- 70 | 0: 001 00001 71 | 1: 002 00002 72 | 2: 003 00003 73 | 3: 004 00004 74 | 4 nodes 75 | --- 76 | 0: 001 00001 77 | 1: 003 00003 78 | 2: 004 00004 79 | 3 nodes 80 | --- 81 | Key (field): 001 82 | Key (subfield): a 83 | -------------------------------------------------------------------------------- /tests/marc_record_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_record_001: create a MARC record from scratch 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc = new File_MARC_Record(); 10 | 11 | $marc->appendField(new File_MARC_Data_Field('245', array( 12 | new File_MARC_Subfield('a', 'Main title: '), 13 | new File_MARC_Subfield('b', 'subtitle'), 14 | new File_MARC_Subfield('c', 'author') 15 | ), null, null 16 | )); 17 | 18 | print $marc; 19 | 20 | ?> 21 | --EXPECT-- 22 | LDR 23 | 245 _aMain title: 24 | _bsubtitle 25 | _cauthor 26 | -------------------------------------------------------------------------------- /tests/marc_subfield_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_subfield_001: Exercise basic methods for File_MARC_Subfield class 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | 10 | // test constructor 11 | $subfield = new File_MARC_Subfield('a', 'wasssup'); 12 | 13 | // test get methods 14 | print "Code: " . $subfield->getCode() . "\n"; 15 | print "Data: " . $subfield->getData() . "\n"; 16 | 17 | // test __toString implementation 18 | print $subfield; 19 | print "\n"; 20 | 21 | // test raw output implementation 22 | print $subfield->toRaw() . "\n"; 23 | 24 | // test isEmpty() 25 | if ($subfield->isEmpty()) { 26 | print "Subfield is empty\n"; 27 | } 28 | else { 29 | print "Subfield is not empty\n"; 30 | } 31 | ?> 32 | --EXPECT-- 33 | Code: a 34 | Data: wasssup 35 | [a]: wasssup 36 | awasssup 37 | Subfield is not empty 38 | -------------------------------------------------------------------------------- /tests/marc_subfield_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_subfield_002: Exercise setter and isEmpty() methods for File_MARC_Subfield class 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | 10 | function testEmpty($testSubfield) { 11 | print "Subfield is "; 12 | if ($testSubfield->isEmpty()) { 13 | print "empty.\n"; 14 | } 15 | else { 16 | print "not empty.\n"; 17 | } 18 | 19 | } 20 | 21 | $subfield = new File_MARC_Subfield('a', 'wasssup'); 22 | 23 | // test isEmpty() scenarios 24 | testEmpty($subfield); 25 | 26 | $subfield->setData(null); 27 | testEmpty($subfield); 28 | 29 | $subfield->setData('just hangin'); 30 | testEmpty($subfield); 31 | 32 | // test setCode() scenarios 33 | print "\nSet code to 'z'..."; 34 | if ($subfield->setCode('z')) { 35 | print "\n"; 36 | print $subfield; 37 | } 38 | 39 | print "\nSet code to ''..."; 40 | if ($subfield->setCode('')) { 41 | print "\n"; 42 | print $subfield; 43 | } 44 | 45 | print "\nSet code to null..."; 46 | if ($subfield->setCode(null)) { 47 | print "\n"; 48 | print $subfield; 49 | } 50 | 51 | ?> 52 | --EXPECT-- 53 | Subfield is not empty. 54 | Subfield is empty. 55 | Subfield is not empty. 56 | 57 | Set code to 'z'... 58 | [z]: just hangin 59 | Set code to ''... 60 | Set code to null... 61 | -------------------------------------------------------------------------------- /tests/marc_xml_001.phpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pear/File_MARC/7085b9e81ee433b5b75eb454d30ab619b8eccacc/tests/marc_xml_001.phpt -------------------------------------------------------------------------------- /tests/marc_xml_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_002: iterate and pretty print a MARC record (LOC standard) 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARC($dir . '/' . 'sandburg.mrc'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record->toXML(); 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | <?xml version="1.0" encoding="UTF-8"?> 18 | <collection xmlns="http://www.loc.gov/MARC21/slim"> 19 | <record> 20 | <leader>01142cam 2200301 a 4500</leader> 21 | <controlfield tag="001"> 92005291 </controlfield> 22 | <controlfield tag="003">DLC</controlfield> 23 | <controlfield tag="005">19930521155141.9</controlfield> 24 | <controlfield tag="008">920219s1993 caua j 000 0 eng </controlfield> 25 | <datafield tag="010" ind1=" " ind2=" "> 26 | <subfield code="a"> 92005291 </subfield> 27 | </datafield> 28 | <datafield tag="020" ind1=" " ind2=" "> 29 | <subfield code="a">0152038655 :</subfield> 30 | <subfield code="c">$15.95</subfield> 31 | </datafield> 32 | <datafield tag="040" ind1=" " ind2=" "> 33 | <subfield code="a">DLC</subfield> 34 | <subfield code="c">DLC</subfield> 35 | <subfield code="d">DLC</subfield> 36 | </datafield> 37 | <datafield tag="042" ind1=" " ind2=" "> 38 | <subfield code="a">lcac</subfield> 39 | </datafield> 40 | <datafield tag="050" ind1="0" ind2="0"> 41 | <subfield code="a">PS3537.A618</subfield> 42 | <subfield code="b">A88 1993</subfield> 43 | </datafield> 44 | <datafield tag="082" ind1="0" ind2="0"> 45 | <subfield code="a">811/.52</subfield> 46 | <subfield code="2">20</subfield> 47 | </datafield> 48 | <datafield tag="100" ind1="1" ind2=" "> 49 | <subfield code="a">Sandburg, Carl,</subfield> 50 | <subfield code="d">1878-1967.</subfield> 51 | </datafield> 52 | <datafield tag="245" ind1="1" ind2="0"> 53 | <subfield code="a">Arithmetic /</subfield> 54 | <subfield code="c">Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand.</subfield> 55 | </datafield> 56 | <datafield tag="250" ind1=" " ind2=" "> 57 | <subfield code="a">1st ed.</subfield> 58 | </datafield> 59 | <datafield tag="260" ind1=" " ind2=" "> 60 | <subfield code="a">San Diego :</subfield> 61 | <subfield code="b">Harcourt Brace Jovanovich,</subfield> 62 | <subfield code="c">c1993.</subfield> 63 | </datafield> 64 | <datafield tag="300" ind1=" " ind2=" "> 65 | <subfield code="a">1 v. (unpaged) :</subfield> 66 | <subfield code="b">ill. (some col.) ;</subfield> 67 | <subfield code="c">26 cm.</subfield> 68 | </datafield> 69 | <datafield tag="500" ind1=" " ind2=" "> 70 | <subfield code="a">One Mylar sheet included in pocket.</subfield> 71 | </datafield> 72 | <datafield tag="520" ind1=" " ind2=" "> 73 | <subfield code="a">A poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone.</subfield> 74 | </datafield> 75 | <datafield tag="650" ind1=" " ind2="0"> 76 | <subfield code="a">Arithmetic</subfield> 77 | <subfield code="x">Juvenile poetry.</subfield> 78 | </datafield> 79 | <datafield tag="650" ind1=" " ind2="0"> 80 | <subfield code="a">Children's poetry, American.</subfield> 81 | </datafield> 82 | <datafield tag="650" ind1=" " ind2="1"> 83 | <subfield code="a">Arithmetic</subfield> 84 | <subfield code="x">Poetry.</subfield> 85 | </datafield> 86 | <datafield tag="650" ind1=" " ind2="1"> 87 | <subfield code="a">American poetry.</subfield> 88 | </datafield> 89 | <datafield tag="650" ind1=" " ind2="1"> 90 | <subfield code="a">Visual perception.</subfield> 91 | </datafield> 92 | <datafield tag="700" ind1="1" ind2=" "> 93 | <subfield code="a">Rand, Ted,</subfield> 94 | <subfield code="e">ill.</subfield> 95 | </datafield> 96 | </record> 97 | </collection> 98 | -------------------------------------------------------------------------------- /tests/marc_xml_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_003: Round-trip a MARCXML record to MARC21 (LOC standard) 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'sandburg.xml'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record->toRaw(); 13 | } 14 | ?> 15 | --EXPECT-- 16 | 01142cam 2200301 a 4500001001300000003000400013005001700017008004100034010001700075020002500092040001800117042000900135050002600144082001600170100003200186245008600218250001200304260005200316300004900368500004000417520022800457650003300685650003300718650002400751650002100775650002300796700002100819 92005291 DLC19930521155141.9920219s1993 caua j 000 0 eng  a 92005291  a0152038655 :c$15.95 aDLCcDLCdDLC alcac00aPS3537.A618bA88 199300a811/.522201 aSandburg, Carl,d1878-1967.10aArithmetic /cCarl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. a1st ed. aSan Diego :bHarcourt Brace Jovanovich,cc1993. a1 v. (unpaged) :bill. (some col.) ;c26 cm. aOne Mylar sheet included in pocket. aA poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone. 0aArithmeticxJuvenile poetry. 0aChildren's poetry, American. 1aArithmeticxPoetry. 1aAmerican poetry. 1aVisual perception.1 aRand, Ted,eill. 17 | -------------------------------------------------------------------------------- /tests/marc_xml_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_004: test conversion to XML of subfields that need to be escaped 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARC($dir . '/' . 'xmlescape.mrc'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record->toXML(); 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | <?xml version="1.0" encoding="UTF-8"?> 18 | <collection xmlns="http://www.loc.gov/MARC21/slim"> 19 | <record> 20 | <leader>00727nam 2200205 a 4500</leader> 21 | <controlfield tag="001">03-0016458</controlfield> 22 | <controlfield tag="005">19971103184734.0</controlfield> 23 | <controlfield tag="008">970701s1997 oru u000 0 eng u</controlfield> 24 | <datafield tag="035" ind1=" " ind2=" "> 25 | <subfield code="a">(Sirsi) a351664</subfield> 26 | </datafield> 27 | <datafield tag="050" ind1="0" ind2="0"> 28 | <subfield code="a">ML270.2</subfield> 29 | <subfield code="b">.A6 1997</subfield> 30 | </datafield> 31 | <datafield tag="100" ind1="1" ind2=" "> 32 | <subfield code="a">Anthony, James R.</subfield> 33 | </datafield> 34 | <datafield tag="245" ind1="0" ind2="0"> 35 | <subfield code="a">French baroque music from Beaujoyeulx to Rameau</subfield> 36 | </datafield> 37 | <datafield tag="250" ind1=" " ind2=" "> 38 | <subfield code="a">Rev. and expanded ed.</subfield> 39 | </datafield> 40 | <datafield tag="260" ind1=" " ind2=" "> 41 | <subfield code="a">Portland, OR :</subfield> 42 | <subfield code="b">Amadeus Press,</subfield> 43 | <subfield code="c">1997.</subfield> 44 | </datafield> 45 | <datafield tag="300" ind1=" " ind2=" "> 46 | <subfield code="a">586 p. :</subfield> 47 | <subfield code="b">music</subfield> 48 | </datafield> 49 | <datafield tag="650" ind1=" " ind2="0"> 50 | <subfield code="a">Music</subfield> 51 | <subfield code="<">France</subfield> 52 | <subfield code="y">16th century</subfield> 53 | <subfield code="x">History and criticism.</subfield> 54 | </datafield> 55 | <datafield tag="650" ind1=" " ind2="0"> 56 | <subfield code="a">Music</subfield> 57 | <subfield code="z">France</subfield> 58 | <subfield code="y">17th century</subfield> 59 | <subfield code="x">History and criticism.</subfield> 60 | </datafield> 61 | <datafield tag="650" ind1=" " ind2="0"> 62 | <subfield code="a">Music</subfield> 63 | <subfield code="z">France</subfield> 64 | <subfield code="y">18th century</subfield> 65 | <subfield code="x">History and criticism.</subfield> 66 | </datafield> 67 | <datafield tag="949" ind1=" " ind2=" "> 68 | <subfield code="a">ML 270.2 A6 1997</subfield> 69 | <subfield code="w">LC</subfield> 70 | <subfield code="i">30007006841505</subfield> 71 | <subfield code="r">Y</subfield> 72 | <subfield code="t">BOOKS</subfield> 73 | <subfield code="l">HUNT-CIRC</subfield> 74 | <subfield code="m">HUNTINGTON</subfield> 75 | </datafield> 76 | <datafield tag="596" ind1=" " ind2=" "> 77 | <subfield code="a">1</subfield> 78 | </datafield> 79 | </record> 80 | </collection> 81 | -------------------------------------------------------------------------------- /tests/marc_xml_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_005: Round-trip a MARCXML record with a root element of "record" to MARC21 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'onerecord.xml'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record->toRaw(); 13 | } 14 | ?> 15 | --EXPECT-- 16 | 01142cam 2200301 a 4500001001300000003000400013005001700017008004100034010001700075020002500092040001800117042000900135050002600144082001600170100003200186245008600218250001200304260005200316300004900368500004000417520022800457650003300685650003300718650002400751650002100775650002300796700002100819 92005291 DLC19930521155141.9920219s1993 caua j 000 0 eng  a 92005291  a0152038655 :c$15.95 aDLCcDLCdDLC alcac00aPS3537.A618bA88 199300a811/.522201 aSandburg, Carl,d1878-1967.10aArithmetic /cCarl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. a1st ed. aSan Diego :bHarcourt Brace Jovanovich,cc1993. a1 v. (unpaged) :bill. (some col.) ;c26 cm. aOne Mylar sheet included in pocket. aA poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone. 0aArithmeticxJuvenile poetry. 0aChildren's poetry, American. 1aArithmeticxPoetry. 1aAmerican poetry. 1aVisual perception.1 aRand, Ted,eill. 17 | -------------------------------------------------------------------------------- /tests/marc_xml_006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_006: test getFields() in XML 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | 8 | $dir = dirname(__FILE__); 9 | require __DIR__ . '/bootstrap.php'; 10 | 11 | // Read MARC records from a stream (a file, in this case) 12 | $marc_source = new File_MARCXML($dir . '/' . 'sandburg.xml'); 13 | 14 | // Retrieve the first MARC record from the source 15 | $marc_record = $marc_source->next(); 16 | 17 | // Retrieve a personal name field from the record 18 | $names = $marc_record->getFields('100'); 19 | foreach ($names as $name_field) { 20 | // Now print the $a subfield 21 | switch ($name_field->getIndicator(1)) { 22 | case 0: 23 | print "Forename: "; 24 | break; 25 | 26 | case 1: 27 | print "Surname: "; 28 | break; 29 | 30 | case 2: 31 | print "Family name: "; 32 | break; 33 | } 34 | $name = $name_field->getSubfields('a'); 35 | if (count($name) == 1) { 36 | print $name[0]->getData() . "\n"; 37 | } 38 | else { 39 | print "Error -- \$a subfield appears more than once in this field!"; 40 | } 41 | } 42 | 43 | // Retrieve all subject and genre fields 44 | // Series statement fields start with a 6 (PCRE) 45 | $subjects = $marc_record->getFields('^6', true); 46 | 47 | // Iterate through all of the returned subject fields 48 | foreach ($subjects as $field) { 49 | // print with File_MARC_Field_Data's magic __toString() method 50 | print "$field\n"; 51 | } 52 | 53 | ?> 54 | --EXPECT-- 55 | Surname: Sandburg, Carl, 56 | 650 0 _aArithmetic 57 | _xJuvenile poetry. 58 | 650 0 _aChildren's poetry, American. 59 | 650 1 _aArithmetic 60 | _xPoetry. 61 | 650 1 _aAmerican poetry. 62 | 650 1 _aVisual perception. 63 | -------------------------------------------------------------------------------- /tests/marc_xml_007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_007: test getTag(), isControlField(), and isDataField() convenience methods on MARCXML 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'bigarchive.xml'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | $fields = $marc_record->getFields(); 13 | foreach ($fields as $field) { 14 | print $field->getTag(); 15 | if ($field->isControlField()) { 16 | print "\tControl field!"; 17 | } 18 | if ($field->isDataField()) { 19 | print "\tData field!"; 20 | } 21 | print "\n"; 22 | } 23 | } 24 | 25 | ?> 26 | --EXPECT-- 27 | 001 Control field! 28 | 003 Control field! 29 | 005 Control field! 30 | 006 Control field! 31 | 007 Control field! 32 | 008 Control field! 33 | 037 Data field! 34 | 040 Data field! 35 | 245 Data field! 36 | 246 Data field! 37 | 260 Data field! 38 | 300 Data field! 39 | 500 Data field! 40 | 500 Data field! 41 | 500 Data field! 42 | 510 Data field! 43 | 510 Data field! 44 | 533 Data field! 45 | 651 Data field! 46 | 830 Data field! 47 | 856 Data field! 48 | 909 Data field! 49 | -------------------------------------------------------------------------------- /tests/marc_xml_009.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_009: convert a MARCXML record with an overly long leader to MARC 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'bad_leader.xml'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record->toRaw(); 13 | } 14 | ?> 15 | --EXPECT-- 16 | 00749cam a2200241 454500001001400000003000600014005001700020008004100037020001800078020001500096035002100111040003600132050002400168100002500192245007800217260003700295300002100332504004100353650001700394650002200411852004800433901002600481LIBN539044247OCoLC20081030150430.0070630||||| ||| 000 0 eng d a9781856075442 a1856075443 a(OCoLC)156822300 aBTCTAcBTCTAdYDXCPdBAKERdEMT 4aBL2747.2b.W45 20061 aWhite, Stephen Ross.10aSpace for unknowing :bthe place of agnosis in faith /cStephen R. White. aDublin :bColumba Press,cc2006. a160 p. ;c22 cm. aIncludes bibliographical references. 0aAgnosticism. 0aBelief and doubt. a1h230 WHIp11111027105040t65112549p26.95 aLIBN539044247bSystem 17 | -------------------------------------------------------------------------------- /tests/marc_xml_010.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_010: iterate and pretty print a MARC record 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'repeated_subfields.xml'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | $subject = $marc_record->getFields('650'); 13 | if (!$subject) { 14 | next; 15 | } 16 | foreach ($subject as $key => $line) { 17 | if ($line->getSubfield('a')) { 18 | // get subject 19 | $array[$key]['subject'] = $line->getSubfield('a')->getData(); 20 | if ($line->getSubfield('b')) { 21 | $array[$key]['subsubject'] = $line->getSubfield('b')->getData(); 22 | } 23 | // get subject hierarchy level 24 | if ($name = $line->getSubfields('x')) { 25 | foreach ($name as $value) { 26 | $array[$key]['level'][] = $value->getData(); 27 | } 28 | } // end if subfield x 29 | } // end if subfield a 30 | } // end foreach 31 | var_dump($array); 32 | } 33 | --EXPECT-- 34 | array(5) { 35 | [0]=> 36 | array(2) { 37 | ["subject"]=> 38 | string(10) "Arithmetic" 39 | ["level"]=> 40 | array(1) { 41 | [0]=> 42 | string(16) "Juvenile poetry." 43 | } 44 | } 45 | [1]=> 46 | array(2) { 47 | ["subject"]=> 48 | string(27) "Children's poetry, American" 49 | ["level"]=> 50 | array(1) { 51 | [0]=> 52 | string(7) "Oregon." 53 | } 54 | } 55 | [2]=> 56 | array(3) { 57 | ["subject"]=> 58 | string(10) "Arithmetic" 59 | ["subsubject"]=> 60 | string(11) "Really hard" 61 | ["level"]=> 62 | array(2) { 63 | [0]=> 64 | string(6) "Poetry" 65 | [1]=> 66 | string(13) "Unbelievable." 67 | } 68 | } 69 | [3]=> 70 | array(1) { 71 | ["subject"]=> 72 | string(16) "American poetry." 73 | } 74 | [4]=> 75 | array(1) { 76 | ["subject"]=> 77 | string(18) "Visual perception." 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/marc_xml_011.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_010: iterate and pretty print a MARC record 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | 10 | class MyRecord extends File_MARC_Record { 11 | public function myNewMethod() { 12 | return $this->getField('040')->getSubfield('a')->getData(); 13 | } 14 | } 15 | 16 | $marc_file = new File_MARCXML($dir . '/' . 'repeated_subfields.xml', File_MARCXML::SOURCE_FILE, '', false, MyRecord::class); 17 | 18 | $rec = $marc_file->next(); 19 | print get_class($rec) . "\n"; 20 | print $rec->myNewMethod() . "\n"; 21 | 22 | --EXPECT-- 23 | MyRecord 24 | DLC 25 | -------------------------------------------------------------------------------- /tests/marc_xml_012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_012: load from SimpleXMLElement object 3 | --SKIPIF-- 4 | <?php include('skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | 10 | $xml_obj = simplexml_load_file($dir . '/namespace.xml', "SimpleXMLElement", 0, "http://www.loc.gov/MARC21/slim", false); 11 | 12 | $marc_file = new File_MARCXML($xml_obj); 13 | $marc_file->toXMLHeader(); 14 | while ($marc_record = $marc_file->next()) { 15 | print $marc_record->toXML('UTF-8', true, false); 16 | } 17 | print $marc_file->toXMLFooter(); 18 | 19 | ?> 20 | --EXPECT-- 21 | <?xml version="1.0" encoding="UTF-8"?> 22 | <collection xmlns="http://www.loc.gov/MARC21/slim"> 23 | <record xmlns="http://www.loc.gov/MARC21/slim"> 24 | <leader>00925njm 22002777a 4500</leader> 25 | <controlfield tag="001">5637241</controlfield> 26 | <controlfield tag="003">DLC</controlfield> 27 | <controlfield tag="005">19920826084036.0</controlfield> 28 | <controlfield tag="007">sdubumennmplu</controlfield> 29 | <controlfield tag="008">910926s1957 nyuuun eng </controlfield> 30 | <datafield tag="010" ind1=" " ind2=" "> 31 | <subfield code="a"> 91758335 </subfield> 32 | </datafield> 33 | <datafield tag="028" ind1="0" ind2="0"> 34 | <subfield code="a">1259</subfield> 35 | <subfield code="b">Atlantic</subfield> 36 | </datafield> 37 | <datafield tag="040" ind1=" " ind2=" "> 38 | <subfield code="a">DLC</subfield> 39 | <subfield code="c">DLC</subfield> 40 | </datafield> 41 | <datafield tag="050" ind1="0" ind2="0"> 42 | <subfield code="a">Atlantic 1259</subfield> 43 | </datafield> 44 | <datafield tag="245" ind1="0" ind2="4"> 45 | <subfield code="a">The Great Ray Charles</subfield> 46 | <subfield code="h">[sound recording].</subfield> 47 | </datafield> 48 | <datafield tag="260" ind1=" " ind2=" "> 49 | <subfield code="a">New York, N.Y. :</subfield> 50 | <subfield code="b">Atlantic,</subfield> 51 | <subfield code="c">[1957?]</subfield> 52 | </datafield> 53 | <datafield tag="300" ind1=" " ind2=" "> 54 | <subfield code="a">1 sound disc :</subfield> 55 | <subfield code="b">analog, 33 1/3 rpm ;</subfield> 56 | <subfield code="c">12 in.</subfield> 57 | </datafield> 58 | <datafield tag="511" ind1="0" ind2=" "> 59 | <subfield code="a">Ray Charles, piano & celeste.</subfield> 60 | </datafield> 61 | <datafield tag="505" ind1="0" ind2=" "> 62 | <subfield code="a">The Ray -- My melancholy baby -- Black coffee -- There's no you -- Doodlin' -- Sweet sixteen bars -- I surrender dear -- Undecided.</subfield> 63 | </datafield> 64 | <datafield tag="500" ind1=" " ind2=" "> 65 | <subfield code="a">Brief record.</subfield> 66 | </datafield> 67 | <datafield tag="650" ind1=" " ind2="0"> 68 | <subfield code="a">Jazz</subfield> 69 | <subfield code="y">1951-1960.</subfield> 70 | </datafield> 71 | <datafield tag="650" ind1=" " ind2="0"> 72 | <subfield code="a">Piano with jazz ensemble.</subfield> 73 | </datafield> 74 | <datafield tag="700" ind1="1" ind2=" "> 75 | <subfield code="a">Charles, Ray,</subfield> 76 | <subfield code="d">1930-</subfield> 77 | <subfield code="4">prf</subfield> 78 | </datafield> 79 | </record> 80 | <record xmlns="http://www.loc.gov/MARC21/slim"> 81 | <leader>01832cmma 2200349 a 4500</leader> 82 | <controlfield tag="001">12149120</controlfield> 83 | <controlfield tag="005">20001005175443.0</controlfield> 84 | <controlfield tag="007">cr |||</controlfield> 85 | <controlfield tag="008">000407m19949999dcu g m eng d</controlfield> 86 | <datafield tag="906" ind1=" " ind2=" "> 87 | <subfield code="a">0</subfield> 88 | <subfield code="b">ibc</subfield> 89 | <subfield code="c">copycat</subfield> 90 | <subfield code="d">1</subfield> 91 | <subfield code="e">ncip</subfield> 92 | <subfield code="f">20</subfield> 93 | <subfield code="g">y-gencompf</subfield> 94 | </datafield> 95 | <datafield tag="925" ind1="0" ind2=" "> 96 | <subfield code="a">undetermined</subfield> 97 | <subfield code="x">web preservation project (wpp)</subfield> 98 | </datafield> 99 | <datafield tag="955" ind1=" " ind2=" "> 100 | <subfield code="a">vb07 (stars done) 08-19-00 to HLCD lk00; AA3s lk29 received for subject Aug 25, 2000; to DEWEY 08-25-00; aa11 08-28-00</subfield> 101 | </datafield> 102 | <datafield tag="010" ind1=" " ind2=" "> 103 | <subfield code="a"> 00530046 </subfield> 104 | </datafield> 105 | <datafield tag="035" ind1=" " ind2=" "> 106 | <subfield code="a">(OCoLC)ocm44279786</subfield> 107 | </datafield> 108 | <datafield tag="040" ind1=" " ind2=" "> 109 | <subfield code="a">IEU</subfield> 110 | <subfield code="c">IEU</subfield> 111 | <subfield code="d">N@F</subfield> 112 | <subfield code="d">DLC</subfield> 113 | </datafield> 114 | <datafield tag="042" ind1=" " ind2=" "> 115 | <subfield code="a">lccopycat</subfield> 116 | </datafield> 117 | <datafield tag="043" ind1=" " ind2=" "> 118 | <subfield code="a">n-us-dc</subfield> 119 | <subfield code="a">n-us---</subfield> 120 | </datafield> 121 | <datafield tag="050" ind1="0" ind2="0"> 122 | <subfield code="a">F204.W5</subfield> 123 | </datafield> 124 | <datafield tag="082" ind1="1" ind2="0"> 125 | <subfield code="a">975.3</subfield> 126 | <subfield code="2">13</subfield> 127 | </datafield> 128 | <datafield tag="245" ind1="0" ind2="4"> 129 | <subfield code="a">The White House</subfield> 130 | <subfield code="h">[computer file].</subfield> 131 | </datafield> 132 | <datafield tag="256" ind1=" " ind2=" "> 133 | <subfield code="a">Computer data.</subfield> 134 | </datafield> 135 | <datafield tag="260" ind1=" " ind2=" "> 136 | <subfield code="a">Washington, D.C. :</subfield> 137 | <subfield code="b">White House Web Team,</subfield> 138 | <subfield code="c">1994-</subfield> 139 | </datafield> 140 | <datafield tag="538" ind1=" " ind2=" "> 141 | <subfield code="a">Mode of access: Internet.</subfield> 142 | </datafield> 143 | <datafield tag="500" ind1=" " ind2=" "> 144 | <subfield code="a">Title from home page as viewed on Aug. 19, 2000.</subfield> 145 | </datafield> 146 | <datafield tag="520" ind1="8" ind2=" "> 147 | <subfield code="a">Features the White House. Highlights the Executive Office of the President, which includes senior policy advisors and offices responsible for the President's correspondence and communications, the Office of the Vice President, and the Office of the First Lady. Posts contact information via mailing address, telephone and fax numbers, and e-mail. Contains the Interactive Citizens' Handbook with information on health, travel and tourism, education and training, and housing. Provides a tour and the history of the White House. Links to White House for Kids.</subfield> 148 | </datafield> 149 | <datafield tag="610" ind1="2" ind2="0"> 150 | <subfield code="a">White House (Washington, D.C.)</subfield> 151 | </datafield> 152 | <datafield tag="610" ind1="1" ind2="0"> 153 | <subfield code="a">United States.</subfield> 154 | <subfield code="b">Executive Office of the President.</subfield> 155 | </datafield> 156 | <datafield tag="610" ind1="1" ind2="0"> 157 | <subfield code="a">United States.</subfield> 158 | <subfield code="b">Office of the Vice President.</subfield> 159 | </datafield> 160 | <datafield tag="610" ind1="1" ind2="0"> 161 | <subfield code="a">United States.</subfield> 162 | <subfield code="b">Office of the First Lady.</subfield> 163 | </datafield> 164 | <datafield tag="710" ind1="2" ind2=" "> 165 | <subfield code="a">White House Web Team.</subfield> 166 | </datafield> 167 | <datafield tag="856" ind1="4" ind2="0"> 168 | <subfield code="u">http://www.whitehouse.gov</subfield> 169 | </datafield> 170 | <datafield tag="856" ind1="4" ind2="0"> 171 | <subfield code="u">http://lcweb.loc.gov/staff/wpp/whitehouse.html</subfield> 172 | <subfield code="z">Web site archive</subfield> 173 | </datafield> 174 | </record> 175 | </collection> 176 | -------------------------------------------------------------------------------- /tests/marc_xml_16642.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_16642: Fix bug 16642: ensure tag and subfield values are returned as strings 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | // Retrieve a set of MARC records from a file 10 | $marc_file = new File_MARCXML($dir . '/' . 'onerecord.xml'); 11 | // Iterate through the retrieved records 12 | while ($record = $marc_file->next()) { 13 | foreach ($record->getFields() as $tag => $subfields) { 14 | // Skip everything except for 650 fields 15 | if ($tag == '650') { 16 | print "Subject:"; 17 | foreach ($subfields->getSubfields() as $code => $value) { 18 | print " $value"; 19 | } 20 | print "\n"; 21 | } 22 | } 23 | } 24 | ?> 25 | --EXPECT-- 26 | Subject: [a]: Arithmetic [x]: Juvenile poetry. 27 | Subject: [a]: Children's poetry, American. 28 | Subject: [a]: Arithmetic [x]: Poetry. 29 | Subject: [a]: American poetry. 30 | Subject: [a]: Visual perception. 31 | -------------------------------------------------------------------------------- /tests/marc_xml_namespace.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_namespace: iterate and pretty print a MARC record 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'namespace.xml',File_MARC::SOURCE_FILE,"http://www.loc.gov/MARC21/slim"); 10 | while ($marc_record = $marc_file->next()) { 11 | print $marc_record->getLeader(); 12 | print "\n"; 13 | $field = $marc_record->getField('050'); 14 | print $field->getIndicator(1); 15 | print "\n"; 16 | print $field->getIndicator(2); 17 | print "\n"; 18 | $subfield = $field->getSubfield('a'); 19 | print $subfield->getData(); 20 | print "\n"; 21 | } 22 | ?> 23 | --EXPECT-- 24 | 00925njm 22002777a 4500 25 | 0 26 | 0 27 | Atlantic 1259 28 | 01832cmma 2200349 a 4500 29 | 0 30 | 0 31 | F204.W5 32 | -------------------------------------------------------------------------------- /tests/marc_xml_namespace_prefix.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_namespace: iterate and pretty print a MARC record 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'namespace.xml',File_MARC::SOURCE_FILE,"marc",true); 10 | while ($marc_record = $marc_file->next()) { 11 | print $marc_record->getLeader(); 12 | print "\n"; 13 | $field = $marc_record->getField('050'); 14 | print $field->getIndicator(1); 15 | print "\n"; 16 | print $field->getIndicator(2); 17 | print "\n"; 18 | $subfield = $field->getSubfield('a'); 19 | print $subfield->getData(); 20 | print "\n"; 21 | } 22 | ?> 23 | --EXPECT-- 24 | 00925njm 22002777a 4500 25 | 0 26 | 0 27 | Atlantic 1259 28 | 01832cmma 2200349 a 4500 29 | 0 30 | 0 31 | F204.W5 32 | -------------------------------------------------------------------------------- /tests/marc_xml_rsinger.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_rsinger2: iterate and pretty print a non-compliant MARC record (uppercase subfield codes) 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARCXML($dir . '/' . 'bad_example.xml'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record; 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | LDR 01850 a2200517 4500 18 | 001 0000000044 19 | 003 EMILDA 20 | 008 980120s1998 fi j 000 0 swe 21 | 005 20050204111518.0 22 | 020 _a9515008808 23 | _cFIM 72:00 24 | 035 _99515008808 25 | 040 _aNB 26 | 042 _9NB 27 | _9SEE 28 | 084 _aHcd,u 29 | _2kssb/6 30 | 084 _5NB 31 | _auHc 32 | _2kssb 33 | 084 _5SEE 34 | _aHcf 35 | _2kssb/6 36 | 084 _5Q 37 | _aHcd,uf 38 | _2kssb/6 39 | 100 1 _aJansson, Tove, 40 | _d1914-2001 41 | 245 0 _aDet osynliga barnet och andra bert̃telser / 42 | _cTove Jansson 43 | 250 _a7. uppl. 44 | 260 _aHelsingfors : 45 | _bSchildt, 46 | _c1998 ; 47 | _e(Falun : 48 | _fScandbook) 49 | 440 0 _aMumin-biblioteket, 50 | _x99-0698931-9 51 | 500 _aOriginaluppl. 1962 52 | 599 _aLi: S 53 | 740 4 _aDet osynliga barnet 54 | 775 1 _z951-50-0385-7 55 | _w9515003857 56 | _907 57 | 841 _5Li 58 | _axa 59 | _b0201080u 0 4000uu |000000 60 | _e1 61 | 841 _5SEE 62 | _axa 63 | _b0201080u 0 4000uu |000000 64 | _e1 65 | 841 _5L 66 | _axa 67 | _b0201080u 0 4000uu |000000 68 | _e1 69 | 841 _5NB 70 | _axa 71 | _b0201080u 0 4000uu |000000 72 | _e1 73 | 841 _5Q 74 | _axa 75 | _b0201080u 0 4000uu |000000 76 | _e1 77 | 841 _5S 78 | _axa 79 | _b0201080u 0 4000uu |000000 80 | _e1 81 | 852 _5NB 82 | _bNB 83 | _cNB98:12 84 | _hplikt 85 | _jR, 980520 86 | 852 _5Li 87 | _bLi 88 | _cCNB 89 | _hh,u 90 | 852 _5SEE 91 | _bSEE 92 | 852 _5Q 93 | _bQ 94 | _j98947 95 | 852 _5L 96 | _bL 97 | _c0100 98 | _h98/ 99 | _j3043 H 100 | 852 _5S 101 | _bS 102 | _hSv97 103 | _j7235 104 | 900 1s _aYanson, Tobe, 105 | _d1914-2001 106 | _uJansson, Tove, 107 | _d1914-2001 108 | 900 1s _aJanssonov,̀ Tove, 109 | _d1914-2001 110 | _uJansson, Tove, 111 | _d1914-2001 112 | 900 1s _aJansone, Tuve, 113 | _d1914-2001 114 | _uJansson, Tove, 115 | _d1914-2001 116 | 900 1s _aJanson, Tuve, 117 | _d1914-2001 118 | _uJansson, Tove, 119 | _d1914-2001 120 | 900 1s _aJansson, Tuve, 121 | _d1914-2001 122 | _uJansson, Tove, 123 | _d1914-2001 124 | 900 1s _aJanssonova, Tove, 125 | _d1914-2001 126 | _uJansson, Tove, 127 | _d1914-2001 128 | 976 2 _aHcd,u 129 | _bSkn̲litteratur 130 | -------------------------------------------------------------------------------- /tests/music.mrc: -------------------------------------------------------------------------------- 1 | 01145ncm 2200277 i 4500001001000000004000800010005001700018008004100035010001700076035002200093035001200115040000700127050002500134245005700159260003800216300002800254500005100282505026600333650001000599650004400609700004400653700003600697700004600733740002700779852006100806000073594AAJ580220030415102100.0801107s1977 nyujza  a 77771106  a(CaOTUIC)154601849 aAAJ5802 aLC00aM1366b.M62dM1527.204aThe Modern Jazz Quartet :bThe legendary profile. -- aNew York :bM.J.Q. Music,cc1977. ascore (72 p.) ;c31 cm. aFor piano, vibraphone, drums, and double bass.0 aLewis, J. Django.--Lewis, J. Plastic dreams (music from the film Kemek).--Lewis, J. Dancing (music from the film Kemek).--Lewis, J. Blues in A minor.--Lewis, J. Blues in B♭.--Lewis, J. Precious joy.--Jackson, M. The martyr.--Jackson, M. The legendary profile. 0aJazz. 0aMotion picture musicvExcerptsvScores.12aLewis, John,d1920-tSelections.f1977.12aJackson, Milt.tMartyrs.f1977.12aJackson, Milt.tLegendary profile.f1977.4 aThe legendary profile.00bMUSICcMAINkfoliohM1366iM62914Marvin Duchow Music5 2 | 01293cjm 2200289 a 450000100100000000500170001000700150002700800410004202400150008302800240009803500200012204000180014210000260016024500620018626000850024830000510033351101380038450000360052251800580055850000590061650000700067550501420074565000210088770000240090871000250093274000460095700187803920050110174900.0sd fungnn|||e|940202r19931981nyujzn i d1 a746457337202aJK 57337bRed Baron a(OCoLC)29737267 aSVPcSVPdLGG1 aDesmond, Paul,d1924-10aPaul Desmond & the Modern Jazz Quarteth[sound recording] aNew York, N.Y. :bRed Baron :bManufactured by Sony Music Entertainment,cp1993. a1 sound disc (39 min.) :bdigital ;c4 3/4 in.0 aPaul Desmond, alto saxophone; Modern Jazz Quartet: John Lewis, piano; Milt Jackson, vibraphone; Percy Heath, bass; Connie Kay, drums. aAll arrangements by John Lewis. aRecorded live on December 25, 1971 at Town Hall, NYC. aOriginally released in 1981 by Finesse as LP FW 27487. aProgram notes by Irving Townsend, June 1981, on container insert.0 aGreensleeves -- You go to my head -- Blue dove -- Jesus Christ Superstar -- Here's that rainy day -- East of the sun -- Bags' new groove. 0aJazzy1971-1980.1 aLewis, John,d1920-2 aModern Jazz Quartet.0 aPaul Desmond and the Modern Jazz Quartet. 3 | 01829cjm 2200385 a 450000100100000000500170001000700150002700800410004202400150008302800210009803300240011903300230014303300230016603300230018903500200021204000230023204800270025511000300028224500530031226000330036530000410039844000170043951102230045651802640067950000180094350000220096150502500098365000100123370000240124370000330126770000330130070000220133370000300135585200580138500196448220060626132700.0sd fzngnn|m|e|871211p19871957nyujzn d1 a422833290201a833 290-2bVerve0 a19571027b6299cD560 a196112--b3804cN40 a19571019b4104cC60 a197107--b6299cV7 a(OCoLC)17222092 aCPLcCPLdOCLdLGG apz01aka01asd01apd012 aModern Jazz Quartet.4prf14aThe Modern Jazz Quartet plush[sound recording]. a[New York] :bVerve,cp1987. a1 sound disc :bdigital ;c4 3/4 in. 0aCompact jazz0 aModern Jazz Quartet (principally) ; Milt Jackson, vibraphone (2nd and 8th works) ; Oscar Peterson, piano (2nd and 8th works) ; Ray Brown, bass (2nd and 8th works) ; Ed Thigpen (2nd work), Louis Hayes (8th work), drums. aRecorded live, Oct. 27, 1957, at the Donaueschingen Jazz Festival (1st, 5th, 7th, and 10th works); Dec. 1961, in New York (2nd work); live, Oct. 19, 1957, at the Opera House, Chicago (3rd, 4th, 6th, and 9th works); July 1971, in Villingen, Germany (8th work). aCompact disc. aAnalog recording.0 aThe golden striker (4:08) -- On Green Dolphin Street (7:28) -- D & E (4:55) -- I'll remember April (4:51) -- Cortège (7:15) -- Now's the time (4:43) -- J.B. blues (5:09) -- Reunion blues (6:35) -- 'Round midnight (3:56) -- Three windows (7:20). 0aJazz.1 aJackson, Milt.4prf1 aPeterson, Oscar,d1925-4prf1 aBrown, Ray,d1926-2002.4prf1 aThigpen, Ed.4prf1 aHayes, Louis,d1937-4prf80bMUSICcAVhCD 11314Marvin Duchow Music5Audio-Visual 4 | -------------------------------------------------------------------------------- /tests/onerecord.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <record xmlns="http://www.loc.gov/MARC21/slim"> 3 | <leader>01142cam 2200301 a 4500</leader> 4 | <controlfield tag="001"> 92005291 </controlfield> 5 | <controlfield tag="003">DLC</controlfield> 6 | <controlfield tag="005">19930521155141.9</controlfield> 7 | <controlfield tag="008">920219s1993 caua j 000 0 eng </controlfield> 8 | <datafield tag="010" ind1=" " ind2=" "> 9 | <subfield code="a"> 92005291 </subfield> 10 | </datafield> 11 | <datafield tag="020" ind1=" " ind2=" "> 12 | <subfield code="a">0152038655 :</subfield> 13 | <subfield code="c">$15.95</subfield> 14 | </datafield> 15 | <datafield tag="040" ind1=" " ind2=" "> 16 | <subfield code="a">DLC</subfield> 17 | <subfield code="c">DLC</subfield> 18 | <subfield code="d">DLC</subfield> 19 | </datafield> 20 | <datafield tag="042" ind1=" " ind2=" "> 21 | <subfield code="a">lcac</subfield> 22 | </datafield> 23 | <datafield tag="050" ind1="0" ind2="0"> 24 | <subfield code="a">PS3537.A618</subfield> 25 | <subfield code="b">A88 1993</subfield> 26 | </datafield> 27 | <datafield tag="082" ind1="0" ind2="0"> 28 | <subfield code="a">811/.52</subfield> 29 | <subfield code="2">20</subfield> 30 | </datafield> 31 | <datafield tag="100" ind1="1" ind2=" "> 32 | <subfield code="a">Sandburg, Carl,</subfield> 33 | <subfield code="d">1878-1967.</subfield> 34 | </datafield> 35 | <datafield tag="245" ind1="1" ind2="0"> 36 | <subfield code="a">Arithmetic /</subfield> 37 | <subfield code="c">Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand.</subfield> 38 | </datafield> 39 | <datafield tag="250" ind1=" " ind2=" "> 40 | <subfield code="a">1st ed.</subfield> 41 | </datafield> 42 | <datafield tag="260" ind1=" " ind2=" "> 43 | <subfield code="a">San Diego :</subfield> 44 | <subfield code="b">Harcourt Brace Jovanovich,</subfield> 45 | <subfield code="c">c1993.</subfield> 46 | </datafield> 47 | <datafield tag="300" ind1=" " ind2=" "> 48 | <subfield code="a">1 v. (unpaged) :</subfield> 49 | <subfield code="b">ill. (some col.) ;</subfield> 50 | <subfield code="c">26 cm.</subfield> 51 | </datafield> 52 | <datafield tag="500" ind1=" " ind2=" "> 53 | <subfield code="a">One Mylar sheet included in pocket.</subfield> 54 | </datafield> 55 | <datafield tag="520" ind1=" " ind2=" "> 56 | <subfield code="a">A poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone.</subfield> 57 | </datafield> 58 | <datafield tag="650" ind1=" " ind2="0"> 59 | <subfield code="a">Arithmetic</subfield> 60 | <subfield code="x">Juvenile poetry.</subfield> 61 | </datafield> 62 | <datafield tag="650" ind1=" " ind2="0"> 63 | <subfield code="a">Children's poetry, American.</subfield> 64 | </datafield> 65 | <datafield tag="650" ind1=" " ind2="1"> 66 | <subfield code="a">Arithmetic</subfield> 67 | <subfield code="x">Poetry.</subfield> 68 | </datafield> 69 | <datafield tag="650" ind1=" " ind2="1"> 70 | <subfield code="a">American poetry.</subfield> 71 | </datafield> 72 | <datafield tag="650" ind1=" " ind2="1"> 73 | <subfield code="a">Visual perception.</subfield> 74 | </datafield> 75 | <datafield tag="700" ind1="1" ind2=" "> 76 | <subfield code="a">Rand, Ted,</subfield> 77 | <subfield code="e">ill.</subfield> 78 | </datafield> 79 | </record> 80 | -------------------------------------------------------------------------------- /tests/parse_marc_php71.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | On php 7.3 the is no error 3 | --SKIPIF-- 4 | <?php include('tests/skipif.inc'); ?> 5 | --FILE-- 6 | <?php 7 | $dir = dirname(__FILE__); 8 | require __DIR__ . '/bootstrap.php'; 9 | $marc_file = new File_MARC($dir . '/' . 'bad_example2.mrc'); 10 | 11 | while ($marc_record = $marc_file->next()) { 12 | print $marc_record; 13 | print ""; 14 | } 15 | ?> 16 | --EXPECT-- 17 | LDR 015970028922450001000080 18 | -------------------------------------------------------------------------------- /tests/repeated_subfields.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <collection xmlns="http://www.loc.gov/MARC21/slim"> 3 | <record> 4 | <leader>01142cam 2200301 a 4500</leader> 5 | <controlfield tag="001"> 92005291 </controlfield> 6 | <controlfield tag="003">DLC</controlfield> 7 | <controlfield tag="005">19930521155141.9</controlfield> 8 | <controlfield tag="008">920219s1993 caua j 000 0 eng </controlfield> 9 | <datafield tag="010" ind1=" " ind2=" "> 10 | <subfield code="a"> 92005291 </subfield> 11 | </datafield> 12 | <datafield tag="020" ind1=" " ind2=" "> 13 | <subfield code="a">0152038655 :</subfield> 14 | <subfield code="c">$15.95</subfield> 15 | </datafield> 16 | <datafield tag="040" ind1=" " ind2=" "> 17 | <subfield code="a">DLC</subfield> 18 | <subfield code="c">DLC</subfield> 19 | <subfield code="d">DLC</subfield> 20 | </datafield> 21 | <datafield tag="042" ind1=" " ind2=" "> 22 | <subfield code="a">lcac</subfield> 23 | </datafield> 24 | <datafield tag="050" ind1="0" ind2="0"> 25 | <subfield code="a">PS3537.A618</subfield> 26 | <subfield code="b">A88 1993</subfield> 27 | </datafield> 28 | <datafield tag="082" ind1="0" ind2="0"> 29 | <subfield code="a">811/.52</subfield> 30 | <subfield code="2">20</subfield> 31 | </datafield> 32 | <datafield tag="100" ind1="1" ind2=" "> 33 | <subfield code="a">Sandburg, Carl,</subfield> 34 | <subfield code="d">1878-1967.</subfield> 35 | </datafield> 36 | <datafield tag="245" ind1="1" ind2="0"> 37 | <subfield code="a">Arithmetic /</subfield> 38 | <subfield code="c">Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand.</subfield> 39 | </datafield> 40 | <datafield tag="250" ind1=" " ind2=" "> 41 | <subfield code="a">1st ed.</subfield> 42 | </datafield> 43 | <datafield tag="260" ind1=" " ind2=" "> 44 | <subfield code="a">San Diego :</subfield> 45 | <subfield code="b">Harcourt Brace Jovanovich,</subfield> 46 | <subfield code="c">c1993.</subfield> 47 | </datafield> 48 | <datafield tag="300" ind1=" " ind2=" "> 49 | <subfield code="a">1 v. (unpaged) :</subfield> 50 | <subfield code="b">ill. (some col.) ;</subfield> 51 | <subfield code="c">26 cm.</subfield> 52 | </datafield> 53 | <datafield tag="500" ind1=" " ind2=" "> 54 | <subfield code="a">One Mylar sheet included in pocket.</subfield> 55 | </datafield> 56 | <datafield tag="520" ind1=" " ind2=" "> 57 | <subfield code="a">A poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone.</subfield> 58 | </datafield> 59 | <datafield tag="650" ind1=" " ind2="0"> 60 | <subfield code="a">Arithmetic</subfield> 61 | <subfield code="x">Juvenile poetry.</subfield> 62 | </datafield> 63 | <datafield tag="650" ind1=" " ind2="0"> 64 | <subfield code="a">Children's poetry, American</subfield> 65 | <subfield code="x">Oregon.</subfield> 66 | </datafield> 67 | <datafield tag="650" ind1=" " ind2="1"> 68 | <subfield code="a">Arithmetic</subfield> 69 | <subfield code="b">Really hard</subfield> 70 | <subfield code="x">Poetry</subfield> 71 | <subfield code="x">Unbelievable.</subfield> 72 | </datafield> 73 | <datafield tag="650" ind1=" " ind2="1"> 74 | <subfield code="a">American poetry.</subfield> 75 | </datafield> 76 | <datafield tag="650" ind1=" " ind2="1"> 77 | <subfield code="a">Visual perception.</subfield> 78 | </datafield> 79 | <datafield tag="700" ind1="1" ind2=" "> 80 | <subfield code="a">Rand, Ted,</subfield> 81 | <subfield code="e">ill.</subfield> 82 | </datafield> 83 | </record> 84 | </collection> 85 | -------------------------------------------------------------------------------- /tests/rsinger.xml: -------------------------------------------------------------------------------- 1 | <record xmlns="http://www.loc.gov/MARC21/slim"> 2 | <leader>00488nam a2200193 4500</leader> 3 | <controlfield tag="001">vtls002817361</controlfield> 4 | <controlfield tag="003">WlAbNL</controlfield> 5 | <controlfield tag="005">20060313054800.0</controlfield> 6 | <controlfield tag="008">060313 || | ||| d</controlfield> 7 | <datafield tag="016" ind1=" " ind2=" "> 8 | <subfield code="a">FREPO</subfield> 9 | </datafield> 10 | <datafield tag="020" ind1=" " ind2=" "> 11 | <subfield code="a">0751712035</subfield> 12 | </datafield> 13 | <datafield tag="035" ind1=" " ind2=" "> 14 | <subfield code="a">(WlAbNL)LLGCb13197045</subfield> 15 | </datafield> 16 | <datafield tag="039" ind1=" " ind2="9"> 17 | <subfield code="y">200603130548</subfield> 18 | <subfield code="z">load</subfield> 19 | </datafield> 20 | <datafield tag="040" ind1=" " ind2=" "> 21 | <subfield code="a">CA</subfield> 22 | </datafield> 23 | <datafield tag="245" ind1="1" ind2="0"> 24 | <subfield code="a">Financial Reporting.\ Paper 2.5</subfield> 25 | </datafield> 26 | <datafield tag="250" ind1=" " ind2=" "> 27 | <subfield code="a">3rd 2003</subfield> 28 | </datafield> 29 | <datafield tag="260" ind1=" " ind2=" "> 30 | <subfield code="b">BPP Publishing Ltd</subfield> 31 | </datafield> 32 | <datafield tag="949" ind1=" " ind2=" "> 33 | <subfield code="A">VIRTUAITEM</subfield> 34 | <subfield code="D">2200000</subfield> 35 | <subfield code="X">1</subfield> 36 | <subfield code="6">0627390</subfield> 37 | </datafield> 38 | <datafield tag="999" ind1=" " ind2=" "> 39 | <subfield code="a">VIRTUA50 </subfield> 40 | </datafield> 41 | </record> 42 | -------------------------------------------------------------------------------- /tests/sandburg.mrc: -------------------------------------------------------------------------------- 1 | 01142cam 2200301 a 4500001001300000003000400013005001700017008004100034010001700075020002500092040001800117042000900135050002600144082001600170100003200186245008600218250001200304260005200316300004900368500004000417520022800457650003300685650003300718650002400751650002100775650002300796700002100819 92005291 DLC19930521155141.9920219s1993 caua j 000 0 eng  a 92005291  a0152038655 :c$15.95 aDLCcDLCdDLC alcac00aPS3537.A618bA88 199300a811/.522201 aSandburg, Carl,d1878-1967.10aArithmetic /cCarl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. a1st ed. aSan Diego :bHarcourt Brace Jovanovich,cc1993. a1 v. (unpaged) :bill. (some col.) ;c26 cm. aOne Mylar sheet included in pocket. aA poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone. 0aArithmeticxJuvenile poetry. 0aChildren's poetry, American. 1aArithmeticxPoetry. 1aAmerican poetry. 1aVisual perception.1 aRand, Ted,eill. -------------------------------------------------------------------------------- /tests/sandburg.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <collection xmlns="http://www.loc.gov/MARC21/slim"> 3 | <record> 4 | <leader>01142cam 2200301 a 4500</leader> 5 | <controlfield tag="001"> 92005291 </controlfield> 6 | <controlfield tag="003">DLC</controlfield> 7 | <controlfield tag="005">19930521155141.9</controlfield> 8 | <controlfield tag="008">920219s1993 caua j 000 0 eng </controlfield> 9 | <datafield tag="010" ind1=" " ind2=" "> 10 | <subfield code="a"> 92005291 </subfield> 11 | </datafield> 12 | <datafield tag="020" ind1=" " ind2=" "> 13 | <subfield code="a">0152038655 :</subfield> 14 | <subfield code="c">$15.95</subfield> 15 | </datafield> 16 | <datafield tag="040" ind1=" " ind2=" "> 17 | <subfield code="a">DLC</subfield> 18 | <subfield code="c">DLC</subfield> 19 | <subfield code="d">DLC</subfield> 20 | </datafield> 21 | <datafield tag="042" ind1=" " ind2=" "> 22 | <subfield code="a">lcac</subfield> 23 | </datafield> 24 | <datafield tag="050" ind1="0" ind2="0"> 25 | <subfield code="a">PS3537.A618</subfield> 26 | <subfield code="b">A88 1993</subfield> 27 | </datafield> 28 | <datafield tag="082" ind1="0" ind2="0"> 29 | <subfield code="a">811/.52</subfield> 30 | <subfield code="2">20</subfield> 31 | </datafield> 32 | <datafield tag="100" ind1="1" ind2=" "> 33 | <subfield code="a">Sandburg, Carl,</subfield> 34 | <subfield code="d">1878-1967.</subfield> 35 | </datafield> 36 | <datafield tag="245" ind1="1" ind2="0"> 37 | <subfield code="a">Arithmetic /</subfield> 38 | <subfield code="c">Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand.</subfield> 39 | </datafield> 40 | <datafield tag="250" ind1=" " ind2=" "> 41 | <subfield code="a">1st ed.</subfield> 42 | </datafield> 43 | <datafield tag="260" ind1=" " ind2=" "> 44 | <subfield code="a">San Diego :</subfield> 45 | <subfield code="b">Harcourt Brace Jovanovich,</subfield> 46 | <subfield code="c">c1993.</subfield> 47 | </datafield> 48 | <datafield tag="300" ind1=" " ind2=" "> 49 | <subfield code="a">1 v. (unpaged) :</subfield> 50 | <subfield code="b">ill. (some col.) ;</subfield> 51 | <subfield code="c">26 cm.</subfield> 52 | </datafield> 53 | <datafield tag="500" ind1=" " ind2=" "> 54 | <subfield code="a">One Mylar sheet included in pocket.</subfield> 55 | </datafield> 56 | <datafield tag="520" ind1=" " ind2=" "> 57 | <subfield code="a">A poem about numbers and their characteristics. Features anamorphic, or distorted, drawings which can be restored to normal by viewing from a particular angle or by viewing the image's reflection in the provided Mylar cone.</subfield> 58 | </datafield> 59 | <datafield tag="650" ind1=" " ind2="0"> 60 | <subfield code="a">Arithmetic</subfield> 61 | <subfield code="x">Juvenile poetry.</subfield> 62 | </datafield> 63 | <datafield tag="650" ind1=" " ind2="0"> 64 | <subfield code="a">Children's poetry, American.</subfield> 65 | </datafield> 66 | <datafield tag="650" ind1=" " ind2="1"> 67 | <subfield code="a">Arithmetic</subfield> 68 | <subfield code="x">Poetry.</subfield> 69 | </datafield> 70 | <datafield tag="650" ind1=" " ind2="1"> 71 | <subfield code="a">American poetry.</subfield> 72 | </datafield> 73 | <datafield tag="650" ind1=" " ind2="1"> 74 | <subfield code="a">Visual perception.</subfield> 75 | </datafield> 76 | <datafield tag="700" ind1="1" ind2=" "> 77 | <subfield code="a">Rand, Ted,</subfield> 78 | <subfield code="e">ill.</subfield> 79 | </datafield> 80 | </record> 81 | </collection> 82 | -------------------------------------------------------------------------------- /tests/skipif.inc: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | // Stash the current error_reporting value 4 | $error_reporting = error_reporting(); 5 | 6 | // Restore the error reporting to previous value 7 | error_reporting($error_reporting); 8 | 9 | ?> 10 | -------------------------------------------------------------------------------- /tests/skipif_noispn.inc: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | // Stash the current error_reporting value 4 | $error_reporting = error_reporting(); 5 | 6 | // Disable warnings for the include_once() test 7 | error_reporting(E_ALL & ~E_WARNING); 8 | 9 | if (file_exists(__DIR__ . '/../vendor/autoload.php')) { 10 | // Composer 11 | require __DIR__ . '/bootstrap.php'; 12 | 13 | if (!class_exists('Validate_ISPN')) { 14 | print("skip - Validate_ISPN package is not installed."); 15 | } 16 | } else { 17 | // Pear 18 | if (!include_once('Validate/ISPN.php')) { 19 | print("skip - Validate_ISPN package is not installed."); 20 | } 21 | } 22 | 23 | // Restore the error reporting to previous value 24 | error_reporting($error_reporting); 25 | 26 | ?> 27 | -------------------------------------------------------------------------------- /tests/wronglen.mrc: -------------------------------------------------------------------------------- 1 | 00727nam 2200205 a 450000100110000000500170001100800410002803500200006905000220008910000220011124500520013325000260018526000420021130000200025365000560027365000560032965000560038594900740044159600060051503-001645819971103184734.0970701s1997 oru u000 0 eng u a(Sirsi) a35166400aML270.2b.A6 19971 aAnthony, James R.00aFrench baroque music from Beaujoyeulx to Rameau aRev. and expanded ed. aPortland, OR :bAmadeus Press,c1997. a586 p. :bmusic 0aMusic<Francey16th centuryxHistory and criticism. 0aMusiczFrancey17th centuryxHistory and criticism. 0aMusiczFrancey18th centuryxHistory and criticism. aML 270.2 A6 1997wLCi30007006841505rYtBOOKSlHUNT-CIRCmHUNEXTRALONGSTUFFTINGTON a1 2 | -------------------------------------------------------------------------------- /tests/xmlescape.mrc: -------------------------------------------------------------------------------- 1 | 00727nam 2200205 a 450000100110000000500170001100800410002803500200006905000220008910000220011124500520013325000260018526000420021130000200025365000560027365000560032965000560038594900740044159600060051503-001645819971103184734.0970701s1997 oru u000 0 eng u a(Sirsi) a35166400aML270.2b.A6 19971 aAnthony, James R.00aFrench baroque music from Beaujoyeulx to Rameau aRev. and expanded ed. aPortland, OR :bAmadeus Press,c1997. a586 p. :bmusic 0aMusic<Francey16th centuryxHistory and criticism. 0aMusiczFrancey17th centuryxHistory and criticism. 0aMusiczFrancey18th centuryxHistory and criticism. aML 270.2 A6 1997wLCi30007006841505rYtBOOKSlHUNT-CIRCmHUNTINGTON a1 2 | --------------------------------------------------------------------------------