Dear xsl-list,
Thanks to everyone for the quick responses, and especially to Norm for
sharing the template that I should have written in the first place.
Best,
David
On Thu, Mar 3, 2022 at 11:23 AM Norm Tovey-Walsh ndw@xxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > I would be grateful for any insights.
>
> This seems to work, YMMV.
>
> <xsl:template match="p">
> <p>
> <xsl:for-each-group select="node()"
> group-adjacent="self::q or
> self::text()[normalize-space(.)='']">
> <xsl:choose>
> <xsl:when test="current-grouping-key()">
> <q>
> <xsl:for-each select="current-group()">
> <xsl:if test="position() gt 1">
> <xsl:text> </xsl:text>
> </xsl:if>
> <xsl:sequence select="node()"/>
> </xsl:for-each>
> </q>
> </xsl:when>
> <xsl:otherwise>
> <xsl:sequence select="current-group()"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:for-each-group>
> </p>
> </xsl:template>
>
> Be seeing you,
> norm
>
> --
> Norman Tovey-Walsh <ndw@xxxxxxxxxx>
> https://nwalsh.com/
>
> > We are at the very beginning of time for the human race. It is not
> > unreasonable that we grapple with problems. But there are tens of
> > thousands of years in the future. Our responsibility is to do what we
> > can, learn what we can, improve the solutions, and pass them
> > on.--Richard Feynman
|