I’m attempting to build some XML elements based on an XSLT string parameter. The idea is quite simple.
The user specifies a parameter, which is a comma-separated list of names. For each name, I want to write the following to the XML file:
<category>{$string}</category>
Where {$string} is one of the comma-separated values. So if the user provides this parameter: category1, category2, cat3, then I should get this in the XML file:
<category>category1</category>
<category>category2</category>
<category>cat3</category>
It should also be possible to provide an empty string, in which case no XML element is printed.
Note that I am using XSLT 2.0, so feel free to include 2.0-based XPath and XSLT constructs.
This transformation (XSLT 2.0):
when applied on any XML document (not used), produces the wanted, correct result: