Pretty up XSL, cater to empty case

This commit is contained in:
Samuel Cochran 2011-12-23 03:34:02 +08:00
parent 50ea84cebf
commit 1067c208cb

View File

@ -1,26 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/xml">
<section class="fractal-analysis">
<xsl:for-each select="result/errors/error">
<xsl:variable name="errorCount" select="position()"/>
<p class="report-intro">
<strong><xsl:value-of select="$errorCount" />.</strong> The <span class="code"><xsl:value-of select="rule/rule_name" /></span> near <span class="code"><xsl:value-of select="snippet" /></span> on line <span class="code"><xsl:value-of select="error_line" /></span> of your code.
</p>
<dl class="unsupported-clients">
<dt>This is unsupported in:</dt>
<dd>
<ul>
<xsl:for-each select="rule/email_client//item">
<li>
<xsl:value-of select="." />
</li>
</xsl:for-each>
</ul>
</dd>
</dl>
</xsl:for-each>
</section>
<section class="fractal-analysis">
<h1>Fractal Results</h1>
<xsl:choose>
<xsl:when test="not(result/errors/node())">
<p class="report-intro valid">Your HTML and CSS for your email is valid.</p>
</xsl:when>
<xsl:otherwise>
<p class="report-intro invalid">Your HTML and CSS for your email contains potential errors:</p>
<ol>
<xsl:for-each select="result/errors/error">
<li>
<p class="error-intro">The <code><xsl:value-of select="rule/rule_name" /></code> near <code><xsl:value-of select="snippet" /></code> on line <code><xsl:value-of select="error_line" /></code> of your code.</p>
<dl class="unsupported-clients">
<dt>This is unsupported in:</dt>
<dd>
<ul>
<xsl:for-each select="rule/email_client//item">
<li><xsl:value-of select="." /></li>
</xsl:for-each>
</ul>
</dd>
</dl>
</li>
</xsl:for-each>
</ol>
</xsl:otherwise>
</xsl:choose>
</section>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>