xsl-list
[Top] [All Lists]

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

2020-08-18 10:18:31
Am 18.08.2020 um 16:09 schrieb Terry Ofner tdofner(_at_)gmail(_dot_)com:
Is it possible to reference elements in p[@class=‘nl’] (to the left of
the ! $groups) in the iterate? Or to pass a parameter including the item
number of the p[@class=’nl’] to the iterate. The selected node of the
iterate is <p=class=‘Directions’>.


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


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


   <write_choices>
     <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.

--~----------------------------------------------------------------
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>