Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XMLHTMLXSL
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 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 25-Jan-13 23:12pm
stellus925
Edited 25-Jan-13 23:40pm
v3
Comments
OriginalGriff at 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 at 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 at 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 at 26-Jan-13 6:44am
   
Would help, wouldn't it? :laugh:
Sergey Alexandrovich Kryukov at 26-Jan-13 11:57am
   
No!..
—SA
Ed Nutting at 26-Jan-13 13:25pm
   
No?? :confused:
Sergey Alexandrovich Kryukov at 26-Jan-13 14:58pm
   
Е-ее... who would like so see huge XML here. Such a trivial thins as non-well-formed... OP can sort it out, if not — nothing can help. It' an answer of a sort "just do it"...
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

According to validation error,
 
…ellpadding="0" cellspacing="0"></table></td><td valign="top" width="144"><tabl…
 
 
for some cases there are no items that match for-each criteria:
 
<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.
 
<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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try this
 
<?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
  Permalink  
Comments
stellus at 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
0 Sergey Alexandrovich Kryukov 668
1 OriginalGriff 396
2 Tadit Dash 345
3 sanket saxena 329
4 Peter Leow 193
0 Sergey Alexandrovich Kryukov 12,109
1 OriginalGriff 7,326
2 Peter Leow 5,003
3 Abhinav S 4,003
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid