shithub: xmltools

ref: fb0e2e9c6043e8bba9efda507111bab946db50be
dir: /test/s.xml/

View raw version
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
	<xsl:template match="/users">
		<html>
		<body>
			<xsl:apply-templates select="user" />
			<xsl:loop select="user">
				<xsl:fallback>
					<div>
					<xsl:for-each select="user">
						<xsl:value-of select="name" />
						<xsl:if test="position()!=last()">
							<xsl:text>, </xsl:text>
						</xsl:if>
					</xsl:for-each>
					</div>
				</xsl:fallback>
			</xsl:loop>
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="user">
		<div>
			<xsl:comment><xsl:value-of select="name" /></xsl:comment>
			<h1>User: <xsl:value-of select="name" /></h1>
			<ul>
			<li>Login: <xsl:value-of select="@id" /></li>
			<li>Email: <xsl:value-of select="email" /></li>
			</ul>
		</div>
	</xsl:template>
</xsl:stylesheet>