By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,378 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,378 IT Pros & Developers. It's quick & easy.

& in XHTML

P: n/a
In trying to validate a document as XHTML Strict, and using < and
&gt; to display < and >, I get this message from the validator:

character "&" is the first character of a delimiter but occurred as data

1) What exactly does that mean?
2) How can I display < and > without using < and > and not get the
messages from the validator? It still validates, but I would like for it
not to have those "warnings" (Not sure thats the right term).

The lines are lines of script code that look something like this:

this.ie4=(document.all && !this.dom && !this.opera5)?1:0;<br />

And its the && that is causing the problems. :-(

Thanks in advance.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Randy Webb:
In trying to validate a document as XHTML Strict, and using &lt; and
&gt; to display < and >, I get this message from the validator: character "&" is the first character of a delimiter but occurred as data The lines are lines of script code that look something like this: this.ie4=(document.all && !this.dom && !this.opera5)?1:0;<br /> And its the && that is causing the problems. :-(


You're using "&" (in "&&") inside your script. The script is part of a
HTML page, and (as always) "&" has to be written as "&amp;".

It's always better to put script in external js files. Then you can
write like you did.

(I kind of wonder about the "<br />" at the end of the line...)

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>
Jul 20 '05 #2

P: n/a
Randy Webb <hi************@aol.com> wrote:
In trying to validate a document as XHTML Strict, and using &lt; and
&gt; to display < and >, I get this message from the validator:

character "&" is the first character of a delimiter but occurred as data
Are yiu sure you're getting that message in relation to &gt; or &lt;?
They both validate under XHTML 1.0 Strict.
1) What exactly does that mean?
The code contains an & that is not the start of a recognised entity.
2) How can I display < and > without using < and > and not get the
messages from the validator?
&lt; &gt; < > &#x3c; &#x3e;
The lines are lines of script code that look something like this:

this.ie4=(document.all && !this.dom && !this.opera5)?1:0;<br />

And its the && that is causing the problems. :-(


So nothing to do with &gt; or &lt; after all?

Move the JavaScript to an external .js file. XHTML has different rules
on embedding scripts and whilst in theory you can mark the script
content as CDATA it's usually easier to just put it all in an external
file.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3

P: n/a
Bertilo Wennergren wrote:
Randy Webb:

In trying to validate a document as XHTML Strict, and using &lt; and
&gt; to display < and >, I get this message from the validator:
character "&" is the first character of a delimiter but occurred as data


The lines are lines of script code that look something like this:


this.ie4=(document.all && !this.dom && !this.opera5)?1:0;<br />


And its the && that is causing the problems. :-(

You're using "&" (in "&&") inside your script. The script is part of a
HTML page, and (as always) "&" has to be written as "&amp;".


Thank you. I feel really stupid now. I should have known that :-(
It's always better to put script in external js files. Then you can
write like you did.
(I kind of wonder about the "<br />" at the end of the line...)


The script is to be displayed on the page, for commenting, not executing
.. So, the <br /> was to maintain my line breaks. I considered a pre or
code block (something to keep my line breaks) but in the end I just used
div tags and <br /> tags to maintain structure and to allow me to color
the components. Its not finished but you can see it at
http://www.hikksworld.com/critique/page2.html

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4

P: n/a
"Randy Webb" <hi************@aol.com> wrote in message
news:69********************@comcast.com...
<snip />
The script is to be displayed on the page, for commenting, not executing . So, the <br /> was to maintain my line breaks. I considered a pre or
code block (something to keep my line breaks) but in the end I just used div tags and <br /> tags to maintain structure and to allow me to color the components. Its not finished but you can see it at
http://www.hikksworld.com/critique/page2.html


This is important info that is missing from the original post, if you're
displaying the raw script and not executing it then run it through ASPs
Server.HTMLEncode (or equivalent), or at least convert all <, > and &
into their entity equivalents:

indexOf("MSIE 6")>-1 && this.dom

vs.

indexOf("MSIE 6")&gt;-1 &amp;&amp; this.dom
--
Andrew Urquhart
Reply: http://www.andrewu.co.uk/about/conta...ct=Re%3A+ciwah
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.