
I take the liberty of exposing my ignorance of how to use the cool grouping features of xslt on the list, in the hope that someone will take pity on me and explain what's going on here. My input file (in the HTML namespace) contains chunks like this: <div class="wpvw-motto"><span class="cursief">Waarde Meryan!</span> <br/> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. <br/> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <span class="cursief">zeer</span> plotseling gestorven.... gij begrijpt mij wel! <br/> </div> which I want to transform (obviously) to something like this <quote><hi rend="italic">Waarde Meryan!</hi> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <hi rend="italic">zeer</hi> plotseling gestorven.... gij begrijpt mij wel! </p> </quote> My stylesheet has a template for div[@class] which contains the following: |||<xsl:when test="@class = 'wpvw-motto'">| |<quote>| |<xsl:for-each-group select="node()" group-ending-with="h:br">| |<xsl:for-each select="current-group()">| |<p>| |<xsl:choose>| |<xsl:when test="self::h:br"/>| |<xsl:when test="self::h:span">| |<xsl:apply-templates select="."/>| |</xsl:when>| |<xsl:otherwise>| |<xsl:apply-templates select="."/>| |</xsl:otherwise>| |</xsl:choose>| |</p>| |</xsl:for-each>| |</xsl:for-each-group>| |</quote>| |</xsl:when>| and another for span which handles the conversion to <hi> ... and this NEARLY works. But not quite. It generates |<quote><p>|| ||<hi rend="italic">Waarde Meryan!</hi> </p>|| ||<p>|| ||‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait.|| ||</p>>|| ||<p>|| ||‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, </p>|| ||<p><hi rend="italic">zeer</hi></p>|| ||<p>||plotseling gestorven.... gij begrijpt mij wel! || ||</p>|| ||</quote>| i.e. it looks as if the current-group starts a new sequence for each h:div child, rather than for each <br/>. So I am misunderstanding something fairly fundamental about how this grouping mechanism works. Any and all advice gratefully received! Lou

