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
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?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.