==== Using Evergreen APIs for client-side bibliographic data rendering ==== === or Replacing result_detail.xml === The following is a rough example of one mechanism available in Evergreen for displaying bibliographic data outside of the stock OPAC code. This is only a test First, load Dojo, which is included in Evergreen 1.4.0 and beyond. Now we lay out some template slots that the bib data will be plugged into. This requires some extra explanation, I think. First, we need to mark the containing element ('' Here we see that by selecting nodes in the middle of the DOM tree ('''' sits between '''' and '''' in ''marcxml'') we can process groups of values together, allowing richer rendering and interpretation of entire sections of information instead of simple, discrete data.
title
'' here) in some way so that we can find it. We do this by giving it a non-standard ''type'' attribute with a value of ''opac/slot-data-marcxml''. This attribute is used in two ways. First, ''opac/slot-data'' says that this element will be used as a place to deposit data needed for constructing this "opac". Second, ''+marcxml'' tells the query processor that it should use the ''marcxml'' form of the bibliographic record. Other formats would include ''marcxml-full'' (which includes holdings information), ''mods'', ''oai_dc'' and other formats supported by the Evergreen unAPI service. Next we need to tell the query processor what to extract from the XML returned by the unapi service. We add a ''query'' attribute to the container element and set its value to the [[http://www.dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/selecting-dom-nodes-dojo-query|dojo.query()]] we need to find the relevant data in the format selected by the ''type'' attribute. Finally, we may need to format the data in some special way. We do this by providing a chunk of Javascript that knows how to take the output of the ''dojo.query()'' call, one node at a time, and do something special with it. Each node is run through this code, and the return values for all nodes passing through this code are joined with a space and used to replace the HTML content of the containing element. Two things to note about this ''
items
And, finally, here's one way for dealing with the holidngs info appended to the bib by adding -full to the end of the format specifier. This function takes the datatype and record id and makes an XHR request to the Evergreen unAPI service to retrieve the record in the required format. When the record arrives, it loops over each data slot using this datatype and looks for one or more script elements with a ''type'' attribute of ''opac/slot-format''. If found, it takes the text content of these and concatenates these and uses that as the body of a processing function to which each node found by passing the ''query'' attribute a ''dojo.query()'' call. If no specialized ''