Hi Lou, I think you’ll need to move the <p> (which you want to create) outside the inner loop (<xsl:for-each select="current-group()“>). Then it will create a <p> for every group, not for every child of a group. Best Peter
Am 06.03.2018 um 15:20 schrieb Lou Burnard <lou.burnard@retired.ox.ac.uk>:
I take the liberty of exposing my ignorance of how to use the cool grouping features of xslt on the list, in the hope that someone will take pity on me and explain what's going on here.
My input file (in the HTML namespace) contains chunks like this:
<div class="wpvw-motto"><span class="cursief">Waarde Meryan!</span> <br/> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. <br/> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <span class="cursief">zeer</span> plotseling gestorven.... gij begrijpt mij wel! <br/> </div>
which I want to transform (obviously) to something like this
<quote><hi rend="italic">Waarde Meryan!</hi> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <hi rend="italic">zeer</hi> plotseling gestorven.... gij begrijpt mij wel! </p> </quote>
My stylesheet has a template for div[@class] which contains the following:
<xsl:when test="@class = 'wpvw-motto'"> <quote> <xsl:for-each-group select="node()" group-ending-with="h:br"> <xsl:for-each select="current-group()"> <p> <xsl:choose> <xsl:when test="self::h:br"/> <xsl:when test="self::h:span"> <xsl:apply-templates select="."/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."/> </xsl:otherwise> </xsl:choose> </p> </xsl:for-each> </xsl:for-each-group> </quote> </xsl:when>
and another for span which handles the conversion to <hi>
... and this NEARLY works. But not quite. It generates
<quote><p> <hi rend="italic">Waarde Meryan!</hi> </p> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p>> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, </p> <p><hi rend="italic">zeer</hi></p> <p> plotseling gestorven.... gij begrijpt mij wel! </p> </quote>
i.e. it looks as if the current-group starts a new sequence for each h:div child, rather than for each <br/>. So I am misunderstanding something fairly fundamental about how this grouping mechanism works.
Any and all advice gratefully received!
Lou
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user
-- Peter Stadler Carl-Maria-von-Weber-Gesamtausgabe Arbeitsstelle Detmold Hornsche Str. 39 D-32756 Detmold Tel. +49 5231 975-676 Fax: +49 5231 975-668 stadler at weber-gesamtausgabe.de www.weber-gesamtausgabe.de

Ha! Thanks Peter! It's totally obvious when a fresh pair of eyes looks at it! I'll go back to banging the rocks together now ... Lou On 06/03/18 14:36, Peter Stadler wrote:
Hi Lou,
I think you’ll need to move the <p> (which you want to create) outside the inner loop (<xsl:for-each select="current-group()“>). Then it will create a <p> for every group, not for every child of a group.
Best Peter
Am 06.03.2018 um 15:20 schrieb Lou Burnard <lou.burnard@retired.ox.ac.uk>:
I take the liberty of exposing my ignorance of how to use the cool grouping features of xslt on the list, in the hope that someone will take pity on me and explain what's going on here.
My input file (in the HTML namespace) contains chunks like this:
<div class="wpvw-motto"><span class="cursief">Waarde Meryan!</span> <br/> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. <br/> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <span class="cursief">zeer</span> plotseling gestorven.... gij begrijpt mij wel! <br/> </div>
which I want to transform (obviously) to something like this
<quote><hi rend="italic">Waarde Meryan!</hi> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <hi rend="italic">zeer</hi> plotseling gestorven.... gij begrijpt mij wel! </p> </quote>
My stylesheet has a template for div[@class] which contains the following:
<xsl:when test="@class = 'wpvw-motto'"> <quote> <xsl:for-each-group select="node()" group-ending-with="h:br"> <xsl:for-each select="current-group()"> <p> <xsl:choose> <xsl:when test="self::h:br"/> <xsl:when test="self::h:span"> <xsl:apply-templates select="."/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."/> </xsl:otherwise> </xsl:choose> </p> </xsl:for-each> </xsl:for-each-group> </quote> </xsl:when>
and another for span which handles the conversion to <hi>
... and this NEARLY works. But not quite. It generates
<quote><p> <hi rend="italic">Waarde Meryan!</hi> </p> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p>> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, </p> <p><hi rend="italic">zeer</hi></p> <p> plotseling gestorven.... gij begrijpt mij wel! </p> </quote>
i.e. it looks as if the current-group starts a new sequence for each h:div child, rather than for each <br/>. So I am misunderstanding something fairly fundamental about how this grouping mechanism works.
Any and all advice gratefully received!
Lou
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user -- Peter Stadler Carl-Maria-von-Weber-Gesamtausgabe Arbeitsstelle Detmold Hornsche Str. 39 D-32756 Detmold Tel. +49 5231 975-676 Fax: +49 5231 975-668 stadler at weber-gesamtausgabe.de www.weber-gesamtausgabe.de

Lou, Below is how I would approach it. I take into account that you want to treat the opening span specially. Best wishes, jk -- Joel Kalvesmaki Managing Editor in Byzantine Studies Dumbarton Oaks 202 339 6435 <xsl:template match="div[@class = 'wpvw-motto']"> <xsl:variable name="opener" select="span[not(preceding-sibling::node())]" as="element()?"/> <quote> <xsl:apply-templates select="$opener"/> <xsl:for-each-group select="node() except $opener" group-ending-with="br"> <p> <xsl:apply-templates select="current-group()"/> </p> </xsl:for-each-group> </quote> </xsl:template> <xsl:template match="*[@class = 'cursief']"> <hi rend="italic"> <xsl:value-of select="."/> </hi> </xsl:template> <xsl:template match="br"/> From: oXygen-user <oxygen-user-bounces@oxygenxml.com> on behalf of Lou Burnard <lou.burnard@retired.ox.ac.uk> Date: Tuesday, March 6, 2018 at 9:21 AM To: "oxygen-user@oxygenxml.com" <oxygen-user@oxygenxml.com> Subject: [oXygen-user] xslt puzzle I take the liberty of exposing my ignorance of how to use the cool grouping features of xslt on the list, in the hope that someone will take pity on me and explain what's going on here. My input file (in the HTML namespace) contains chunks like this: <div class="wpvw-motto"><span class="cursief">Waarde Meryan!</span> <br/> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. <br/> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <span class="cursief">zeer</span> plotseling gestorven.... gij begrijpt mij wel! <br/> </div> which I want to transform (obviously) to something like this <quote><hi rend="italic">Waarde Meryan!</hi> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, <hi rend="italic">zeer</hi> plotseling gestorven.... gij begrijpt mij wel! </p> </quote> My stylesheet has a template for div[@class] which contains the following: <xsl:when test="@class = 'wpvw-motto'"> <quote> <xsl:for-each-group select="node()" group-ending-with="h:br"> <xsl:for-each select="current-group()"> <p> <xsl:choose> <xsl:when test="self::h:br"/> <xsl:when test="self::h:span"> <xsl:apply-templates select="."/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."/> </xsl:otherwise> </xsl:choose> </p> </xsl:for-each> </xsl:for-each-group> </quote> </xsl:when> and another for span which handles the conversion to <hi> ... and this NEARLY works. But not quite. It generates <quote><p> <hi rend="italic">Waarde Meryan!</hi> </p> <p> ‘In aanmerking genomen onze gewoonlijk niet heel drukke (!) correspondentie, ... Dus, vous voilà prévenu, le pire est fait. </p>> <p> ‘Weet dan ... voet voortleven en ten slotte totaal geruïneerd! Hij, </p> <p><hi rend="italic">zeer</hi></p> <p> plotseling gestorven.... gij begrijpt mij wel! </p> </quote> i.e. it looks as if the current-group starts a new sequence for each h:div child, rather than for each <br/>. So I am misunderstanding something fairly fundamental about how this grouping mechanism works. Any and all advice gratefully received! Lou Disclaimer The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful. This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business, providing a safer and more useful place for your human generated data. Mimecast specializes in security, archiving and compliance. To find out more visit the Mimecast website.
participants (3)
-
Kalvesmaki, Joel
-
Lou Burnard
-
Peter Stadler