Class File_MARC_Record

Description

Represents a single MARC record

A MARC record contains a leader and zero or more fields held within a linked list structure. Fields are represented by File_MARC_Data_Field objects.

Located in /MARC/Record.php (line 53)


	
			
Variable Summary
Method Summary
true __construct ()
void __destruct ()
void addWarnings (string $warning)
int deleteFields (string $tag, [bool $pcre = null])
{@link getField ([string $spec = null], [bool $pcre = null])
File_MARC_List|array getFields ([string $spec = null], [bool $pcre = null])
string getLeader ()
array getWarnings ( $warning)
File_MARC_Field insertField (File_MARC_Field $new_field, File_MARC_Field $existing_field, [bool $before = false])
string setLeader (string $leader)
bool setLeaderLengths (int $record_length, int $base_address)
string toRaw ()
string toXML ([string $encoding = "UTF-8"], [bool $indent = true])
string __toString ()
Variables
File_MARC_List $fields (line 61)

Contains a linked list of File_MARC_Data_Field objects for

this record

  • access: protected
string $leader (line 67)

Record leader

  • access: protected
array $warnings (line 73)

Non-fatal warnings generated during parsing

  • access: protected
Methods
Constructor __construct (line 83)

Start function

Set all variables to defaults to create new File_MARC_Record object

true __construct ()
Destructor __destruct (line 94)

Destroys the data field

void __destruct ()
addWarnings (line 391)

Add a warning to the MARC record that something non-fatal occurred during parsing.

  • access: public
void addWarnings (string $warning)
  • string $warning: warning message
appendField (line 143)

Appends field to MARC record

Adds a File_MARC_Control_Field or File_MARC_Data_Field object to the end of the existing list of fields.

  • return: The field that was added
File_MARC_Field appendField (File_MARC_Field $new_field)
deleteFields (line 367)

Delete all occurrences of a field matching a tag name from the record.

  • return: number of fields that were deleted
int deleteFields (string $tag, [bool $pcre = null])
  • string $tag: tag for the fields to be deleted
  • bool $pcre: if true, then match as a regular expression
getField (line 313)

Return the first File_MARC_Data_Field or File_MARC_Control_Field object that matches the specified tag name. Returns false if no match is found.

{@link getField ([string $spec = null], [bool $pcre = null])
  • string $spec: tag name
  • bool $pcre: if true, then match as a regular expression
getFields (line 340)

Return an array or File_MARC_List containing all File_MARC_Data_Field or File_MARC_Control_Field objects that match the specified tag name. If the tag name is omitted all fields are returned.

File_MARC_List|array getFields ([string $spec = null], [bool $pcre = null])
  • string $spec: tag name
  • bool $pcre: if true, then match as a regular expression
getLeader (line 110)

Get MARC leader

Returns the leader for the MARC record. No validation on the specified leader is performed.

  • return: returns the leader
string getLeader ()
getWarnings (line 403)

Return the array of warnings from the MARC record.

  • return: warning messages
  • access: public
array getWarnings ( $warning)
  • $warning
insertField (line 200)

Inserts a field in the MARC record relative to an existing field

Inserts a File_MARC_Control_Field or File_MARC_Data_Field object before or after a specified existing field.

  1.  // Example: Insert a new field before the first 650 field
  2.  
  3.  // Create the new field
  4.   $subfields[new File_MARC_Data_Subfield('a''Scott, Daniel.');
  5.  $new_field new File_MARC_Data_Field('100'$subfields0null);
  6.  
  7.  // Retrieve the target field for our insertion point
  8.   $subject $record->getFields('650');
  9.  
  10.  // Insert the new field
  11.   if (is_array($subject)) {
  12.      $record->insertField($new_field$subject[0]true);
  13.  }
  14.  elseif ($subject{
  15.      $record->insertField($new_field$subjecttrue);
  16.  }

  • return: The field that was added
File_MARC_Field insertField (File_MARC_Field $new_field, File_MARC_Field $existing_field, [bool $before = false])
  • File_MARC_Field $new_field: The field to add
  • File_MARC_Field $existing_field: The target field
  • bool $before: Insert the new field before the existing field if true, after the existing field if false
prependField (line 161)

Prepends field to MARC record

Adds a File_MARC_Control_Field or File_MARC_Data_Field object to the start of to the existing list of fields.

  • return: The field that was added
File_MARC_Field prependField (File_MARC_Field $new_field)
setLeader (line 126)

Set MARC record leader

Sets the leader for the MARC record. No validation on the specified leader is performed.

  • return: returns the leader
string setLeader (string $leader)
  • string $leader: Leader
setLeaderLengths (line 285)

Set MARC record leader lengths

Set the Leader lengths of the record according to defaults specified in http://www.loc.gov/marc/bibliographic/ecbdldrd.html

  • return: Success or failure
bool setLeaderLengths (int $record_length, int $base_address)
  • int $record_length: Record length
  • int $base_address: Base address of data
toRaw (line 435)

Return the record in raw MARC format.

If you have modified an existing MARC record or created a new MARC record, use this method to save the record for use in other programs that accept the MARC format -- for example, your integrated library system.

  1.  // Example: Modify a record and save the output to a file
  2.   $record->deleteFields('650');
  3.  
  4.  // Now that the record has no subject fields, save it to disk
  5.   fopen($file'/home/dan/no_subject.mrc''w');
  6.  fwrite($file$record->toRaw());
  7.  fclose($file);

  • return: Raw MARC data
string toRaw ()
toXML (line 486)

Return the MARC record in MARCXML format

This method produces an XML representation of a MARC record that attempts to adhere to the MARCXML standard documented at http://www.loc.gov/standards/marcxml/

  • return: representation of MARC record in MARCXML format
  • todo: Fix encoding input / output issues (PHP 6.0 required?)
string toXML ([string $encoding = "UTF-8"], [bool $indent = true])
  • string $encoding: output encoding for the MARCXML record
  • bool $indent: pretty-print the MARCXML record
__toString (line 459)

Return the MARC record in a pretty printed string

This method produces an easy-to-read textual display of a MARC record.

The structure is roughly: <tag> <ind1> <ind2> _

  • return: Formatted representation of MARC record
string __toString ()

Documentation generated on Mon, 01 Jan 2007 23:44:42 -0500 by phpDocumentor 1.3.1