James H. writes "If you had to programatically output a list of HTML <a> tags linking to anchors for the Alphabet like this:
<a href="#A">A</a> <a href="#B">B</a> ...
"How would you do it? A for loop through the relevant ASCII code numbers so you can use Asc(i) to output the letter or something similar? Oh no, apparently this is the right way:
1) Create an XML file to define the alphabet (calling the root tag "root" and each node "node," since hey, that's what they are after all:
<root> <node>A</node> <node>B</node> <node>C</node> <node>D</node> <node>E</node> <node>F</node> <node>G</node> <node>H</node> <node>I</node> <node>J</node> <node>K</node> <node>L</node> <node>M</node> <node>N</node> <node>O</node> <node>P</node> <node>Q</node> <node>R</node> <node>S</node> <node>T</node> <node>U</node> <node>V</node> <node>W</node> <node>X</node> <node>Y</node> <node>Z</node> </root>
"2) Use XSLT to render the <a> tags (full implementation details omitted for sanity pusposes):
<xsl:for-each select="document($alpha)/root/node"> <xsl:variable name="alpha" select="."/> <xsl:variable name="found_alpha"> <xsl:text>false</xsl:text> <xsl:for-each select="document($staff)/staff"> <xsl:for-each select="profile"> <xsl:if test="starts-with(surname, $alpha)"> <xsl:text>true</xsl:text> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:variable> <li> <xsl:if test="$found_alpha = 'true'"><xsl:value-of select="$found_alpha"/></xsl:if> <a> <xsl:attribute name="href"> <xsl:text>/staff.cfm#</xsl:text><xsl:value-of select="$alpha" /> </xsl:attribute> <xsl:attribute name="title"> <xsl:text>Jump to the listing of staff with surnames beginning with </xsl:text><xsl:value-of select="$alpha" /> </xsl:attribute> <xsl:value-of select="$alpha"/> </a> </li> </xsl:for-each>
"Yes, that's all much simpler than three line for loop."
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!