XML = Dynamic data generated by Alma
What is XML?
How XML is used in Alma Letters
XML contains the dynamic data used to generate letters and notifications. This can be thought of as context-specific, event-driven data.
XML Components
Path
/
), that leads to a specific element in the document.XML Path Example
<user_for_printing>
<active_balance>
<currency></currency>
<normalized_sum></normalized_sum>
<sum></sum>
<vat></vat>
</active_balance>
<address1></address1>
<address2></address2>
<address3></address3>
<address4></address4>
<address5></address5>
<blocks></blocks>
<city></city>
<country></country>
<country_display></country_display>
<email></email>
<first_name></first_name>
<gender></gender>
<identifiers>
<code_value>
<code>Primary Identifier</code>
<value>12345678</value>
</code_value>
</identifiers>
<last_name></last_name>
<middle_name></middle_name>
<name></name>
<phone></phone>
<postal_code></postal_code>
<preferred_first_name></preferred_first_name>
<preferred_last_name></preferred_last_name>
<preferred_middle_name></preferred_middle_name>
<state></state>
<title></title>
<user_group></user_group>
<user_title></user_title>
</user_for_printing>
In this example, <user_for_printing>
is the root element. It contains child elements such as <active_balance>
, <address1>
, and <identifiers>
. The relative path to the <value>
element inside the <identifiers>
element, which contains the user's Primary Identifier, would be /user_for_printing/identifiers/code_value/value
. The full path would be /notification_data/user_for_printing/identifiers/code_value/value
Labels = Static text
@@label_code@@
XSL = Formatting template and logic
XSLT (Extensible Stylesheet Language Transformations) documents transform XML data into an HTML document. Here’s a high-level breakdown of the structure and components of the XSLT in an Alma loan receipt notification:
Includes: The XSLT document begins by including several other XSL files, each defining templates for different parts of the final HTML document. These include header.xsl
, senderReceiver.xsl
, mailReason.xsl
, footer.xsl
, style.xsl
, and recordTitle.xsl
.
Main Template: The main template matches the root of the XML input document (match="/"
) and generates the HTML document’s structure. It includes the HTML, head, and body elements.
Conditional Language Attribute: Inside the HTML element, there’s a conditional statement that checks if a language string exists in the XML input (notification_data/languages/string
). If it does, it sets the lang
attribute of the HTML element to this value.
Head Element: The head element includes a title, which is set to the subject from the XML input (notification_data/general_data/subject
), and calls a template named generalStyle
.
Body Element: The body element includes several called templates (head
, senderReceiver
, toWhomIsConcerned
, lastFooter
) that generate different parts of the HTML body. It also includes a div for the message area, which contains a table for displaying loan information.
Loan Information Table: The table includes a loop (xsl:for-each
) that iterates over each loan in the XML input (notification_data/loans_by_library/library_loans_for_display
) and generates a row in the table for each one.