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: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Aug 2020 15:18:25 -0000
Am 18.08.2020 um 16:09 schrieb Terry Ofner tdofner@xxxxxxxxx:
Is it possible to reference elements in p[@class=bnlb] (to the left of
the ! $groups) in the iterate? Or to pass a parameter including the item
number of the p[@class=bnlb] to the iterate. The selected node of the
iterate is <p=class=bDirectionsb>.


<xsl:template match="set[p[@class = 'nl']]">


B B B <xsl:variable name="groups" as="map(xs:string, element())*">
B B B B B <xsl:for-each-group select="p[@class = 'directions']/*"
group-starting-with="span[@class = 'letter']">
B B B B B B B <xsl:sequence select="map { 'letter' : ., 'term' :
current-group()[2] }"/>
B B B B B </xsl:for-each-group>
B B B </xsl:variable>


B B B <write_choices>
B B B B B <xsl:iterate select="p[@class = 'nl'] ! $groups">

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.

The map functions are in the namespace
http://www.w3.org/2005/xpath-functions/map so you need to declare e.g.
xmlns:map="http://www.w3.org/2005/xpath-functions/map"; in your
stylesheet to use map:merge.

Current Thread