cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael French <mfre...@zycor.lgc.com>
Subject RE: Specifying DOCTYPE
Date Thu, 30 Mar 2000 23:18:55 GMT


> -----Original Message-----
> From: Robin Green [mailto:greenrd@hotmail.com]
> Sent: Thursday, March 30, 2000 3:13 PM
> To: cocoon-dev@xml.apache.org
> Subject: Re: Specifying DOCTYPE
> 
> 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.


> Much better to:
> 
> i) Patch the cocoon-format processing instruction with 
>    doctype-public and doctype-system attributes.

This is good and general (probably useful for SVG and SMIL
and other XML applications), but it makes the PI more 
obscure for the common cases.

Another approach is just to subclass the formatter.
Make HTMLFormatter abstract, with two local abstract methods 
to fetch the doctype fields. Then just have 3 concrete
subclasses, one for each doc type: strict, loose, frameset.

Then change cocoon.properties to read:

formatter.type.text/html            =
org.apache.cocoon.formatter.HTMLLooseFormatter

formatter.type.text/html-loose      =
org.apache.cocoon.formatter.HTMLLooseFormatter
formatter.type.text/html-strict     =
org.apache.cocoon.formatter.HTMLStrictFormatter
formatter.type.text/html-frameset   =
org.apache.cocoon.formatter.HTMLFramesetFormatter

where you can pick your default to be strict or loose.

Mike





public abstract class HTMLFormatter 
    extends AbstractFormatter implements Status 
{    . . .
    public void format(...) throws Exception {
        . . .
        // change doctype instruction
        format.setDoctype( getDoctypePublic(), getDoctypeSystem() );
        . . .
    }
    . . . 
    // add new methods
    protected abstract String getDoctypePublic();
    protected abstract String getDoctypeSystem();
}

// add new classes

public class HTMLFramesetFormatter extends HTMLFormatter {

    protected String getDoctypePublic() {
        return "-//W3C//DTD HTML 4.01 Frameset//EN";
    }
    
    protected String getDoctypeSystem() {
        return "http://www.w3.org/TR/html4/frameset.dtd";
    }
}

public class HTMLLooseFormatter extends HTMLFormatter {

    protected String getDoctypePublic() {
        return "-//W3C//DTD HTML 4.01 Transitional//EN";
    }
    
    protected String getDoctypeSystem() {
        return "http://www.w3.org/TR/html4/loose.dtd";
    }
}

public class HTMLStrictFormatter extends HTMLFormatter {

    protected String getDoctypePublic() {
        return "-//W3C//DTD HTML 4.01//EN";
    }
    
    protected String getDoctypeSystem() {
        return "http://www.w3.org/TR/html4/strict.dtd";
    }
}



Mime
View raw message