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