You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Sparkes <pe...@didm.co.uk> on 2007/09/03 18:17:24 UTC

xhtml serialization and form textarea

Hi,

1.    Using CForms I generate a form with a textarea. If I serialize it 
as xml the output is :

 <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
active" rows="10" cols="40"/>

2.    If I serialize it as html the output is :

 <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
active" rows="10" cols="40"></textarea>

which is correct and the form displays correctly

3.    However when I serialize as XHTML 1.0 Strict the xhtml output is:

 <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
active" rows="10" cols="40"/>

which is not correct and the form does not display correctly

Please, how do I get correct xhtml

Thanks

Peter Sparkes



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


Re: xhtml serialization and form textarea

Posted by Peter Sparkes <pe...@didm.co.uk>.
Hi Tobia,

Thanks for your suggestion, I have not had time to try it yet and am 
away for the next few days, will try it when I come back. In the mean 
time Jasha suggestion to use 
org.apache.cocoon.components.serializers.XHTMLSerializer works

Peter
> Peter Sparkes wrote:
>   
>> If I serialize it as html the output is :
>>
>> <textarea ...></textarea>
>>
>> However when I serialize as XHTML 1.0 Strict the xhtml output is:
>>
>> <textarea .../>
>>     
>
> What you say is true and also happens with <div/>, <script/>, and a
> few other elements.  My advice is to avoid the "xhtml" serializer
> altogether, as defined in the root sitemap.  The problem is that it
> outputs XML (in fact it uses the XML serializer) but with a "text/html"
> mime type, and that confuses browsers.
>
> You can either use the "xhtml11" serializer, which is correctly defined
> to output an "application/xhtml+xml" mime type and that means the output
> will be parsed as XML; or use the "html" serializer and work with HTML 4.
>
> What I do is use "xhtml11" on browsers that support XHTML (nearly all)
> and "html" on the legacy ones (IE, wget, lynx):
>
> 	<selector name="accept"
> 	    src="org.apache.cocoon.selection.RegexpHeaderSelector">
> 	  <pattern name="xhtml">application/xhtml\+xml</pattern>
> 	  <header-name>Accept</header-name>
> 	</selector>
>
> ...
>
> 	<select type="accept">
> 	  <when test="xhtml">
> 	    <serialize type="xhtml11"/>
> 	  </when>
> 	  <otherwise>
> 	    <transform src="html-fix.xsl"/>
> 	    <serialize type="html"/>
> 	  </otherwise>
> 	</select>
>
> Notice how it parses the Accept header and thus works on browsers old,
> new, and yet to come, without the need to do user-agent sniffing.
>
> html-fix.xsl adds the following element to <head/>, which is needed in
> legacy mode but does harm in XHTML mode:
>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>
>
> HTH
> Tobia
>
> ---------------------------------------------------------------------
> 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: xhtml serialization and form textarea

Posted by Tobia Conforto <to...@linux.it>.
Peter Sparkes wrote:
> If I serialize it as html the output is :
>
> <textarea ...></textarea>
>
> However when I serialize as XHTML 1.0 Strict the xhtml output is:
>
> <textarea .../>

What you say is true and also happens with <div/>, <script/>, and a
few other elements.  My advice is to avoid the "xhtml" serializer
altogether, as defined in the root sitemap.  The problem is that it
outputs XML (in fact it uses the XML serializer) but with a "text/html"
mime type, and that confuses browsers.

You can either use the "xhtml11" serializer, which is correctly defined
to output an "application/xhtml+xml" mime type and that means the output
will be parsed as XML; or use the "html" serializer and work with HTML 4.

What I do is use "xhtml11" on browsers that support XHTML (nearly all)
and "html" on the legacy ones (IE, wget, lynx):

	<selector name="accept"
	    src="org.apache.cocoon.selection.RegexpHeaderSelector">
	  <pattern name="xhtml">application/xhtml\+xml</pattern>
	  <header-name>Accept</header-name>
	</selector>

...

	<select type="accept">
	  <when test="xhtml">
	    <serialize type="xhtml11"/>
	  </when>
	  <otherwise>
	    <transform src="html-fix.xsl"/>
	    <serialize type="html"/>
	  </otherwise>
	</select>

Notice how it parses the Accept header and thus works on browsers old,
new, and yet to come, without the need to do user-agent sniffing.

html-fix.xsl adds the following element to <head/>, which is needed in
legacy mode but does harm in XHTML mode:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


HTH
Tobia

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


Re: xhtml serialization and form textarea

Posted by Peter Sparkes <pe...@didm.co.uk>.
Hi Jasha,

The Class is org.apache.cocoon.serialization.XMLSerializer. The version 
is whatever comes with cocoon 2.1.10

Doing something like:

<textarea ......>-</textarea>

does not work as the <textarea .. is generated from

<ft:widget id="lodge">
      <fi:styling  type="textarea" rows="10" cols="40"/>
 </ft:widget>

by the forms styling and I can't work out how to change the stylesheets

Peter
> peter@didm.co.uk>
>
> Hi Peter,
>
> which serializer are you using (both class and version)?
> As workaround you can put a   in the textarea if your version of the XHTMLSerializer closes the textarea element (not very nice).
>
> Jasha
>
>
> -----Original Message-----
> From:	Peter Sparkes [mailto:peter@didm.co.uk]
> Sent:	Mon 9/3/2007 6:17 PM
> To:	users@cocoon.apache.org
> Cc:	
> Subject:	xhtml serialization and form textarea
>
> Hi,
>
> 1.    Using CForms I generate a form with a textarea. If I serialize it 
> as xml the output is :
>
>  <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
> active" rows="10" cols="40"/>
>
> 2.    If I serialize it as html the output is :
>
>  <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
> active" rows="10" cols="40"></textarea>
>
> which is correct and the form displays correctly
>
> 3.    However when I serialize as XHTML 1.0 Strict the xhtml output is:
>
>  <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
> active" rows="10" cols="40"/>
>
> which is not correct and the form does not display correctly
>
> Please, how do I get correct xhtml
>
> Thanks
>
> Peter Sparkes
>
>
>
>   


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


RE: xhtml serialization and form textarea

Posted by Jasha Joachimsthal <j....@hippo.nl>.
peter@didm.co.uk>

Hi Peter,

which serializer are you using (both class and version)?
As workaround you can put a   in the textarea if your version of the XHTMLSerializer closes the textarea element (not very nice).

Jasha


-----Original Message-----
From:	Peter Sparkes [mailto:peter@didm.co.uk]
Sent:	Mon 9/3/2007 6:17 PM
To:	users@cocoon.apache.org
Cc:	
Subject:	xhtml serialization and form textarea

Hi,

1.    Using CForms I generate a form with a textarea. If I serialize it 
as xml the output is :

 <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
active" rows="10" cols="40"/>

2.    If I serialize it as html the output is :

 <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
active" rows="10" cols="40"></textarea>

which is correct and the form displays correctly

3.    However when I serialize as XHTML 1.0 Strict the xhtml output is:

 <textarea title="" name="enjoy" id="enjoy:input" class="forms field 
active" rows="10" cols="40"/>

which is not correct and the form does not display correctly

Please, how do I get correct xhtml

Thanks

Peter Sparkes



---------------------------------------------------------------------
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