Please enable JavaScript to view this site.

MyParking Configuration Guide

Navigation: Appendix

Writing your XSL Code

Scroll Prev Top Next More

The Message forwarding templates uses XSL (Xml Stylesheet Language) to transform the data from e.g. a purchase to a readable text.

Note:
This is NOT a complete list of all the XSL syntax. Only some parts used in the templates are described.
 
See Purchase Receipt Template Fields for a list of all available fields.

 

Each xsl:value-of element to select must use the full path to the value to select. In the example below, we are looking for Purchase receipt data. We want to add the Company Name to the receipt. The select parameter lists the path PurchaseReceipt->Compay->Name to retrieve the @value.

select="/PurchaseReceipt/Company/Name/@Value"

If a value can be empty, you can use an “xsl:if” statement to prevent an empty line one the receipt. The following example will look for the value of the VatRegNo (Value added Tax Registration number). If the value is not empty, the next 2 lines will print. The last line will close the if statement.

<xsl:if test="/PurchaseReceipt/Terminal/TerminalID/@Value != ''">
<xsl:value-of select="/PurchaseReceipt/Terminal/TerminalID/@Value" />
<xsl:text>&#10;</xsl:text>
</xsl:if>

To add text to a receipt that always will be printed, use the text element. The example below prints a line feed to move to the next line to print. This line must be added to prevent all the values to be printed on one line.

<xsl:text>&#10;</xsl:text>

To print the name or label of a value use @Key. The example below first prints “Purchase State”, than a colon and then the value. The line is closed with a line feed.

<xsl:value-of select="/PurchaseReceipt/Purchase/PurchaseStateName/@Key" />
<xsl:text>: </xsl:text>
<xsl:value-of select="/PurchaseReceipt/Purchase/PurchaseStateName/@Value" />
<xsl:text>&#10;</xsl:text>

Result:
Purchase State: Completed.

The complete example below is the default SMS template that will be used if no other template for the company is available.

The Table below lists all the possible keys and value to use. Most fields are not explained as they explain the content with their name.

 

Example for the SMS template

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text" />
  <xsl:template match="/">
    <xsl:value-of select="/PurchaseReceipt/Company/Name/@Value" />
    <xsl:text>&#10;</xsl:text><!-- LINE FEED -->
    <xsl:if test="/PurchaseReceipt/Company/VatRegNo/@Value != ''">
        <xsl:value-of select="/PurchaseReceipt/Company/VatRegNo/@Value" />
        <xsl:text>&#10;</xsl:text>
    </xsl:if>
    <xsl:value-of select="/PurchaseReceipt/Purchase/PurchaseDateLocal/@Value" />
    <xsl:text>&#10;</xsl:text>
    <xsl:if test="/PurchaseReceipt/Terminal/TerminalID/@Value != ''">
        <xsl:value-of select="/PurchaseReceipt/Terminal/TerminalID/@Value" />
        <xsl:text>&#10;</xsl:text>
    </xsl:if>
    <xsl:value-of select="/PurchaseReceipt/Purchase/PurchaseStateName/@Key" />
    <xsl:text>: </xsl:text>
    <xsl:value-of select="/PurchaseReceipt/Purchase/PurchaseStateName/@Value" />
    <xsl:text>&#10;</xsl:text>
    <xsl:value-of select="/PurchaseReceipt/Purchase/Amount/@Key" />
    <xsl:text>: </xsl:text>
    <xsl:value-of select="/PurchaseReceipt/Purchase/Amount/@Value" />
    <xsl:text>&#10;</xsl:text>
    <xsl:if test="/PurchaseReceipt/Purchase/VatAmount/@Value != ''">
        <xsl:value-of select="/PurchaseReceipt/Purchase/VatAmount/@Key" />
        <xsl:text>: </xsl:text>
        <xsl:value-of select="/PurchaseReceipt/Purchase/VatAmount/@Value" />
        <xsl:text>&#10;</xsl:text>
    </xsl:if>
    <xsl:value-of select="/PurchaseReceipt/Purchase/EndDateLocal/@Key" />
    <xsl:text>: </xsl:text>
    <xsl:value-of select="/PurchaseReceipt/Purchase/EndDateLocal/@Value" />
    <xsl:text>&#10;</xsl:text>
    <xsl:if test="/PurchaseReceipt/Purchase/Code/@Value != ''">
        <xsl:value-of select="/PurchaseReceipt/Purchase/Code/@Value" />
        <xsl:text>&#10;</xsl:text>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>

 

Resulting SMS text

The first row “Receipt from …” is the subject of the message. The next part is the formatted text from the template above.

Receipt from Flowbird Sweden

 

Flowbird Sweden
9/9/2016 10:45:00 AM
Demo
Purchase State: Completed
Amount incl. Vat and Fees: 24.00
Vat Amount: 4.80
End Date Local: 9/9/2016 11:19:55 AM
NKC808