I have a nested list, and therefore I want the label to be nested too.
This is my code:
<!-- For first list -->
<xsl:template name="list1-label">
<xsl:number format="1."/>
</xsl:template>
<!-- The nestled list -->
<xsl:template name="list2-label">
<xsl:number format="1.1."/>
</xsl:template>
The first number in the last template (1.1.) I want to be relative to the parent item, in this case; “3”.
Here is the xml structure:
<list1>
<item>Test</item>
<item>Test</item>
<list2>
<item>Test</item>
<item>Test</item>
</list2>
<item>Test</item>
</list1>
Here is the output:
1. Test
2. Test
2.1. Test
2.2. Test
3. Test
The wanted output can be obtained (for example) applying the advanced attributes @from and @count of
xsl:number. Here a working example from which you should get started:If you want to simplify the match patterns:
This latest example will correctly drive you to further nesting levels as with a list3.