473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

& in XHTML

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
4 12735
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rutger Claes | last post by:
Code and problem are from PHP5: When I execute the following piece of code, the DomException is thrown with a message: Not Found Exception. I assume this means that the node I extracted from the...
6
by: Tjerk Wolterink | last post by:
When i open the following xml file in internetexplorer: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE xc:content > <xc:xcontent...
2
by: Bond13579 | last post by:
Hi! I'm not an expert in XSL and XHTML so I need a little help! I have an XSL file that ends up using the ENTITY (varname) SYSTEM (file.xhtml) and then calls this variable which in turn outputs...
2
by: Brian Idzik | last post by:
I've successfully setup a xhtml 1.0 strict page with Mozilla & Netscape to display links in a toolbar into an internal <div id='content'> within the same document. The toolbar uses some...
81
by: Michael Rozdoba | last post by:
I've been wandering around the results of numerous googles for several hours without reaching a conclusive solution, so I'm dipping a tentative toe back in ciwah... I've been persuaded here in...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
13
by: rbronson1976 | last post by:
Hi all, I have a very simple page that Firefox has problems with: www.absolutejava.com/testing.htm First of all, this page seems to be perfectly valid XHTML Strict. Both the W3C validator as...
4
by: David Grogan | last post by:
Hi, 2 questions.... 1. I'm parsing an XHTML document that contains both the default namespace (xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") - both of these being...
1
by: Jim Carlock | last post by:
Let's not argue about semantics. Let's talk about semasiology. Do specifications exist for using mixed case, upper case, lower case for the contents of the method employed? My own preferences...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.