Saturday, July 26, 2008

An elegant XSLT solution

We usually see some nice posts, on the xsl-list.

David Carlisle recently posted a very elegant XSLT solution to a question asked on xsl-list. It's archived here, http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200807/msg00574.html.

I really liked the following expression, in David's solution:

<xsl:attribute name="level">
<xsl:value-of select="sum(.|preceding::sect[1]/@depth)"/>
</xsl:attribute>

I might have solved this problem differently, but not as elegantly like this. Nice thought, David!

No comments: