If statements in XPath 1.0
For a reflection field that I’m using in a Symphony CMS project, I needed to create an XPath conditional expression. XPath 2.0 supports if statements, but I couldn’t use those because PHP-XSL only support XPath 1.0. After searching on the internet I finally came up with this solution:
substring('repeat', 1, number(factuur/herhaling = 'Yes') * string-length('repeat'))
This statement will return “repeat” when factuur/herhaling is checked in the CMS. Not the most readable solution, but it does work!