[opencms-dev] Inline Javascript within CDATA throwsXMLunmarshalling error

Christian Steinert christian_steinert at web.de
Fri Jan 16 23:41:12 CET 2009


Brock Haywood ha scritto:
> This seems to be the result having nested CDATA sections.  I've looked
> at the control code for the webpage and because everything in that pages
> <content> node is within a CDATA section, when I use my own CDATA
> section, it blows up the xml.
>
> Is there anyway to dynamically add the CDATA sections to my content? Or
> something else to handle this problem?
>   
Why don't you use a JSP template to assemble your final page and add the 
script section there.
Also, why don't you stick your script code into an external .js file - 
then you won't need a cdata section at all. And for the specific 
Javascript code that you quoted, you won't need a cdata block - in this 
specific case, you have nothing therein that would make your xhtml 
invalid even when leaving away the CDATA wrapping.

You definitely cannot nest cdata sections, because in XML, the first ]]> 
will terminate any CDATA that was opened before.

Regards
Christian
> Thanks,
>
> Brock
>
> -----Original Message-----
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Brock Haywood
> Sent: January 15, 2009 1:00 PM
> To: opencms-dev at opencms.org
> Subject: [opencms-dev] Inline Javascript within CDATA
> throwsXMLunmarshalling error
>
> Hi,
>
> I'm trying to migrate a site to opencms.  I've run into a problem where
> there is some inline javascript in a content html page.  The following
> code produces this error:
> 	Unmarshalling XML document failed.
> 		Reason: Error on line 55 of document : The element type
> "content" must be terminated by the matching end-tag "</content>".
> Nested exception: The element type "content" must be terminated by the
> matching end-tag "</content>".
>
> Here's the code:
>
> 	<script type="text/javascript">
> 		//<![CDATA[
> 		var so = new SWFObject(
> 		"/Banner/loader/bannerLoader.swf",
> 		"homepage",
> 		"550", "217",
> 		"7",
> 		"#FFFFFF");
> 		so.addParam("wmode", "transparent");
> so.addParam("allowScriptAccess", "sameDomain");
> so.addVariable("BannerFilePath", "/Banner/bannerConfig.xml");
> 		so.write("SWFBanner");
> 		//]]>
>
> 	</script>
>
> I've narrowed it down to the CDATA sections within the script tags.  If
> I remove that then the page saves correctly, however, I am using the
> xstandard editor so we can guarantee xhtml compliant code so this is not
> really an options for me.
>
> Can anyone suggest a workaround or what I'm doing wrong? I'm using
> OpenCms 7.0.5.
>
> Thanks,
>
> Brock
>
>
>  
> This email is intended only for the addressee. It may contain
> confidential or proprietary information that cannot be disclosed without
> BCLC's permission. If you have received this email in error, please
> notify the sender immediately and delete the email.
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
> visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
>  
> This email is intended only for the addressee. It may contain confidential or proprietary information that cannot be disclosed without BCLC's permission. If you have received this email in error, please notify the sender immediately and delete the email.
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>   




More information about the opencms-dev mailing list