Thanks, Martin,
Your response got me thinking. My selection of groups is not specific enough.
I stepped back to <xsl:for-each> (in place of <xsl:iterate>) to see if I can
identify the proper level of select. Here is a set of clumsy for-each steps
that get closer to what I am looking for. Not a final solution, but closer.
<write_choices>
<xsl:for-each-group select="$myDir/p"
group-starting-with="span[@class='writeLetter']b>
<!--a variable to keep track of the number of spans to select; could
iterate this number?-->
<xsl:variable name="groupNum" select="1b/>
<xsl:for-each
select="current-group()/span[@class='writeLetter'][$groupNum]">
<xsl:variable name="startNum"
select="$myitemNum"/>
<write_choice>
<xsl:attribute name="writeNum">
<xsl:value-of
select="$startNum"/>
</xsl:attribute>
<xsl:attribute name="letter">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:attribute name="term">
<xsl:value-of
select="following::span[1]"/>
</xsl:attribute>
</write_choice>
</xsl:for-each>
<xsl:for-each
select="current-group()/span[@class='writeLetter'][$groupNum + 1]">
<xsl:variable name="startNum"
select="$myitemNum"/>
<write_choice>
<xsl:attribute name="writeNum">
<xsl:value-of
select="$startNum + 1"/>
</xsl:attribute>
<xsl:attribute name="letter">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:attribute name="term">
<xsl:value-of
select="following::span[1]"/>
</xsl:attribute>
</write_choice>
</xsl:for-each>
</xsl:for-each-group>
</write_choices>
Output:
<write_choices>
<write_choice writeNum="0" letter="S" term="sentence"/>
<write_choice writeNum="1" letter="F" term="fragment"/>
</write_choices>
b&
<write_choices>
<write_choice writeNum="1" letter="S" term="sentence"/>
<write_choice writeNum="2" letter="F" term="fragment"/>
</write_choices>
Perhaps I need nested <xsl:iterate> statements, one for the groupNum in the
for-each select and one for the $startNum variable.
> On Aug 13, 2020, at 1:26 PM, Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> On 13.08.2020 19:15, Terry Ofner tdofner@xxxxxxxxx wrote:
>
>> Here then is the same section with the <xsl:iterate> added:
>>
>> <write_choices>
>> <xsl:for-each-group select="$myDir/p/*"
group-starting-with="span[@class='letter']">
>>
>> <xsl:iterate select=".">
>
> Inside of any `for-each-group`, the context item `.` is the first item
> of `current-group()` so using a single item in the select expression of
> `iterate` is likely not what you want.
>
>
>
> I haven't grasped what you need instead.
|