Working with Bibliographic Records in XML

Ex Libris Developer Network Ex Libris Cloud Apps Tutorials Working with Bibliographic Records in XML

Bibliographic records are represented in Alma in various XML formats, including MARCXML and DC XML. Until now we’ve used the JSON representation of objects when working with the Alma APIs. However, to create and update BIB records we need to manipulate XML and send XML to Alma .

In this tutorial, we’ll create a component which will watch for the user to navigate to a BIB record in Alma and update the BIB by adding a 500-note field. The component will add the field to the MARCXML and save the record back to Alma.

We start by following the instructions in the “Adding additional routes” tutorial to add a new component and route called “xml”.

Once the user has navigated to a bibliographic record in Alma, our xml.component.html file displays the title and author and a button which calls the addNote method.

xml.component.htmlView on Github

In the init method of our component, we subscribe to the onPageLoad event and provide a handler which looks for bibliographic records. When we see that the user has browsed to a bibliographic record, we retrieve the bib with the API. If the BIB is in MARC21 format, we set the local bib property to the selected bibliographic record, which in turn updates the display.

xml.component.tsView on Github

We’ve separated out our bib-related functionality to a separate class called BibUtils. In the getBib function we return an Observable of a Bib interface so that we get type-checking and code-completion.

bib-utils.tsView on Github

When the user clicks on the Add Note button, our addNote method calls a helper function in our BibUtils class. The function uses XML features to add the required nodes to our MARCXML.

bib-utils.tsView on Github

Then we update the bib record in Alma using the API and use the refreshPage method of the Events Service to refresh the page in Alma and reflect the change to the bib record.

The CloudAppRestService provides functionality to work with XML. While the default is to work with JSON, you can specify both accept and content-type headers in the Request object. For example, here we set the content-type header to application/xml to indicate that we’re sending an XML representation of the object:

bib-utils.tsView on Github

Now our record has been updated with the field added:

500	__ |a Record processed at 3/5/2025, 5:44:39 AM

Using these tools you should be able to work with XML in bibliographic records.