[thelist] Javascript/XHTML Strict Validation

liorean liorean at gmail.com
Mon Nov 8 15:46:41 CST 2004


On Mon, 8 Nov 2004 13:26:36 -0600, Kevin Switzer
<kevin.switzer at stamats.com> wrote:
> I have a page that is XHTML Strict.  I get 4 errors, but I'm not sure how to fix them, have the javascript still work, and validate in XHTML Strict.  Any help would be MUCH appreciated.

Everything can be solved very easily by moving the entire script to an
external file. If you don't want to do that, though, there is another
solution.

> Below are the results of attempting to parse this document with an SGML parser.
> 1.      Line 16, column 30: character ";" not allowed in attribute specification list

As an explanation for the error, the XML parser thinks "sfEls.length"
is an element name, and ";" is the first character that is not part of
the element name. That means it must be an attribute name. But, since
";" is not a legal character in attributes, it throws a syntax error
on the XML level.

> 2.      Line 16, column 30: element "sfEls.length" undefined

As said, it thinks "sfEls.length" is an element. It can't find the
definition for this element in the DTD, so the element gives a
validation error on the XHTML level.

> 3.      Line 26, column 8: end tag for "sfEls.length" omitted, but OMITTAG NO was specified

Pretty self explanatory.

> 4.      Line 16, column 17: start tag was here

Not really an error, just pointing out the position for hte start tag.




The alternative solution to the use of an external file is to use 

<script type="text/javascript">
// <[CDATA[

    your script here

// ]]>
</script>


This tells the XML parser that all characters inside the CDATA block
should be treated as literal characters, instead of parsed XML.
-- 
David "liorean" Andersson
<uri:http://liorean.web-graphics.com/>


More information about the thelist mailing list