Skip to Main Content
the logo for the Library Services Platform: California Community Colleges

Systems Work Group

LSP Systems Work Group Main LibGuide- information on events, documentation, and resources

Customization Basics

Customizations to Alma letters are generally made in the XSLT or to the labels for the specific notification, or in one of the component files. Specifically customizations may be made to the:

  • Included XSL Files: If you want to customize the header, sender/receiver information, mail reason, footer, or style you would do so in the respective included XSL files (header.xslsenderReceiver.xsl, etc.).

  • Main Template: If you want to customize the overall structure of the HTML document or the way the loan information is displayed, you would do so in the main template within this XSLT document.

  • Called Templates: If you want to customize the styles or the content of the different parts of the HTML body, you would do so in the templates that are called within the body element (headsenderReceivertoWhomIsConcernedlastFooter).

  • Labels: The text in labels can be easily modified or togged on/off to quickly customize the language in a notification. 

Conditional Statements

Conditional Statements

In XSL, conditionals are used to control the flow of the transformation process based on certain conditions. The <xsl:if> element is used to specify a conditional test against the content of the XML.

Here’s how it works:

  1. Construction: The <xsl:if> element is constructed with a test attribute, which contains an XPath expression. If the expression evaluates to true, the content inside the <xsl:if> element is processed.
<xsl:if test="expression">
  <!-- Content to process if the expression is true -->
</xsl:if>
  1. Interaction with XML data: The XPath expression in the test attribute is evaluated against the XML data. It can be an absolute path from the root, or a relative path from the current node.

Example:

<xsl:if test="/notification_data/item_loans/item_loan/material_type ='LPTOP'"> 
  <xsl:message terminate="yes"></xsl:message>
</xsl:if>

The XPath expression /notification_data/item_loans/item_loan/material_type ='LPTOP' checks if there’s an item_loan with material_type equal to 'LPTOP' in the XML data. If such an item_loan exists, the <xsl:message terminate="yes"></xsl:message> is processed, which terminates the message.

  • Multiple Conditionals: You can have multiple <xsl:if> elements to check for different conditions. For example, different material_type values could be checked in separate <xsl:if> elements. Each <xsl:if> is independent, and all will be evaluated.

Remember, <xsl:if> only supports a single condition. If you need to test multiple mutually exclusive conditions, consider using <xsl:choose>, <xsl:when>, and <xsl:otherwise> elements.

Conditional Examples

In XSLT, conditional statements are primarily handled using xsl:if and xsl:choose constructs. Here are examples of each:

  1. xsl:if - This is used when you want to apply a single condition.
<xsl:if test="expression">
  <!-- Content to render if the expression is true -->
</xsl:if>
  1. xsl:choose - This is used when you want to apply multiple conditions. It’s similar to if-else in other programming languages.
<xsl:choose>
  <xsl:when test="expression1">
    <!-- Content to render if expression1 is true -->
  </xsl:when>
  <xsl:when test="expression2">
    <!-- Content to render if expression2 is true -->
  </xsl:when>
  <xsl:otherwise>
    <!-- Content to render if none of the above expressions are true -->
  </xsl:otherwise>
</xsl:choose>

Using ‘and’ or ‘or’ in Conditional Statements

You can use ‘and’ or ‘or’ operators to test multiple conditions within the same conditional statement. This is particularly useful when you want to apply a condition based on multiple criteria. 

<xsl:choose>
  <xsl:when test="condition1 and (condition2 or condition3)">
    <!-- Content to render if condition1 is true and either condition2 or condition3 is true -->
  </xsl:when>
  <xsl:otherwise>
    <!-- Content to render if none of the above conditions are true -->
  </xsl:otherwise>
</xsl:choose>

Here the ‘and’ operator is used to ensure both conditions on either side of it are true. The ‘or’ operator is used within the parentheses to check if any of the conditions separated by ‘or’ are true. If condition1 is true and either condition2 or condition3 is true, the content within the <xsl:when> tag will be rendered. If not, the content within the <xsl:otherwise> tag will be rendered. 

Crafting a Conditional Statement

  1. Determine a desired outcome
    • ex: "I don't want to send courtesy notices to Staff users"
  2. Find an XML element that you want to test for
    • User Group elements would allow you to test for whether a recipient is has a staff account type
  3. Find the PATH to the element
    • /notification_data/receivers/receiver/user/user_group
  4.  Construct a conditional to test whether the user_group element equals "STAFF" and terminate the message if the condition is True.
    <xsl:if test="/notification_data/receivers/receiver/user/user_group='STAFF'">
    
    <xsl:message terminate="yes"></xsl:message>
    
    </xsl:if>
    
  5. Since we are simply terminating the message we can place the conditional anywhere in the message head or body. Paste in the conditional. Test test test.

HTML Cheat Sheet

  • <html>: This is the root element of an HTML page.
  • <head>: This element contains meta-information about the HTML document.
  • <title>: This tag defines the title of the HTML document. It is displayed in the browser’s title bar or tab.
  • <body>: This tag defines the document’s body. It contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc.
  • <div>: This is a container tag that is used to group HTML block-elements to format them with styles.
  • <table>: This tag defines an HTML table.
  • <tr>: This tag defines a row in an HTML table.
  • <td>: This tag defines a cell in an HTML table.
  • <strong>: This tag is used to define important text.
  • <th>: This tag defines a header cell in an HTML table.
  • <hr>: This tag represents a thematic break between paragraph-level elements.
  • <br>: This tag inserts a single line break.
  • <p>: This tag defines a paragraph. For example, <p>This is a paragraph.</p>.

  • <h1> to <h6>: These tags are used to define HTML headings, <h1> being the largest and <h6> the smallest. For example, <h1>This is a heading</h1>.

  • <a>: This tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link’s destination. For example, <a href="https://www.example.com">This is a link</a>.

  • <!-- -->: This tag is used to insert comments in the source code. Comments are not displayed in the browsers. You can use them to document your code. For example, <!-- This is a comment -->.

  • <img>: This tag is used to embed an image in an HTML page. The src attribute holds the image location. For example, <img src="image.jpg" alt="My Image">.

  • <ul> and <li>: The <ul> tag defines an unordered (bulleted) list, and the <li> tag defines each list item. For example:

    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
    </ul>
  • <ol>: Similar to <ul>, but <ol> defines an ordered (numbered) list.

  • <span>: This tag is used for grouping and applying styles to inline elements. For example, <span style="color:blue">This is a blue text.</span>.

  • <style>: This tag is used to define style information (CSS) for a document. For example:

    <style>
      body {background-color: powderblue;}
      h1   {color: blue;}
      p    {color: red;}
    </style>

HTML Modification Basics

  • Well-formed: Ensure that the HTML follows the basic syntax rules of HTML. For example, every opening tag has a corresponding closing tag, like <p> is closed with </p>.
  • Valid: This means the HTML adheres to the HTML specification. For instance, <li> elements are always nested within a <ul> or <ol>.