DIGIFORMS
Digiforms Designer Documentation
Search
About
+
Getting started
+
Howto
Help by samples
+
Objects
+
Page template
Capture or output data in a defined layout
+
XML
Extensible Markup Language
Howto
Alternating style of objects based on values in xml
Switch-case any set of objects to create visual effects or user interface variations.
Alternating objects or style with xsl:choose
In XSLT, the xsl:choose element allows building simple or complex switch-cases (alternations). Any object can be switch-cased to set up style matching almost any situation. The concept is straight-forward:
Duplicate/copy the object in question as many times as desired number of style variants
Mark the original and duplicated objects, right-click and select "choose"
Set up the desired test expression in xsl:when instance(s)
Apply the desired style to object(s) within xsl:when or xsl:otherwise instances
Example
Alternating table row style based on unit price
This example is based on the Giro template bundled with Digiforms Designer. The Giro template contains a table that outputs a row for each matching products/product element in XML.
Let's say we would like the row style to alternate, based on the unit price. We simply follow the steps as explained above.
Right-click first cell of row inside xsl:for-each (R), and select "Table -> Add row below" ( duplicates selected row )
Select first column of the two rows within xsl:for-each (shift + click)
Right click one of the selected table cells, and select "Choose"
Designer will now have created an xsl:choose, containing xsl:when for first row, and xsl:otherwise for the second.
Related articles
xsl:choose
xsl:when
Edit article