Not
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
In this example, the names in a group of names are formatted as a comma-separated list.
XML File (names.xml)
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="ifcomma.xsl" ?>
<namelist>
<name>Albert</name>
<name>Terrance</name>
<name>Will</name>
<name>Sylvia</name>
<name>Timothy</name>
<name>Gordon</name>
<name>James</name>
<name>Robert</name>
<name>Dan</name>
<name>Sasha</name>
</namelist>
XSLT File (ifcomma.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:apply-templates/>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:template>
</xsl:stylesheet>
Output
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
See Also
Concepts
Example 2 of <xsl:if>
Example 3 of <xsl:if>
Example 4 of <xsl:if>