xsl-list
[Top] [All Lists]

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

2020-08-18 11:14:09
Interesting tangle I am in. I tried the map:merge in both the iterate and 
apply-templates solutions. I can indeed reference the ‘p’ 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.”/>


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.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>