Re: [xsl] grouping xhtml title with first sibling

Subject: Re: [xsl] grouping xhtml title with first sibling
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 18 Jan 2011 14:34:09 +0000
OK, sorry. Because of the way the mailer destroys indentation, I misread your question and assumed you were asking the commonly asked question about how to create hierarchic sections.

I think you can do this with

<xsl:function name="f:is-heading" as="xs:boolean">
<xsl:param name="e" as="element()"/>
<xsl:sequence select="matches(local-name($e), 'h[1-9]')"/>
</xsl:function>

<xsl:template match="body">
<xsl:apply-templates select="* except (*[f:is-heading(.)]/following-sibling::*[1])"/>
</xsl:template>


<xsl:template match="body/*">
<xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="body/*/is-heading(.)" priority="10">
<div>
<xsl:copy-of select=".|following-sibling::*[1]"/>
</div>
</xsl:template>

On 18/01/2011 13:46, Matthieu Ricaud-Dussarget wrote:

My goal is to prevent *orphans* title, that's why I need to group each title with his first-sibling (with conditions as said before).

I can't help feeling there must be better ways of doing that...


Michael Kay
Saxonica

Current Thread