Jump to content

puzzling simple comparison parse error message


W3_Bill

Recommended Posts

My javascript is within a 39-line xhtml file "debug.xhtml", which is attached.

When I load the file into Firefox 65 on a Fedora-28 workstation, I get the following error message:

XML Parsing Error: not well-formed Location: file:///[private path]/debug.xhtml Line Number 29, Column 21:
   if  (picturenum < 10)  {
--------------------^

W3C's validator gives the following message:

Warning Line 27, Column 20: character "<" is the first character of a delimiter but occurred as data

   if  (picturenum < 10)  {

I've wrestled with this for hours.  What's wrong?

If it helps, the validator also gives 5 additional messages:

(1)

Error Line 6, Column 18: there is no attribute "charset"

   <meta charset="UTF-8" />

(2)

Error Line 6, Column 27: required attribute "content" not specified

   <meta charset="UTF-8" />

(3)

Error Line 14, Column 39: document type does not allow element "img" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset" start-tag

<img id="BianzhongPic" src="x" alt="" >

(4)

Error Line 14, Column 40: end tag for "img" omitted, but OMITTAG NO was specified

<img id="BianzhongPic" src="x" alt="" >

(5)

Info Line 14, Column 1: start tag was here

<img id="BianzhongPic" src="x" alt="" >

These all look like false alarms to me.

Thank-you in advance.

Bill.

debug.xhtml

Link to comment
Share on other sites

Your document is not XHTML, it's HTML 5, so the XHTML validator is going to find problems with it and XML parsers will as well. Save it with a .html extension rather than .xhtml so that the browser doesn't try to use the XML parser on it.

Link to comment
Share on other sites

6 hours ago, Ingolme said:

Your document is not XHTML, it's HTML 5, so the XHTML validator is going to find problems with it and XML parsers will as well. Save it with a .html extension rather than .xhtml so that the browser doesn't try to use the XML parser on it.

My objective is the opposite.  I'm putting in a lot of effort to make all my documents much more strictly compliant with standards.  I want my docs to be xhtml docs.  I've invested a lot of time and effort in the W3Schools site (and other places) learning xhtml, figuring out how to convert my docs, and trying to figure out what's wrong with debug.xhtml.

What do I need to do to make debug.xhtml valid xhtml?

Link to comment
Share on other sites

XHTML is actually an old and outdated standard, I would not suggest sticking with it. If you really want your document to be XHTML compliant, here's a list of things that need to be fixed:

  • All tags must either have a closing tag (<img></img>) or be self-closed (<img />)
  • The charset attribute does not exist in XHTML, you have to get rid of it, you must use the content attribute in the meta tag.
  • Inline elements such as <img> cannot be a direct child of the <body>
  • You cannot have any angle brackets "<" ">" in your code unless they're part of a tag. To use angle brackets as content you have to use the entities that represent them, &lt; and &gt;.

I highly suggest forgetting about XHTML, it is not good.

Link to comment
Share on other sites

> XHTML is actually an old and outdated standard, I would not suggest sticking with it.

That's news to me!  But I'm not surprised.  Can't use greater than or less than symbols?  That makes for harder-to-read code.  I also repeatedly find character entity names (like &nbsp) rejected; I have to use their numbers.  That is specific to xhtml, right?  It certainly makes the code harder to read, understand, and maintain.

So I'm taking your suggestion and going back to html.

Suggestion to W3Schools: The xhtml tutorial page should say what Ingolme said, and recommend to programmers that have the choice to forget xhtml and use the current version of html.

Thank-you, Ingolme.  I consider this thread closed.

Link to comment
Share on other sites

XHTML was an attempt by the W3C to make HTML compatible with XML parsers. In XML, anytime the parser finds a "<" it assumes that it's the beginning of a tag. XHTML was stuck unchanging for nearly a decade because the members of the W3C couldn't come to an agreement on how to move forward with the standard. After some years a new organization formed named WHATWG which picked up where the W3C left off and they decided to scrap XHTML and continue with HTML, moving it up to version 5. These days, the HTML 5 standard is a joint effort between the W3C and the WHATWG. They don't always agree on things, but we keep moving forward anyway. HTML 5 is referred to as a "living standard" which means that there won't be an HTML 6, they will just keep adding new features to HTML 5 as time progresses.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...