xsl-list
[Top] [All Lists]

Re: [xsl] grouping xhtml title with first sibling

2011-01-18 08:34:20
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--