Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add toXMLHeader() and toXMLFooter() methods to wrap collections appro…
…priately Returns the default toXML() mode to outputting a single record wrapped in a collection element for backwards compatibility. Although it's tempting to change that before a 1.0 release. A reasonable example of generating a collection of MARCXML records now looks like: <?php require 'File/MARCXML.php'; $xml_data = 'SOCIAL_SCIENCES_UTF_8_20100721.xml'; $books = new File_MARCXML($xml_data); $public_note = "Available online / Disponible en ligne"; // Add the XML header and opening <collection> element print $books->toXMLHeader(); // Iterate through the retrieved records while ($record = $books->next()) { // Pretty print each record $urls = $record->getFields('856'); foreach ($urls as $url) { // These are the actual resources, ensure indicator 2 is set accordingly $url->setIndicator(2, '0'); // Prepend our proxy URL and fix the existing URL $u = $url->getSubfields('u'); foreach ($u as $uri) { $uri->setData('http://librweb.laurentian.ca/login?url=http://' . $uri->getData()); } // Set our desired public note $notes = $url->getSubfields('z'); foreach ($notes as $note) { $note->setData($public_note); } // Some of these don't have public notes; create if necessary if (!count($notes)) { $url->appendSubfield(new File_MARC_Subfield('z', $public_note)); } } // Generate the XML output for this record $record->toXML(); } // Add the </collection> closing element and dump the XMLWriter contents print $books->toXMLFooter(); git-svn-id: https://svn.php.net/repository/pear/packages/File_MARC/trunk@301725 c90b9560-bf6c-de11-be94-00142212c4b1
- Loading branch information
Dan Scott
committed
Jul 30, 2010
1 parent
2c5bf0e
commit ba7c1c1
Showing
3 changed files
with
172 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters