[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: Using xsl:iterate inside <xsl:for-each-group> xslt 3.0
From: "Terry Ofner tdofner@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Aug 2020 19:54:38 -0000
Re:  Using xsl:iterate inside <xsl:for-each-group> xslt
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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.