Jump to content

XHTML Validation problem with shorttags


agbates

Recommended Posts

Hello Everyone,

 

I'm not skilled with php. I am currently working on an xhtml project which uses the following php:

 

http://www.alistapart.com/articles/keepingcurrent/

 

When running it thru the W3 validator for XHTML strict, it comes up with errors regarding the use of "short tags". Can anyone supply a compliant workaround?

 

The original author of the article is long gone somewhere..

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/84482-xhtml-validation-problem-with-shorttags/
Share on other sites

Here's the code I attempted to validate using the W3 validator, XHTML strict doctype:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php $thisPage="All about us"; ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XHTML Strict Navigation Test</title>
<style type="text/css" media="screen">@import"styles/site.css";</style></head>
<body>

<div id="navigation">
  <ul>
    <li<?php if ($thisPage=="Page One") 
      echo " id=\"currentpage\""; ?>>
      <a href="http://www.nowhere.com/pageone.php">Page One</a></li>
    <li<?php if ($thisPage=="Page Two") 
      echo " id=\"currentpage\""; ?>>
      <a href="http://www.nowhere.com/pagetwo.php">Page Two</a></li>
    <li<?php if ($thisPage=="Page Three") 
      echo " id=\"currentpage\""; ?>>
      <a href="http://www.nowhere.com/pagethree.php">Page Three</a></li>
    <li<?php if ($thisPage=="Page Four") 
      echo " id=\"currentpage\""; ?>>
      <a href="http://www.nowhere.com/pagefour.php">Page Four</a></li>
  </ul>
</div>

</body>
</html>

 

 

Here are the results reported by the validator:

 

Validation Output:  17 Errors

   1. Error XML Parsing Error


          * Line 12, column 7: XML Parsing Error: error parsing attribute name

                <li<?php if ($thisPage=="Page One") 

          * Line 12, column 7: XML Parsing Error: attributes construct error

                <li<?php if ($thisPage=="Page One") 

          * Line 12, column 7: XML Parsing Error: Couldn't find end of Start Tag li line 12

                <li<?php if ($thisPage=="Page One") 

          * Line 14, column 68: XML Parsing Error: Opening and ending tag mismatch: ul line 11 and li

            …://www.nowhere.com/pageone.php">Page One</a></li>

          * Line 15, column 7: XML Parsing Error: error parsing attribute name

                <li<?php if ($thisPage=="Page Two") 

          * Line 15, column 7: XML Parsing Error: attributes construct error

                <li<?php if ($thisPage=="Page Two") 

          * Line 15, column 7: XML Parsing Error: Couldn't find end of Start Tag li line 15

                <li<?php if ($thisPage=="Page Two") 

          * Line 17, column 68: XML Parsing Error: Opening and ending tag mismatch: div line 10 and li

            …://www.nowhere.com/pagetwo.php">Page Two</a></li>

          * Line 18, column 7: XML Parsing Error: error parsing attribute name

                <li<?php if ($thisPage=="Page Three") 

          * Line 18, column 7: XML Parsing Error: attributes construct error

                <li<?php if ($thisPage=="Page Three") 

          * Line 18, column 7: XML Parsing Error: Couldn't find end of Start Tag li line 18

                <li<?php if ($thisPage=="Page Three") 

          * Line 20, column 72: XML Parsing Error: Opening and ending tag mismatch: body line 8 and li

            …owhere.com/pagethree.php">Page Three</a></li>

          * Line 21, column 7: XML Parsing Error: error parsing attribute name

                <li<?php if ($thisPage=="Page Four") 

          * Line 21, column 7: XML Parsing Error: attributes construct error

                <li<?php if ($thisPage=="Page Four") 

          * Line 21, column 7: XML Parsing Error: Couldn't find end of Start Tag li line 21

                <li<?php if ($thisPage=="Page Four") 

          * Line 23, column 70: XML Parsing Error: Opening and ending tag mismatch: html line 3 and li

            …ww.nowhere.com/pagefour.php">Page Four</a></li>

          * Line 24, column 2: XML Parsing Error: Extra content at the end of the document

              </ul>

   2. Warning unclosed start-tag requires SHORTTAG YES

     

      The construct <foo<bar> is valid in HTML (it is an example of the rather obscure “Shorttags” feature) but its use is not recommended. In most cases, this is a typo that you will want to fix. If you really want to use shorttags, be aware that they are not well implemented by browsers.
          * Line 12, column 7: unclosed start-tag requires SHORTTAG YES

                <li<?php if ($thisPage=="Page One") 

          * Line 15, column 7: unclosed start-tag requires SHORTTAG YES

                <li<?php if ($thisPage=="Page Two") 

          * Line 18, column 7: unclosed start-tag requires SHORTTAG YES

                <li<?php if ($thisPage=="Page Three") 

          * Line 21, column 7: unclosed start-tag requires SHORTTAG YES

                <li<?php if ($thisPage=="Page Four") 

 

 

I hope that helps?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.