You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Angus McIntyre <an...@pobox.com> on 2001/11/06 15:42:24 UTC

Serializer ate my DOCTYPE?

I've just converted an app I'm writing from using a simple 
transformer (as in the UseStylesheetPI example) to using a chain of 
transformers (as in the Pipe example). Everything works fine, except 
for one small problem: the DOCTYPE (as specified in the <xsl:output/> 
element no longer seems to get written out.

Here, trimmed to a minimum, is the relevant code:

	StreamSource xmlSource = new StreamSource(sourcefile);
	xmlSource.setSystemId(sourcefile);
	Source stylesheet =
	tfactory.getAssociatedStylesheet(xmlSource, media, title, charset);
	TransformerHandler mainhandler =
		saxtfactory.newTransformerHandler(stylesheet);

	XMLReader reader = XMLReaderFactory.createXMLReader();
	reader.setContentHandler(mainhandler);
	reader.setProperty("http://xml.org/sax/properties/lexical-handler",
			   mainhandler);

	Serializer serializer = SerializerFactory.getSerializer
		(OutputProperties.getDefaultMethodProperties("html"));
	serializer.setOutputStream(new FileOutputStream(targetfile));
	mainhandler.setResult(new SAXResult(serializer.asContentHandler()));

Can anyone suggest what needs to be added to get my DOCTYPE back 
again? (I'd also like to choose the serializer based on the 
<xsl:output/>, but that's a refinement I can add later).

Thanks in advance

Angus
-- 
angus@pobox.com                             http://pobox.com/~angus