├── .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 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. The basic requirement for File_MARC is PHP 5 with a working PEAR installer. The PEAR installer will install any dependencies for you.
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
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
10 | Requirements
15 |
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 |
Read the File_MARC API documentation.
26 |Current release: 0.1.0-alpha is hosted at PEAR.
40 | 41 |Comments are welcome by email at dbs@php.net.
43 | 44 |,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 | 5 | 6 | --FILE-- 7 | 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 | 5 | 6 | --FILE-- 7 | "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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record->toXML(); 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | 18 | 19 | 98 | -------------------------------------------------------------------------------- /tests/marc_xml_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | marc_xml_003: Round-trip a MARCXML record to MARC21 (LOC standard) 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record->toXML(); 13 | print "\n"; 14 | } 15 | ?> 16 | --EXPECT-- 17 | 18 |20 | 97 |01142cam 2200301 a 4500 21 |92005291 22 |DLC 23 |19930521155141.9 24 |920219s1993 caua j 000 0 eng 25 |26 | 28 |92005291 27 |29 | 32 |0152038655 : 30 |$15.95 31 |33 | 37 |DLC 34 |DLC 35 |DLC 36 |38 | 40 |lcac 39 |41 | 44 |PS3537.A618 42 |A88 1993 43 |45 | 48 |811/.52 46 |20 47 |49 | 52 |Sandburg, Carl, 50 |1878-1967. 51 |53 | 56 |Arithmetic / 54 |Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. 55 |57 | 59 |1st ed. 58 |60 | 64 |San Diego : 61 |Harcourt Brace Jovanovich, 62 |c1993. 63 |65 | 69 |1 v. (unpaged) : 66 |ill. (some col.) ; 67 |26 cm. 68 |70 | 72 |One Mylar sheet included in pocket. 71 |73 | 75 |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. 74 |76 | 79 |Arithmetic 77 |Juvenile poetry. 78 |80 | 82 |Children's poetry, American. 81 |83 | 86 |Arithmetic 84 |Poetry. 85 |87 | 89 |American poetry. 88 |90 | 92 |Visual perception. 91 |93 | 96 |Rand, Ted, 94 |ill. 95 |19 | 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 | 5 | --FILE-- 6 | 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 | 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 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 | 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 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 22 |20 | 80 |00727nam 2200205 a 4500 21 |03-0016458 22 |19971103184734.0 23 |970701s1997 oru u000 0 eng u 24 |25 | 27 |(Sirsi) a351664 26 |28 | 31 |ML270.2 29 |.A6 1997 30 |32 | 34 |Anthony, James R. 33 |35 | 37 |French baroque music from Beaujoyeulx to Rameau 36 |38 | 40 |Rev. and expanded ed. 39 |41 | 45 |Portland, OR : 42 |Amadeus Press, 43 |1997. 44 |46 | 49 |586 p. : 47 |music 48 |50 | 55 |Music 51 |France 52 |16th century 53 |History and criticism. 54 |56 | 61 |Music 57 |France 58 |17th century 59 |History and criticism. 60 |62 | 67 |Music 63 |France 64 |18th century 65 |History and criticism. 66 |68 | 76 |ML 270.2 A6 1997 69 |LC 70 |30007006841505 71 |Y 72 |BOOKS 73 |HUNT-CIRC 74 |HUNTINGTON 75 |77 | 79 |1 78 |23 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 5 | --FILE-- 6 | 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 | 2 |24 | 80 |00925njm 22002777a 4500 25 |5637241 26 |DLC 27 |19920826084036.0 28 |sdubumennmplu 29 |910926s1957 nyuuun eng 30 |31 | 33 |91758335 32 |34 | 37 |1259 35 |Atlantic 36 |38 | 41 |DLC 39 |DLC 40 |42 | 44 |Atlantic 1259 43 |45 | 48 |The Great Ray Charles 46 |[sound recording]. 47 |49 | 53 |New York, N.Y. : 50 |Atlantic, 51 |[1957?] 52 |54 | 58 |1 sound disc : 55 |analog, 33 1/3 rpm ; 56 |12 in. 57 |59 | 61 |Ray Charles, piano & celeste. 60 |62 | 64 |The Ray -- My melancholy baby -- Black coffee -- There's no you -- Doodlin' -- Sweet sixteen bars -- I surrender dear -- Undecided. 63 |65 | 67 |Brief record. 66 |68 | 71 |Jazz 69 |1951-1960. 70 |72 | 74 |Piano with jazz ensemble. 73 |75 | 79 |Charles, Ray, 76 |1930- 77 |prf 78 |81 | 175 |01832cmma 2200349 a 4500 82 |12149120 83 |20001005175443.0 84 |cr ||| 85 |000407m19949999dcu g m eng d 86 |87 | 95 |0 88 |ibc 89 |copycat 90 |1 91 |ncip 92 |20 93 |y-gencompf 94 |96 | 99 |undetermined 97 |web preservation project (wpp) 98 |100 | 102 |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 101 |103 | 105 |00530046 104 |106 | 108 |(OCoLC)ocm44279786 107 |109 | 114 |IEU 110 |IEU 111 |N@F 112 |DLC 113 |115 | 117 |lccopycat 116 |118 | 121 |n-us-dc 119 |n-us--- 120 |122 | 124 |F204.W5 123 |125 | 128 |975.3 126 |13 127 |129 | 132 |The White House 130 |[computer file]. 131 |133 | 135 |Computer data. 134 |136 | 140 |Washington, D.C. : 137 |White House Web Team, 138 |1994- 139 |141 | 143 |Mode of access: Internet. 142 |144 | 146 |Title from home page as viewed on Aug. 19, 2000. 145 |147 | 149 |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. 148 |150 | 152 |White House (Washington, D.C.) 151 |153 | 156 |United States. 154 |Executive Office of the President. 155 |157 | 160 |United States. 158 |Office of the Vice President. 159 |161 | 164 |United States. 162 |Office of the First Lady. 163 |165 | 167 |White House Web Team. 166 |168 | 170 |http://www.whitehouse.gov 169 |171 | 174 |http://lcweb.loc.gov/staff/wpp/whitehouse.html 172 |Web site archive 173 |3 | 80 | -------------------------------------------------------------------------------- /tests/parse_marc_php71.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | On php 7.3 the is no error 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | next()) { 12 | print $marc_record; 13 | print ""; 14 | } 15 | ?> 16 | --EXPECT-- 17 | LDR 015970028922450001000080 18 | -------------------------------------------------------------------------------- /tests/repeated_subfields.xml: -------------------------------------------------------------------------------- 1 | 2 |01142cam 2200301 a 4500 4 |92005291 5 |DLC 6 |19930521155141.9 7 |920219s1993 caua j 000 0 eng 8 |9 | 11 |92005291 10 |12 | 15 |0152038655 : 13 |$15.95 14 |16 | 20 |DLC 17 |DLC 18 |DLC 19 |21 | 23 |lcac 22 |24 | 27 |PS3537.A618 25 |A88 1993 26 |28 | 31 |811/.52 29 |20 30 |32 | 35 |Sandburg, Carl, 33 |1878-1967. 34 |36 | 39 |Arithmetic / 37 |Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. 38 |40 | 42 |1st ed. 41 |43 | 47 |San Diego : 44 |Harcourt Brace Jovanovich, 45 |c1993. 46 |48 | 52 |1 v. (unpaged) : 49 |ill. (some col.) ; 50 |26 cm. 51 |53 | 55 |One Mylar sheet included in pocket. 54 |56 | 58 |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. 57 |59 | 62 |Arithmetic 60 |Juvenile poetry. 61 |63 | 65 |Children's poetry, American. 64 |66 | 69 |Arithmetic 67 |Poetry. 68 |70 | 72 |American poetry. 71 |73 | 75 |Visual perception. 74 |76 | 79 |Rand, Ted, 77 |ill. 78 |3 | 85 | -------------------------------------------------------------------------------- /tests/rsinger.xml: -------------------------------------------------------------------------------- 1 |4 | 84 |01142cam 2200301 a 4500 5 |92005291 6 |DLC 7 |19930521155141.9 8 |920219s1993 caua j 000 0 eng 9 |10 | 12 |92005291 11 |13 | 16 |0152038655 : 14 |$15.95 15 |17 | 21 |DLC 18 |DLC 19 |DLC 20 |22 | 24 |lcac 23 |25 | 28 |PS3537.A618 26 |A88 1993 27 |29 | 32 |811/.52 30 |20 31 |33 | 36 |Sandburg, Carl, 34 |1878-1967. 35 |37 | 40 |Arithmetic / 38 |Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. 39 |41 | 43 |1st ed. 42 |44 | 48 |San Diego : 45 |Harcourt Brace Jovanovich, 46 |c1993. 47 |49 | 53 |1 v. (unpaged) : 50 |ill. (some col.) ; 51 |26 cm. 52 |54 | 56 |One Mylar sheet included in pocket. 55 |57 | 59 |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. 58 |60 | 63 |Arithmetic 61 |Juvenile poetry. 62 |64 | 67 |Children's poetry, American 65 |Oregon. 66 |68 | 73 |Arithmetic 69 |Really hard 70 |Poetry 71 |Unbelievable. 72 |74 | 76 |American poetry. 75 |77 | 79 |Visual perception. 78 |80 | 83 |Rand, Ted, 81 |ill. 82 |2 | 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 | 2 |00488nam a2200193 4500 3 |vtls002817361 4 |WlAbNL 5 |20060313054800.0 6 |060313 || | ||| d 7 |8 | 10 |FREPO 9 |11 | 13 |0751712035 12 |14 | 16 |(WlAbNL)LLGCb13197045 15 |17 | 20 |200603130548 18 |load 19 |21 | 23 |CA 22 |24 | 26 |Financial Reporting.\ Paper 2.5 25 |27 | 29 |3rd 2003 28 |30 | 32 |BPP Publishing Ltd 31 |33 | 38 |VIRTUAITEM 34 |2200000 35 |1 36 |0627390 37 |39 | 41 |VIRTUA50 40 |3 | 82 | -------------------------------------------------------------------------------- /tests/skipif.inc: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /tests/skipif_noispn.inc: -------------------------------------------------------------------------------- 1 | 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 0aMusic4 | 81 |01142cam 2200301 a 4500 5 |92005291 6 |DLC 7 |19930521155141.9 8 |920219s1993 caua j 000 0 eng 9 |10 | 12 |92005291 11 |13 | 16 |0152038655 : 14 |$15.95 15 |17 | 21 |DLC 18 |DLC 19 |DLC 20 |22 | 24 |lcac 23 |25 | 28 |PS3537.A618 26 |A88 1993 27 |29 | 32 |811/.52 30 |20 31 |33 | 36 |Sandburg, Carl, 34 |1878-1967. 35 |37 | 40 |Arithmetic / 38 |Carl Sandburg ; illustrated as an anamorphic adventure by Ted Rand. 39 |41 | 43 |1st ed. 42 |44 | 48 |San Diego : 45 |Harcourt Brace Jovanovich, 46 |c1993. 47 |49 | 53 |1 v. (unpaged) : 50 |ill. (some col.) ; 51 |26 cm. 52 |54 | 56 |One Mylar sheet included in pocket. 55 |57 | 59 |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. 58 |60 | 63 |Arithmetic 61 |Juvenile poetry. 62 |64 | 66 |Children's poetry, American. 65 |67 | 70 |Arithmetic 68 |Poetry. 69 |71 | 73 |American poetry. 72 |74 | 76 |Visual perception. 75 |77 | 80 |Rand, Ted, 78 |ill. 79 |