Using Voyager SIF records to create Alma XML patron load data
$patron_record = readsifline($line);
Once you’ve got your patron record, you can access various elements in the record, ie:
print $patron_record['patron_registration_date'];
This means that we can do something like:
$xmldas = SDO_DAS_XML::create(); $xmldas->addTypes("xsd/user_record_simpletypes.xsd"); $doc = $xmldas->createDocument(); $rdo = $doc->getRootDataObject(); $userDetails = $xmldas->createDataObject('http://com/exlibris/urm/user_record/xmlbeans','userDetails'); $userDetails->firstName = rtrim($patron_record['first_name']); $userDetails->middleName = rtrim($patron_record['middle_name']); $userDetails->status = "Active"; $userDetails->userType = "External"; $userDetails->userName = rtrim($patron_record['inst_id']); ...
Using the dates from the SIF record is fairly straight forward – we just need to remove the ‘.’s in the Voyager SIF record and any trailing spaces
$userDetails->expiryDate = preg_replace('/\./','',rtrim($patron_record['patron_expiration_date'])); $userDetails->purgeDate = preg_replace('/\./','',rtrim($patron_record['patron_purge_date'])); ... $rdo->userDetails = $userDetails;
In the example below you can attach additional nodes to the userDetails node to specify identifiers
Ie barcodes from the SIF record:
$userIdentifiers = $xmldas->createDataObject('http://com/exlibris/urm/user_record/xmlbeans','userIdentifiersList'); for ($t = 1; $t <= 3; $t++) { $userident = $xmldas->createDataObject('http://com/exlibris/urm/user_record/xmlbeans','userIdentifier'); $userident->type = "BARCODE"; $userident->value = rtrim($patron_record['patron_barcode'.$t]); ...
And only add the barcode identifier branch where it wasn’t empty and the patron group was valid in the SIF file – ie:
$userIdentifiers->userIdentifier = $userident;
Once you’ve filled in all of the fields you can, using the Voyager SIF data, and added any additional information, you can then save off the final XML document after ensuring you’ve attached all the nodes to the XML document in the correct spots. If you’ve created nodes and not attached them, then they won’t be saved to the XML record.
Save the final XML document for the patron record off to a string to allow us to do some cleanup before output:
$test_record = $xmldas->saveString($doc,-1);
Then clear away the extraneous XML formating to provide a simple and clean XML record to add to the end of the list of user records:
$test_record = preg_replace('/ xmlns:tns="http:\/\/com\/exlibris\/urm\/user_record\/xmlbeans" xmlns:xsi="http:\/\/www.w3.org\/2001\/XMLSchema-instance"/','',$test_record); $test_record = preg_replace('/\<\?xml version="1.0" encoding="UTF-8"\?\>\\n/','',$test_record);
Which ends up producing something like:
<userRecord><userDetails><status>Inactive</status><userType>External</userType><expiryDate>20160331</expiryDate><defaultLanguage>en</defaultLanguage><userName>TEST</userName><firstName >Melissa</firstName><lastName>Smith</lastName><middleName>Sheelly</middleName><jobTitle></jobTitle><jobDescription></jobDescription><userGroup>P</userGroup><birthDate></birthDate><purg eDate>20291231</purgeDate><password></password><pinNumber></pinNumber></userDetails><owneredEntity><modificationDate>20150223</modificationDate><createdBy>SIS</createdBy></owneredEntity>< userNoteList/><userBlockList><userBlock><status>Active</status><type>Cash</type><note>Sanction for outstanding debt from Student System applied 23/02/2015</note><blockDefinitionId>SUSPEND ED</blockDefinitionId></userBlock></userBlockList><userIdentifiers/><userAddressList><userPhone preferred="false" preferredSMS="true"><phone>0414888888</phone><types><userPhoneTypes>mobil e</userPhoneTypes></types></userPhone><userAddress preferred="true"><line1>6 Jones Ave</line1><line2></line2><line3></line3><line4></line4><line5></line5><city>WEST CROYDON</city><sta teProvince>SA</stateProvince><postalCode>5008</postalCode><country></country><startDate>20150220</startDate><endDate>20291231</endDate><types><userAddressTypes>home</userAddressTypes></ty pes></userAddress><userEmail preferred="true"><email>smith01@flinders.edu.au</email><types><userEmailTypes>personal</userEmailTypes></types></userEmail></userAddressList><userStatistical CategoriesList><userCategory><statisticalCategory>MRO</statisticalCategory></userCategory><userCategory><statisticalCategory>914</statisticalCategory></userCategory><userCategory><statist icalCategory>1</statisticalCategory></userCategory><userCategory><statisticalCategory>OD</statisticalCategory></userCategory><userCategory><statisticalCategory>DOC</statisticalCategory></ userCategory></userStatisticalCategoriesList></userRecord>
We’ve also set the creator of the record to SIS, which is the identifier used by the external interface in Alma that loads the records from our Student System.
The PHP include file from this blog are available here, but is for use at your own risk.
One Reply to “Using Voyager SIF records to create Alma XML patron load data”
Leave a Reply
You must be logged in to post a comment.
How do you use this PHP script?