[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Getting the first p inside a div


Subject: Re: [xsl] Getting the first p inside a div
From: Walter Lee Davis <waltd@xxxxxxxxxxxx>
Date: Tue, 19 Aug 2008 12:25:13 -0400

Thanks very much!

On Aug 19, 2008, at 12:02 PM, Wendell Piez wrote:

Something like this:

<xsl:template match="note//p">
<p class="note_p">
<xsl:if test="generate-id() = generate-id(ancestor::note/ descendant::p[1])">
<xsl:apply-templates select="ancestor::note/label"/>
</xsl:if>
<xsl:apply-templates/>
</p>
</xsl:template>


What this does:

* Collapse the templates together for all p elements inside note, rather than splitting a template out for the first p. This is clearer, allows better code reuse, and is more robust.


I agree (about the robustness), and it works perfectly.

Walter


Current Thread