...

View Full Version : HTML validator problem, java code



BubikolRamios
08-02-2011, 11:18 AM
<%
if (some condition that is false)
{
//so this does not gets executed
out.println("Access denied, members only !");
return ;
}
%>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

.....



1.if I look at page source: there is no text like "Access denied, members only !". As expected.
2. validate:



Validation Output: 3 Errors

Error Line 21, Column 1: document instance must start with document element

Access denied, members only !


Error Line 21, Column 1: character data is not allowed here

Access denied, members only !



You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.
Error Line 21, Column 30: no document element

Access denied, members only !



?

Rowsdower!
08-02-2011, 01:10 PM
Are you saying you viewed the source code in the validator (using the "Show Source" check box option) or are you saying you viewed the source from your browser when you visit your own page? If you're viewing from your own browser's view source then you should use the validator's Show Source option instead to get line numbers and see the actual source code being evaluated.

Can you give us a link to the page you are testing?

Anyway, for whatever reason the validator's visit to your page is not getting the "false" result from the check that you are expecting it to get in ASP. To fix the validation you would need to add proper doctype declaration and page structure (html tags, head, title, body, and paragraph or div to contain the text) to this portion of your script:


<%
if (some condition that is false)
{
//so this does not gets executed
out.println("Access denied, members only !");
return ;
}
%>

But as for why your if statement is evaluating true rather than false, I can't even begin to guess without seeing your full ASP script.

BubikolRamios
08-02-2011, 01:33 PM
Are you saying you viewed the source code in the validator (using the "Show Source" check box option) .

Ahh damn. Sure thing. When I see the page , I'm logged in, so it shows everything.
When validator takes it, it is not logged in, so it gets entirely different contence.

I have shortuct on my page to validator, and next to it my user name(as I',m logged in), so it was kind of dificult to figure out what is going wrong.

Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum