Ok, then create an HTML5Serializer that extends the current Serializer. An
other solution would be to add a boolean that will output differently for
html5 but I'd prefer extension above a number of if statements.
Jasha
On 6 January 2012 16:56, Robby Pelssers wrote:
> I am using Cocoon2.2 but am planning to switch to C3 in the upcoming
> months. And in my mail I was actually referring to C3. You are right
> about what you write but I’d prefer to have a Serializer which follows the
> spec so I can just copy the output and validate it without errors and too
> many warnings at http://validator.w3.org/****
>
> ** **
>
> Robby****
>
> ** **
>
> *From:* Jasha Joachimsthal [mailto:j.joachimsthal@onehippo.com]
> *Sent:* Friday, January 06, 2012 4:51 PM
> *To:* dev@cocoon.apache.org
> *Subject:* Re: HTML5 serializer****
>
> ** **
>
> Hey Robby,****
>
> ** **
>
> which Cocoon version are you using for your project? In C2.1 and C2.2
> there's not only a XMLSerializer but also an HTMLSerializer and
> XHTMLSerializer for their specific needs. So why not create your own
> HTML5Serializer?****
>
> ** **
>
> In HTML5 the specification teams tried to specify what browsers were
> already doing instead of making a new theoretical specification. HTML5
> should be backwards compatible with previous (X)HTML versions. This is the
> reason why some old elements are not deprecated but considered obsolete
> (remember marquee, it was so cool on Geocities).****
>
> The doctype doesn't really matter, browsers generally ignore the PUBLIC
> part in the doctype (apart from some hacks in IE going into quirks mode).
> ****
>
> A good presentation about HTML5 is http://vimeo.com/15755349.****
>
>
> ****
>
> Jasha Joachimsthal****
>
>
> Europe - Amsterdam - Oosteinde 11, 1017 WT Amsterdam - +31(0)20 522 4466
> US - Boston - 1 Broadway, Cambridge, MA 02142 - +1 877 414 4776 (toll
> free)
>
> www.onehippo.com
>
> ****
>
> On 6 January 2012 15:48, Robby Pelssers wrote:***
> *
>
> Hi all,****
>
> ****
>
> I’ve been looking at how to add a HTML5 serializer to the project.****
>
> ****
>
> So far my investigations have led to add following code to
> org.apache.cocoon.sax.component.XMLSerializer****
>
> ****
>
> public static XMLSerializer createHTML5Serializer() {****
>
> XMLSerializer serializer = new XMLSerializer();****
>
> ****
>
> serializer.setContentType(TEXT_HTML_UTF_8);****
>
> serializer.setDoctypePublic("XSLT-compat");****
>
> serializer.setEncoding(UTF_8);****
>
> serializer.setMethod(HTML);****
>
> ****
>
> return serializer;****
>
> }****
>
> ****
>
> ****
>
> Using the HTML5 serializer in a test to print the output:****
>
> ****
>
> @Test****
>
> public void testHTML5Serializer() throws Exception {****
>
> ByteArrayOutputStream baos = new ByteArrayOutputStream();****
>
> ****
>
> newNonCachingPipeline()****
>
> .setStarter(****
>
> new XMLGenerator("serializer
> testtest
")****
>
> )****
>
> .setFinisher(XMLSerializer.createHTML5Serializer())****
>
> .withEmptyConfiguration()****
>
> .setup(baos)****
>
> .execute();****
>
> ****
>
> String data = new String(baos.toByteArray());****
>
> System.out.println(data);****
>
> }****
>
> ****
>
> Would print****
>
> ****
>
> ****
>
> ****
>
> ****
>
> ****
>
> serializer test****
>
> ****
>
> ****
>
> test
****
>
> ****
>
> ****
>
> ****
>
> ****
>
> I read a number of articles describing the issues with serializing html5
> and so far this was the best I could come up with which is not 100%
> conforming due to ****
>
> · Non matching doctype although it will not break in the browser
> à should be ****
>
> · The charset should be according to
> html5 spec****
>
> ****
>
> ****
>
> http://www.contentwithstyle.co.uk/content/xslt-and-html-5-problems/****
>
> http://www.w3schools.com/html5/tag_meta.asp****
>
> ****
>
> ****
>
> Does anyone have more knowledge on this subject?****
>
> ****
>
> Robby ****
>
> ****
>
> ****
>
> ** **
>