Re: [xsl] Using xsl:iterate inside <xsl:for-each-group> xslt 3.0

Subject: Re: [xsl] Using xsl:iterate inside <xsl:for-each-group> xslt 3.0
From: "Terry Ofner tdofner@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Aug 2020 16:14:00 -0000
Interesting tangle I am in. I tried the map:merge in both the iterate and
apply-templates solutions. I can indeed reference the bpb and pull it into
the output. However, it seems to play havoc with the $groups output. Here is
the changed iterate:

                     <xsl:iterate select="p[@class = 'nl'] !
map:merge(($groups, map
                        { 'p' : . }))">
                        <xsl:text>&#10;</xsl:text>
                        <write_choice  num="{position() - 1}"
letter="{?letter}"
                            term="{?term}" item="{?p}"/>
                        </xsl:iterate>

Output:

<write_choice num="0" letter="S" term="sentence" item="&#x9;1.&#x9;Sent the
package to her yesterday."/>
<write_choice num="1" letter="S" term="sentence" item="&#x9;2.&#x9;A history
teacher at the middle school."/>
<write_choice num="2" letter="S" term="sentence" item="&#x9;3.&#x9;Roberto
works on Saturday afternoons."/>
<write_choice num="3" letter="S" term="sentence" item="&#x9;4.&#x9;Skied down
a mountain for the first time."/>
<write_choice num="4" letter="S" term="sentence" item="&#x9;5.&#x9;Since are
going out for dinner."/>
<write_choice num="5" letter="S" term="sentence" item="&#x9;6.&#x9;George does
twenty push-ups each morning.b/>


I was naive to think that it would read my mind and output something like
this:

<write_choice num="0" letter="S" term="sentence" item="&#x9;1.&#x9;Sent the
package to her yesterday."/>
<write_choice num="1" letter="S" term="sentence" item="&#x9;1.&#x9;Sent the
package to her yesterday."/>
<write_choice num="2" letter="S" term="sentence" item="&#x9;2.&#x9;A history
teacher at the middle school."/>
<write_choice num="3" letter="S" term="sentence" item="&#x9;2.&#x9;A history
teacher at the middle school."/>

Maybe I need to do something different with the ?p call?



> If you need the item on the left side of ! then include it in a merged
> group, for instance
>
>       <xsl:iterate select="p[@class = 'nl'] ! map:merge(($groups, map
> { 'p' : . }))">
>
> then the expression ?p inside the iterate selects the property named "p"
> of the map which holds the "p" element.

Current Thread