This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Stylesheets] Adding a text the *first* time youencounter a given element?


Jirka Kosek writes:
> Jeff Beal wrote:
> > 
> > Try using
> > <xsl:template match="//rfc[1]">
> >  <!-- Add link to RFC here -->
> > </xsl:template>
> > 
> > I'm not totally sure this will work, but I think since the match is on the
> > /descendant-or-self axis of the root node, this will only match on the first
> > rfc element in the document.
> 
> In attribute match there is XPath pattern and it is evaluated in a
> slightly different way than XPath expression. I think that writing
> //rfc[1] and rfc[1] in match attribute is same and thus it won't work.
> I'm almost 98 % sure :-)
> 
I don't know if your 98% are right, but if this is right, one could do a

<xsl:template match="rfc">
<xsl:if test="not(preceding::rfc)">
<!-- Add link to RFC here -->
</xsl:if>
<xsl:apply-templates/>
</xsl:template>

HTH


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]