cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: Specifying DOCTYPE
Date Thu, 30 Mar 2000 21:12:33 GMT

Jeremy Quinn wrote:

>Is there any way I can stop this appearing at the top of my rendered HTML
>
>	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" 
>"http://www.w3.org/TR/REC-html40/strict.dtd">
>
>Or at least to specify what type of HTML I am creating.
>
>My HTML is not version 4.0 (strict), some browsers (most notably MSIE 5.0 
>MacOS) choke on this, they display the HTML differently depending on this 
>doctype. In my case it is ignoring the "align" attribute of Table Cells.
>

Same problem here. As far as I can see, you can't right now - although I 
will do a patch in a minute - see below. There are two ways of specifying 
the type of the output:

1. Insert the xsl:output tag at the toplevel of the styleshet, something 
like this:

  <xsl:output method="html" version="4.01"
   doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
   doctype-system="http://www.w3.org/TR/html4/loose.dtd" />

Unfortunately, this doesn't work on Cocoon 1.x, and as far as I can see (I 
am no expert) this is because:

a) Cocoon always asks for the result of an XSLT transformation as a DOM tree 
rather than text, so the XSLT engine ignores the xsl:output tag because it 
is not at the output stage yet. Cocoon does its own outputting, in the 
org.apache.cocoon.formatter packages.

b) Cocoon ignores the xsl:output tag. Is this a bug? Well, if you have a 
page that just applies one stylesheet to itself, no XSP or anything fancy, 
and then gets output, then you might think that Cocoon is acting just as an 
XSLT processor, so it is breaking the XSLT spec by ignoring the xsl:output 
tag. But technically Cocoon is not itself an XSLT processor, rather it wraps 
around real processors like Xalan, so it doesn't have to conform to the XSLT 
spec (it's a bit of an angels-dancing-on-the-head-of-a-pin-type-argument 
IMO).

2. So, cocoon provides its own way of specifying output parameters, the 
<?cocoon-format ?> processing instruction. Unfortunately, if you look at 
org.apache.cocoon.formatter.HTMLFormatter you'll see the doctype tag is 
hardcoded. Bad!! :-)

It looks like "fixing" 1(b) would be very messy, because you'd have to do 
prediction of whether the next processor is going to result in a formatted 
output document, and then ignore the usual cocoon-format stage. And what 
about if there is also a cocoon formatting instruction? Which takes 
priority?

Much better to:

i) Patch the cocoon-format processing instruction with doctype-public and 
doctype-system attributes.
ii) Patch the docs to indicate that xsl-output will be ignored (Otherwise 
people like me will go crazy thinking "What's wrong with my xsl-output tag? 
Is there some really obscure bug in Xalan?" :-)

I will get onto this right away.

--
Robin Green

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Mime
View raw message