Alice Ju-Hsuan Wei wrote:
Hi,
Below are two templates I am using to display some titles of the
book. I am wondering if anybody knows whether or not I can use the
count function here so that for books with multiple books by one author,
I think you mean: books with multiple titles but with one author
the titles would be broken off with the <p> tag, but those with only
one, would not display the <p> tag. Anyone know if I should use
<xsl:if> or the count function here?
That is quite a generic question. In general, it is probably not needed
to use xsl:if. And yes, you can use the count function. When you are in
the context of <book>, you can use count(title) to find out. When you
design the matching template for <title>, just change it to be
<xsl:template match="title[1]" to match only the first title and make a
throw away generic template for the rest.
<!-- first title -->
<xsl:template match="title[1]">
<p><xsl:apply-templates /></p>
</xsl:template>
<!-- throw away -->
<xsl:template match="title" />
If you don't want to do anything with count, this is it. Alternatively,
you can simplify matters by changing your select statement instead. But
that is a matter of taste and context.
Cheers,
-- Abel Braaksma
--~------------------------------------------------------------------
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>
--~--