You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by hussayn <hu...@saxess.com> on 2008/08/26 12:38:25 UTC

how can i force a serialiser to generate a -tag even if the body is empty ?

Hi;

i am experimenting with dojo and i got an expression like this inside my
sourcefile:

	    <script type="text/javascript"
src="servlet:dojo:/resource/external/dojo/dojo/dojo.js"
	     djConfig="parseOnLoad:true, isDebug:true"></script>

After serialising to xhtml, the output contains:

	    <script type="text/javascript"
src="/dojo/resource/external/dojo/dojo/dojo.js"
	     djConfig="parseOnLoad:true, isDebug:true"/>

which is absolutely perfect... but for some reason the web browser (or dojo)
needs the closing "</script>" although the script tag does not contain any
content...

I did not find any configuration parameter in cocoon, so i just added a fake
entry into the scripts body:

	    <script type="text/javascript"
src="servlet:dojo:/resource/external/dojo/dojo/dojo.js"
	     djConfig="parseOnLoad:true, isDebug:true">&#160;</script>

That worked and now dojo (or my browser, or both???) seems to be happy.

But i don't like this hack very much. So how can i force cocoon (probably
the xhtml-serialiser ?) to create a tag-pair around an empty body ?

-- 
View this message in context: http://www.nabble.com/how-can-i-force-a-serialiser-to-generate-a-%3C-close%3E-tag-even-if-the-body-is-empty---tp19158791p19158791.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how can i force a serialiser to generate a -tag even if the body is empty ?

Posted by Andre Thenot <an...@thenot.org>.
On Sep 24, 2008, at 12:01, Rainer Pruy wrote:

> This "closing tag" issue is usually related to mixing html vs. xhtml
> and browsers that are not precise with handling both.
>
> Probably your are using xhtml serializer while indicating a HTML doc  
> type to the browser
> (evtl. implied by providing a ".html" suffix to the url?).
>
> You might want to play around with combinations of serializer  
> settings and doctypes (and mime types generated or extensions  
> indicated
> to the browser). But beware, this might effect other areas of your  
> pages.....

Hmm... I'm using the XML serializer, no URL suffix and an XHTML-strict  
doctype. I'm not aware of an XHTML serializer.

       <map:serializer name="xhtml" mime-type="text/html"  
src="org.apache.cocoon.serialization.XMLSerializer">
         <map:doctype-public>-//W3C//DTD XHTML 1.0 Strict//EN</ 
map:doctype-public>
         <map:doctype-system>http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd 
</map:doctype-system>
         <map:omit-xml-declaration>yes</map:omit-xml-declaration>
         <map:encoding>UTF-8</map:encoding>
       </map:serializer>

Basically I try to be the strictest possible to avoid triggering the  
quirks-mode of certain browsers...

A.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how can i force a serialiser to generate a -tag even if the body is empty ?

Posted by Rainer Pruy <Ra...@Acrys.COM>.
This "closing tag" issue is usually related to mixing html vs. xhtml
and browsers that are not precise with handling both.

Probably your are using xhtml serializer while indicating a HTML doc type to the browser
(evtl. implied by providing a ".html" suffix to the url?).

You might want to play around with combinations of serializer settings and doctypes (and mime types generated or extensions indicated
to the browser). But beware, this might effect other areas of your pages.....


Rainer

Andre Thenot schrieb:
> On Aug 26, 2008, at 6:38, hussayn wrote:
> 
> <snip/>
>> which is absolutely perfect... but for some reason the web browser (or
>> dojo)
>> needs the closing "</script>" although the script tag does not contain
>> any
>> content...
>>
>> I did not find any configuration parameter in cocoon, so i just added
>> a fake
>> entry into the scripts body:
>>
>>         <script type="text/javascript"
>> src="servlet:dojo:/resource/external/dojo/dojo/dojo.js"
>>          djConfig="parseOnLoad:true, isDebug:true">&#160;</script>
>>
>> That worked and now dojo (or my browser, or both???) seems to be happy.
>>
>> But i don't like this hack very much. So how can i force cocoon (probably
>> the xhtml-serialiser ?) to create a tag-pair around an empty body ?
> 
> Thanks for your post, I just got bitten by that bug too.
> I guess when using forms, it's necessary to add a transformation at the
> end to insert the hack:
> 
>   <xsl:template match="script">
>     <script>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates select="text()"/>
>       <xsl:text>&#160;</xsl:text>
>     </script>
>   </xsl:template>
> 
> This is a bug only in Mozilla and IE, AFAIK. Safari is fine with
> self-closing <script/> tags but helpfully warns about other browsers.
> 
> A.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how can i force a serialiser to generate a -tag even if the body is empty ?

Posted by Andre Thenot <an...@thenot.org>.
On Aug 26, 2008, at 6:38, hussayn wrote:

<snip/>
> which is absolutely perfect... but for some reason the web browser  
> (or dojo)
> needs the closing "</script>" although the script tag does not  
> contain any
> content...
>
> I did not find any configuration parameter in cocoon, so i just  
> added a fake
> entry into the scripts body:
>
> 	    <script type="text/javascript"
> src="servlet:dojo:/resource/external/dojo/dojo/dojo.js"
> 	     djConfig="parseOnLoad:true, isDebug:true">&#160;</script>
>
> That worked and now dojo (or my browser, or both???) seems to be  
> happy.
>
> But i don't like this hack very much. So how can i force cocoon  
> (probably
> the xhtml-serialiser ?) to create a tag-pair around an empty body ?

Thanks for your post, I just got bitten by that bug too.
I guess when using forms, it's necessary to add a transformation at  
the end to insert the hack:

   <xsl:template match="script">
     <script>
       <xsl:apply-templates select="@*"/>
       <xsl:apply-templates select="text()"/>
       <xsl:text>&#160;</xsl:text>
     </script>
   </xsl:template>

This is a bug only in Mozilla and IE, AFAIK. Safari is fine with self- 
closing <script/> tags but helpfully warns about other browsers.

A.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org