Subject: Re: [xsl] Feedback on grouping solution|
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 26 Oct 2019 17:38:08 -0000
I need to process the <step> child elements so that the <figure> elements are always on the "right" (even-numbered position) in the output. Immediate children of the <procedure> do not factor into the odd/even sequence.
The first child of each group of adjacent <step> elements starts a new odd/even series. To ensure that the each <figure> is in an even-numbered position, I want to insert a <spacer> element where it is required.
Here is my stylesheet. My basic question is: is there a better or more efficient way to do this? I really want to master grouping because it comes up in a lot of my tasks. Thank you for any input or criticism.
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<!-- Group the children of the procedure, keeping adjacent steps together. -->
<xsl:for-each-group select="child::*" group-adjacent="local-name(.)">
<!-- Single element. -->
I don't understand this part, what is supposed to happen with two (or more) adjacent <note/><note/> or other non step elements? Do you want to drop any but the first of them?