Me... "Why?"
Angry work colleague... "BECAUSE IT'S SHIT!"
Well thought out, considered opinion!
On an XSLT related issue, I had to count the number of items starting with a given letter or number for an A to Z. We can find all the items starting with any given character using starts-with(). In the cace of counting elements which start with a diget we need to do it slightly differently...
<xsl:param name="lcase">abcdefghijklmnopqrstuvwxyz</xsl:param> <xsl:param name="ucase">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:param> <xsl:param name="digits">1234567890</xsl:param> <!-- return the number of books whose name starts with any given letter --> <xsl:template name="alphabet_counter"> <xsl:param name="letter" /> <xsl:value-of select="count(/books/book[starts-with(translate(name,$lcase,$ucase), translate($letter,$lcase,$ucase))])"></xsl:value-of> </xsl:template> <!-- return the number of books whose name starts with a number --> <xsl:template name="int_counter"> <xsl:value-of select="count(/books/book[contains($digits, substring(name, 1, 1) ) ])"></xsl:value-of> </xsl:template>
No comments:
Post a Comment