Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Another way to separate the names by commas is to check a name to see if it is the first. In some circumstances this performs better than Example 1 of <xsl:if> , because the last()
function requires that the entire set of names be found and counted, while this approach does not.
Use the names.xml listing in Example 1 of <xsl:if>
, but edit the href
attribute to point to ifcomma2.xsl.
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="namelist/name">
<xsl:if test="position()!=1">, </xsl:if>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
This is the formatted output:
Albert, Terrance, Will, Sylvia, Timothy, Gordon, James, Robert, Dan, Sasha
This is the processor output:
<?xml version="1.0" encoding="UTF-16"?>Albert, Terrance, Will, Sylvia, Timothy, Gordon, James, Robert, Dan, Sasha