[oXygen-user] xslt puzzle

Lou Burnard lou.burnard at retired.ox.ac.uk
Tue Mar 6 08:40:19 CST 2018


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



More information about the oXygen-user mailing list