Haven’t found this anywhere so I ask it here.
I have a xml document structured as follows:
<root>
<row>Row 1</row>
<row>Row 2</row>
<row>Row 3</row>
<row>Row 4</row>
<row>Row 5</row>
<row>Row 6</row>
<row>Row 7</row>
<row>Row 8</row>
<row>Row 9</row>
<row>Row 10</row>
</root>
In a xsl document,I want to display the rows in a range.For example,I want to display only the rows from Row 3
to Row 8
,excluding the first and last 2 rows.
I know how to set the limit of the rows but that displays rows starting from Row 1
(the very first).
Edit:typos
2
Answers
You can use a predicate based on position:
This could be in an
xsl:apply-templates
or in axsl:for-each
or even in axsl:copy-of
instruction (all from the context ofroot
). You didn’t post your attempt or the expected result, so we can only guess.To display a specific range of rows in your XML using XSLT, you can utilize the
position()
function along with conditional statements. Here’s an example XSLT that displays rows from Row 3 to Row 8:The Output: