It is better if you structure your XML like this (omitted unused fields for brevity):
Link #2
2
Link #1
1
Link #3
3
Your XSLT then becomes:
I've also modified the data-toggle
(I assume it's Bootstrap) to name the class it should toggle (collapse
as an example), and the data-target
to use generate-id()
, which you should use when generating the content to be acted upon.
The XML resulting from the above is this:
If you need to set attributes on the first element in the xsl:for-each, you can use this in the XSLT:
-
setCurrent