ZPT parser changes from 2.6.x to 2.7.3 ?
Hi all. The following page was accepted under Zope 2.6.x, but it is not anymore accepted under Zope 2.7.3. <html> <head> <title tal:content="template/title">The title</title> </head> <body> <script><![CDATA[ if (gecko) document.write('<tr><td><table>'); ]]></script> <script><![CDATA[ if (gecko) document.write('</table></td></tr>'); ]]> </script> </body> </html> The problem, of course, is in the </table> inside the second <script> section. The error is: Compilation failed TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do not match close tag </table>, at line 10, column 36 therefore, the parse is interpreting the inside of the <script> tag as normal tags instead of simple content of the script. (Please note that it is not an option, at the moment, to put the <tr><td><table> inside one single <script> tag, because there is other content between the two scripts). Any suggestions? Regards Marco
Marco Bizzarri wrote:
Hi all.
The following page was accepted under Zope 2.6.x, but it is not anymore accepted under Zope 2.7.3.
<html> <head> <title tal:content="template/title">The title</title> </head> <body> <script><![CDATA[ if (gecko) document.write('<tr><td><table>'); ]]></script> <script><![CDATA[ if (gecko) document.write('</table></td></tr>'); ]]> </script> </body> </html>
The problem, of course, is in the </table> inside the second <script> section. The error is:
Compilation failed TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do not match close tag </table>, at line 10, column 36
therefore, the parse is interpreting the inside of the <script> tag as normal tags instead of simple content of the script.
(Please note that it is not an option, at the moment, to put the <tr><td><table> inside one single <script> tag, because there is other content between the two scripts).
Any suggestions?
Put your JavaScript code in a DMTL-Method or Python Script or File and call it from the Page Template: <script tal:content="structure here/myJavaScriptSnippet"/> I'd prefer to request the JS code with the 'src' attribute of the <script> element. HTH Tonico
Tonico Strasser wrote:
Marco Bizzarri wrote:
Hi all.
The following page was accepted under Zope 2.6.x, but it is not anymore accepted under Zope 2.7.3.
<html> <head> <title tal:content="template/title">The title</title> </head> <body> <script><![CDATA[ if (gecko) document.write('<tr><td><table>'); ]]></script> <script><![CDATA[ if (gecko) document.write('</table></td></tr>'); ]]> </script> </body> </html>
The problem, of course, is in the </table> inside the second <script> section. The error is:
Compilation failed TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do not match close tag </table>, at line 10, column 36
therefore, the parse is interpreting the inside of the <script> tag as normal tags instead of simple content of the script.
(Please note that it is not an option, at the moment, to put the <tr><td><table> inside one single <script> tag, because there is other content between the two scripts).
Any suggestions?
Put your JavaScript code in a DMTL-Method or Python Script or File and call it from the Page Template:
<script tal:content="structure here/myJavaScriptSnippet"/>
I'd prefer to request the JS code with the 'src' attribute of the <script> element.
HTH Tonico
Hi Tonico. Yes, it was useful to identify some solutions. I will try all the solutions... Regards Marco
On Tue, 16 Nov 2004 13:03:07 +0100, Marco Bizzarri <m.bizzarri@icube.it> wrote:
<script><![CDATA[ if (gecko) document.write('</table></td></tr>'); ]]>
...
Compilation failed TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do not match close tag </table>, at line 10, column 36
therefore, the parse is interpreting the inside of the <script> tag as normal tags instead of simple content of the script.
Not just any tags; it's catching the "</" in particular. The parser being used doesn't understand <![CDATA[...]]>, so doesn't avoid this problem. In addition to the options Tonico suggested, there's one more option: change the line containing the </table> to: if (gecko) document.write('<' + '/table></td></tr>'); This avoids the specific behavior you're seeing, and would also work without the CDATA marked section.
(Please note that it is not an option, at the moment, to put the <tr><td><table> inside one single <script> tag, because there is other content between the two scripts).
No need to do that. -Fred -- Fred L. Drake, Jr. <fdrake at gmail.com> Zope Corporation
Fred Drake wrote:
On Tue, 16 Nov 2004 13:03:07 +0100, Marco Bizzarri <m.bizzarri@icube.it> wrote:
<script><![CDATA[ if (gecko) document.write('</table></td></tr>'); ]]>
...
Compilation failed TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do not match close tag </table>, at line 10, column 36
therefore, the parse is interpreting the inside of the <script> tag as normal tags instead of simple content of the script.
Not just any tags; it's catching the "</" in particular. The parser being used doesn't understand <![CDATA[...]]>, so doesn't avoid this problem.
In addition to the options Tonico suggested, there's one more option: change the line containing the </table> to:
if (gecko) document.write('<' + '/table></td></tr>');
This avoids the specific behavior you're seeing, and would also work without the CDATA marked section.
Ok. I will try this and check... Why the parser does not understand the cdata section? Is this a problem in the HTMLTALParser, or in the parser inside python? Regards Marco
On Tue, 16 Nov 2004 17:29:56 +0100, Marco Bizzarri <m.bizzarri@icube.it> wrote:
I will try this and check... Why the parser does not understand the cdata section?
Just because we didn't add that. There weren't a lot of people using CDATA marked sections in HTML at the time, at least as far as we knew.
Is this a problem in the HTMLTALParser, or in the parser inside python?
It would need to be fixed in the HTMLParser module in Python's standard library. I don't imagine it would actually take much in the way of changes, but it should be considered a new feature, so could not be added until Python 2.5. Feel free to add an issue to the Python bug tracker on SourceForge; you can assign it to me if you like. -Fred -- Fred L. Drake, Jr. <fdrake at gmail.com> Zope Corporation
Fred Drake wrote:
On Tue, 16 Nov 2004 13:03:07 +0100, Marco Bizzarri <m.bizzarri@icube.it> wrote:
<script><![CDATA[ if (gecko) document.write('</table></td></tr>'); ]]>
...
Compilation failed TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do not match close tag </table>, at line 10, column 36
therefore, the parse is interpreting the inside of the <script> tag as normal tags instead of simple content of the script.
Not just any tags; it's catching the "</" in particular. The parser being used doesn't understand <![CDATA[...]]>, so doesn't avoid this problem.
In addition to the options Tonico suggested, there's one more option: change the line containing the </table> to:
if (gecko) document.write('<' + '/table></td></tr>');
This avoids the specific behavior you're seeing, and would also work without the CDATA marked section.
The HTML spec on dynamic document modification: http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.4 points out that you can also escape the forward slash (all of them need escaping, not just the first one), e.g.: if (gecko) document.write('<\/table><\/td><\/tr>') Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
I wrote:
The HTML spec on dynamic document modification:
http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.4
points out that you can also escape the forward slash (all of them need escaping, not just the first one), e.g.:
if (gecko) document.write('<\/table><\/td><\/tr>')
Here is the portion of the spec which mandates terminating the content of a CDATA-typed element (e.g, '<script>' or '<style>') at the first occurence of '</': http://www.w3.org/TR/REC-html40/types.html#h-6.2 Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
participants (4)
-
Fred Drake -
Marco Bizzarri -
Tonico Strasser -
Tres Seaver