Angus --

I am admittedly treading on thin ice here because I haven't tried your
example and haven't thought it out too thoroughly.  However, I noted
that nobody has answered you yet so I thought I'd give it a stab since
that may be better than nothing.

You're initializing your Serializer with

  Serializer serializer = SerializerFactory.getSerializer
           (OutputProperties.getDefaultMethodProperties("html"));

which doesn't take into account the xsl:output element that's included
in poststylesheet.  Try either (a) using the <xalan:redirect> extension
or (b) doing

  Serializer serializer = SerializerFactory.getSerializer
           (posttransformer.getOutputProperties());

Please let us know what happens.

Gary

> -----Original Message-----
> From: Angus McIntyre [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 17, 2001 11:09 AM
> To: [EMAIL PROTECTED]
> Subject: Can't get DOCTYPE, can't suppress META tag
> 
> 
> I have an application based on Xalan-J 2.2D14, which applies two
> stylesheets in sequence, using code modelled on the Pipe example. The 
> relevant fragment of the code is included at the foot of this message.
> 
> The two stylesheets each start as follows:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>               xmlns:lxslt="http://xml.apache.org/xslt";
>               xmlns:xalan="http://xml.apache.org/xslt";
>               xmlns:xmelissa="com.raingod.XMelissaExtension"
>               extension-element-prefixes="xmelissa"
>               version="1.0">
> 
> <xsl:output
>     method="html"
>     doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
>     
> doctype-system="http://www.w3.org/TR/1999/REC-html401-19991224
> /loose.dtd"
>     xalan:omit-meta-tag="yes"/>
> 
> However, the output HTML documents do not contain the doctype line,
> and they _do_ contain the
> 
>     <META http-equiv="Content-Type" content="text/html;
> charset=UTF-8">
> 
> which I'd very much like to get rid of, as it stops Netscape
> Communicator 4.x from applying the stylesheet (on Macintosh, at 
> least).
> 
> Can anyone point out what I'm doing wrong?
> 
> Thanks in advance,
> 
>       Angus
> 
> Code follows
> 
> ----
> 
>    String media= null , title = null, charset = null;
>     TransformerFactory tfactory = TransformerFactory.newInstance();
>     if (tfactory.getFeature(SAXSource.FEATURE) &&
>         tfactory.getFeature(SAXResult.FEATURE)) {
>        SAXTransformerFactory saxtfactory =
> ((SAXTransformerFactory) tfactory);
> 
>        StreamSource xmlSource = new StreamSource(sourcefile);
>        xmlSource.setSystemId(sourcefile);
>        Source stylesheet = tfactory.getAssociatedStylesheet(xmlSource,
>                                                 media, title,
> charset);
>        TransformerHandler mainhandler =
>            saxtfactory.newTransformerHandler(stylesheet);
>       Transformer maintransformer = mainhandler.getTransformer();
> 
>       StreamSource poststylesheet = new StreamSource((String)
>            settings.get("postprocess"));
>       TransformerHandler posthandler =
>            saxtfactory.newTransformerHandler(poststylesheet);
>       Transformer posttransformer = posthandler.getTransformer();
> 
>       XMLReader reader = XMLReaderFactory.createXMLReader();
>       reader.setContentHandler(mainhandler);
>       
> reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
>                          mainhandler);
>       mainhandler.setResult(new SAXResult(posthandler));
> 
>       Serializer serializer = SerializerFactory.getSerializer
>           (OutputProperties.getDefaultMethodProperties("html"));
>       FileOutputStream outstream = new FileOutputStream(targetfile);
>       serializer.setOutputStream(outstream);
>       posthandler.setResult(new
> SAXResult(serializer.asContentHandler()));
> 
>       reader.parse(sourcefile.getPath());
>       outstream.close();
> 
> -- 
> [EMAIL PROTECTED]                             http://pobox.com/~angus
> 

Reply via email to