CDATA Sections

For technical support for all editions of CSE HTML Validator. Includes bug reports.

CDATA Sections

Postby kennedyrt » Fri Feb 17, 2012 5:26 pm

When the following code is validated under Version 11.0042:

Code: Select all
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() !== false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


The following warning is issued:
This document contains 1 CDATA section. Using CDATA sections is not recommended due to poor browser support (even some newer browsers fail to properly support it) and due to other complications. AI Internet Solutions recommends avoiding CDATA sections if possible or commenting them out (for example, using "//<![CDATA[" and "//]]>" in a "script" element).


The code example above already implements the solution suggested by the warning of commenting out the CDATA section using "//<![CDATA[" and "//]]>" in a "script" element. The warning gives the programmer no remedial action that has not already been taken. The warning message in this example could be considered a false positive.
kennedyrt
Rank I - Novice
Rank I - Novice
 
Posts: 15
Joined: Fri Nov 09, 2007 10:57 pm
Location: Renton, Washington

Re: CDATA Sections

Postby Albert Wiersch » Tue Feb 21, 2012 5:29 pm

Thanks for the suggestion. Right now CSE HTML Validator does not detect whether CDATA start and end "markers" have been commented out, but I will look into improving this in a future update. For example, not generating a warning if all the CDATA markers have been commented out.
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX

Re: CDATA Sections

Postby Albert Wiersch » Wed Sep 12, 2012 2:44 pm

The upcoming FREE PUBLIC BETA will now treat CDATA markers that have been commented out differently than if they haven't. For example, the CDATA markers can be commented out in a script to avoid the standard warning about using CDATA in HTML.

http://www.htmlvalidator.com/freebeta/
Image
Albert Wiersch
User avatar
Albert Wiersch
Site Admin
Site Admin
 
Posts: 2361
Joined: Sat Dec 11, 2004 10:23 am
Location: Near Dallas, TX


Return to CSE Tech Support

Who is online

Users browsing this forum: Google [Bot] and 1 guest