Revindex Storefront

XSL Transform

Last updated on 2020-06-02 6 mins. to read

Every business has its own set of unique business rules, which gives its competitive edge and allows it to comply with regulations. For example, you may have a business rule that gives a $10 discount to repeat customers who purchased over $50 worth of products or your ground shipping method in the United States should never ship to Hawaii.

Revindex Storefront employs powerful XSL 2.0 transform to apply dynamic business rules and calculate the resulting values. XSL (Extensible Stylesheet Language) is the industry standard XML transform language and can be found in different DNN core modules such as the Reports, XML, News Feed module and throughout the Internet. Although not necessary to operate the Revindex Storefront, understanding the basics of XSL will open endless possibility to describe your most complicated business rules needed to run your business.

To learn XSL, you must first understand XML (Extensible Markup Language). XML is very similar to HTML, the language used to describe Web pages. XML is made up of elements contained in open and close right-angle brackets. e.g. <element attribute="Some value">My value</element>

Computer is able to interpret the tags into useful value. XML language has a few simple rules:

  1. XML is case-sensitive.
  2. All elements must be properly closed.
    e.g. <myTag>1.00</myTag> or use the short form <myTag /> if no value is enclosed.
  3. All elements must be properly nested.
    e.g. <a><b>1.00</b></a> is correct. <a><b>1.00</a></b> is wrong.
  4. Comments use the special open and close tags and are ignored by the computer.
    e.g. <!-- this is some comment -->
  5. Reserved characters must be encoded when used as value.
    e.g. <myTag>John &amp; Jane</myTag>
Reserved Characters Encoded Characters
& &amp;
' &apos;
" &quot;

The structure of XSL looks like XML. It uses open and close right-angle brackets and follows the same syntax as XML. In addition, it has built-in special purpose elements and functions that can manipulate XML data. The following example shows a sample XML input with a $75 sales order. The XSL business rule has an “if” condition that prints the $10 discount if the amount is greater than $50.


To write XSL, start with how you expect the XML output to be. In the previous example, you would write the <out> and <discountAmount> open and close tags as you see them. Add to the header and footer the standard <xsl:transform> and <xsl:template> open and close tags respectively. These tags tell the computer that you're writing XSL and match up with start of the XML input data. Finally, add the <xsl:if> condition and check for the $50 amount. Here, the "in/salesOrder/amount" is used to navigate and select the XML input data.

The common XSL special purpose elements for transforming XML data are listed below.

XSL Elements Description
<xsl:variable name="varname" select="expression" /> Hold the value of an expression in a variable that can be referenced later using $varname.
<xsl:value-of select="expression" /> Used to select and print a value from XML input.
<xsl:if test="expression">value</xsl:if> Only print the value if condition succeeds.
  <xsl:when test="expression">value</xsl:when>
  <xsl:when test="expression">value</xsl:when>
  <xsl:when test="expression">value</xsl:when>
Print first value if condition succeeds, otherwise print next value. Unlike the xsl:if instruction, the xsl:choose instruction allows for one or multiple xsl:when test conditions. The result of the first test condition that succeeds will returned. If no test condition succeeds, the last optional xsl:otherwise result is returned.
<xsl:for-each select="expression">value</xsl:for-each> Loop each occurrence of the expression and print the value.


The XSL expressions can contain these operators.

XSL Operators Description Example Result
+ Addition. 1 + 2 3
- Subtraction. 3 - 1 2
* Multiplication. 2 * 6 12
div Division. 6 div 2 3
= Test for equality. amount = 1.00 True if amount is 1.00
False if amount is 1.10
!= Test for not equal. amount != 1.10 True if amount is 1.00
False if amount is 1.10
Less than. amount < 1.10 True if amount is 1.00
False if amount is 1.10
<= Less than or equal. amount <= 1.00 True if amount is 1.00
False if amount is 1.10
Greater than. amount > 1.00 True if amount is 1.10
False if amount is 1.00
>= Greater than or equal. amount >= 1.00 True if amount is 1.00
False if amount is 0.90
or Conditional or. amount = 1.00 or amount = 1.10 True if amount is 1.00
False if amount is 1.20
and Conditional and. amount > 1.00 and amount < 1.10 True if amount is 1.05
False if amount is 0.90


XSL also provides hundreds of functions to manipulate data, such as rounding a decimal number, etc. The common functions are listed below. To see a full list of functions, please see

XSL Functions Description
ceiling(num) Returns the smallest integer number that is greater than the number argument.
floor(num) Returns the largest integer number that is smaller than the number argument.
round(num) Round the number argument to the nearest integer number.
concat(string, string, ..., sep) Returns a string by concatenating with the separator argument.
substring(string, start, length) Returns the sub-string from the start position to the specified length. Index of the first character is 1. If length is omitted it returns the substring from the start position to the end.
string-length(string) Returns the length of the string argument.
upper-case(string) Returns the string in all upper case.
lower-case(string) Returns the string in all lower case.
contains(string1, string1) Returns true if string1 contains string2, otherwise false.
starts-with(string1, string2) Returns true if string1 starts with string2, otherwise false.
ends-with(string1, string2) Returns true if string1 ends with string2, otherwise false.
matches(string, pattern) Returns true if the string argument matches the pattern, otherwise false.
replace(string, pattern, replace) Returns a string that is created by replacing the given pattern with the replace argument.
not(arg) Returns true if the boolean value is false, and false if the boolean value is true.
count((item, item, ...)) Returns the count of nodes.
avg((arg, arg,...)) Returns the average of the argument values.
max((arg, arg,...)) Returns the argument that is greater than the others.
min((arg, arg, ...)) Returns the argument that is less than the others.
sum(arg, arg, ...) Returns the sum of the numeric value of each node in the specified node-set.


To learn more about XML, please see and to learn more about XSL, please see You'll also find more help and example of XSL in the Revindex Forum and Support pages. 


Powered by Revindex Wiki