To retrieve the position of an element that is between specific other elements, you can use the "count" and "preceding-sibling" functions in XSLT.
For example, if you want to retrieve the position of an "item" element that is between two "category" elements, you can use the following XSLT expression:
count(preceding-sibling::category) + 1
This expression counts the number of "category" elements that come before the current "item" element, and then adds 1 to the count to get the position of the current "item" element.
Assuming you have the following XML structure:
<root>
<category>Category 1</category>
<item>Item 1.1</item>
<item>Item 1.2</item>
<category>Category 2</category>
<item>Item 2.1</item>
<item>Item 2.2</item>
<item>Item 2.3</item>
</root>
If you apply the above XSLT expression to each "item" element, you will get the following positions:
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-04 20:10:43 +0000
Seen: 8 times
Last updated: May 04 '23
How can the approval status of a SharePoint List item be updated using Power Automate?
How can I use flexbox to achieve an even amount of empty space at either end?
How can the last item be displayed fully while only half of the right item is shown in slick slider?
What does it mean to select an item on the display by clicking it?
What is the process for removing an item from the Laravel session?
How to obtain a Null value in combo boxes?
What is the process for selecting items in a list that appear only once?
How can I send an array of objects to a controller in ASP.NET 6 (Core)?