Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi all,

Im confused with my html code for the time of w3c validation because its obvious that the closing and opening tags are in the right order.. and am using the html code inside the xml file.

so please have look into it my below error code,

my error is :

Line 620, Column 216: end tag for "table" which is not finished

…ellpadding="0" cellspacing="0"></table></td><td valign="top" width="144"><tabl…

my code is:
XML
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="first_count">
    <xsl:value-of select="(count(/Countries/country[price = '0.5p']) div 4)"/>
  </xsl:param>
  <xsl:param name="second_count">
    <xsl:value-of select="((count(/Countries/country[price = '0.5p']) * 2) div 4)"/>
  </xsl:param>
  <xsl:param name="third_count">
    <xsl:value-of select="((count(/Countries/country[price = '0.5p']) * 3) div 4)"/>
  </xsl:param>
  <xsl:param name="countall">
    <xsl:value-of select="(count(/Countries/country[price = '0.5p']))"/>
  </xsl:param>

  <xsl:template match="Countries">
    <table width="631" border="0" cellspacing="0" cellpadding="7">
      <tr>
        <td valign="top" width="144">
          <table width="140" cellpadding="0" cellspacing="0">
            <xsl:for-each select="country[price='0.5p']">
              <xsl:if test="position() &lt;= $first_count ">
                <xsl:choose>
                  <xsl:when test="position() mod 2 = 1">
                    <tr>
                      <td class="black">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:when>
                  <xsl:otherwise>
                    <tr>
                      <td class="grey">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:if>

            </xsl:for-each>
          </table>
        </td>
        <td valign="top" width="144">
          <table width="140" cellpadding="0" cellspacing="0">
            <xsl:for-each select="country[price='0.5p']">

              <xsl:if test="position() &gt; $first_count and position() &lt;= $second_count ">
                <xsl:choose>
                  <xsl:when test="position() mod 2 = 1">
                    <tr>
                      <td class="black">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:when>
                  <xsl:otherwise>
                    <tr>
                      <td class="grey">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:if>

            </xsl:for-each>
          </table>
        </td>
        <td valign="top" width="144">
          <table width="140" cellpadding="0" cellspacing="0">
            <xsl:for-each select="country[price='0.5p']">

              <xsl:if test="position() &gt; $second_count and position() &lt;= $third_count ">
                <xsl:choose>
                  <xsl:when test="position() mod 2 = 1">
                    <tr>
                      <td class="black">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:when>
                  <xsl:otherwise>
                    <tr>
                      <td class="grey">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:if>

            </xsl:for-each>
          </table>
        </td>
        <td valign="top" width="144">
          <table width="140" cellpadding="0" cellspacing="0">
            <xsl:for-each select="country[price='0.5p']">

              <xsl:if test="position() &gt; $third_count">
                <xsl:choose>
                  <xsl:when test="position() mod 2 = 1">
                    <tr>
                      <td class="black">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:when>
                  <xsl:otherwise>
                    <tr>
                      <td class="grey">
                        <xsl:value-of select="name"/>
                      </td>
                    </tr>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:if>

            </xsl:for-each>
          </table>
        </td>
      </tr>
    </table>
  </xsl:template>

</xsl:stylesheet>


thanks to advance...
Posted
Updated 25-Jan-13 23:40pm
v3
Comments
OriginalGriff 26-Jan-13 5:26am    
We can't - that code fragment is just not sufficient.
"its obvious that the closing and opening tags are in the right order"
I would believe the computer over you - it doesn't make mistakes like that. Somewhere, your data is wrong - but we can't see it so we can't say where...
OriginalGriff 26-Jan-13 5:54am    
Better - but I still have doubts.
Why is it complaining about line 620, column 216, when you file has only 120-odd lines, and less than 80 characters per line?
Are you sure you are looking at the right file?
Ed Nutting 26-Jan-13 6:43am    
He has xsl repeating units in there doesn't he? He's probably got lots of content injected into the page that we can't see but that is actually being validated. I would suggest he turn on the option to show the actual HTML that is being validated and then post all of that.

Ed
OriginalGriff 26-Jan-13 6:44am    
Would help, wouldn't it? :laugh:
Sergey Alexandrovich Kryukov 26-Jan-13 11:57am    
No!..
—SA

According to validation error,

VB
…ellpadding="0" cellspacing="0"></table></td><td valign="top" width="144"><tabl…


for some cases there are no items that match for-each criteria:

XML
<xsl:for-each select="country[price='0.5p']" xmlns:xsl="#unknown"></xsl:for-each>


in a result you are generating empty table tag without any contents inside.

XML
<table width="140" cellpadding="0" cellspacing="0">
</table>


and this is what we actually see in validation error.

Consider neither using xsl:if to filter this, or just adding empty row outside of xsl:for-each.
 
Share this answer
 
try this

XML
<?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:param name="first_count">
            <xsl:value-of select="(count(/Countries/country[price = '0.5p']) div 4)" />
        </xsl:param>
        <xsl:param name="second_count">
            <xsl:value-of select="((count(/Countries/country[price = '0.5p']) * 2) div 4)" />
        </xsl:param>
        <xsl:param name="third_count">
            <xsl:value-of select="((count(/Countries/country[price = '0.5p']) * 3) div 4)" />
        </xsl:param>
        <xsl:param name="countall">
            <xsl:value-of select="(count(/Countries/country[price = '0.5p']))" />
        </xsl:param>
        <xsl:template match="Countries">
            <table width="631" border="0" cellspacing="0" cellpadding="7">
                <tr>
                    <td valign="top" width="144">
                        <table width="140" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <xsl:for-each select="country[price='0.5p']">
                                        <xsl:if test="position() &lt;= $first_count ">
                                            <xsl:choose>
                                                <xsl:when test="position() mod 2 = 1">
                                                    <tr>
                                                        <td class="black">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <tr>
                                                        <td class="grey">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td valign="top" width="144">
                        <table width="140" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <xsl:for-each select="country[price='0.5p']">
                                        <xsl:if test="position() &gt; $first_count and position() &lt;= $second_count ">
                                            <xsl:choose>
                                                <xsl:when test="position() mod 2 = 1">
                                                    <tr>
                                                        <td class="black">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <tr>
                                                        <td class="grey">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td valign="top" width="144">
                        <table width="140" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <xsl:for-each select="country[price='0.5p']">
                                        <xsl:if test="position() &gt; $second_count and position() &lt;= $third_count ">
                                            <xsl:choose>
                                                <xsl:when test="position() mod 2 = 1">
                                                    <tr>
                                                        <td class="black">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <tr>
                                                        <td class="grey">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td valign="top" width="144">
                        <table width="140" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <xsl:for-each select="country[price='0.5p']">
                                        <xsl:if test="position() &gt; $third_count">
                                            <xsl:choose>
                                                <xsl:when test="position() mod 2 = 1">
                                                    <tr>
                                                        <td class="black">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <tr>
                                                        <td class="grey">
                                                            <xsl:value-of select="name" />
                                                        </td>
                                                    </tr>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </xsl:template>
    </xsl:stylesheet>

Thanks
 
Share this answer
 
Comments
stellus 28-Jan-13 5:48am    
hi ashish,

i tried the above code , but i can't rectify the error. please put up me a anathor solution.

thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900