Project

Profile

Help

Identity transform and content type

Added by Anonymous over 16 years ago

Legacy ID: #4574133 Legacy Poster: Andrew Fang (afang4)

This is done using Saxon 8.9. When running an xhtml instance through an identity transform stylesheet, I got the content type (i.e. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />) in the output as expected. However, the content type does not show if running via JAXP. Is this expected? Source xhtml: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title> </head> <body> <h1>Test</h1> </body> </html> The Java Code: public static void main(String[] args) throws Exception { System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); XMLReader reader = XMLReaderFactory.createXMLReader(); Properties props = new Properties(); props.setProperty(OutputKeys.METHOD, "xhtml"); props.setProperty(OutputKeys.ENCODING, "UTF-8"); props.setProperty("include-content-type", "yes"); SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance(); TransformerHandler handler = factory.newTransformerHandler(); handler.getTransformer().setOutputProperties(props); Result result = new StreamResult(System.out); handler.setResult(result); reader.setContentHandler(handler); reader.setDTDHandler(handler); File file = new File(args[0]); InputSource source = new InputSource(new FileInputStream(file)); reader.parse(source); } The identity XSL: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output encoding="UTF-8" method="xhtml" indent="yes" include-content-type="yes"/> <xsl:template match="@|node()"> <xsl:copy> <xsl:apply-templates select="@|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>


Replies (1)

RE: Identity transform and content type - Added by Anonymous over 16 years ago

Legacy ID: #4574224 Legacy Poster: Michael Kay (mhkay)

Thanks, I have logged the bug and there is a fix in Subversion.

    (1-1/1)

    Please register to reply