Hello,
I am using Xalan 2.3.1 to chain XMLFilter together (similar to the
"UseXMLFilters" example). The parent XMLReader is a custom reader that
generates SAXEvents for a JDBC ResultSet. I would like to control the output
format of the generated data, for example csv and xml, and reading under the
"Usage Patterns" on the site it seems like I should be able to set the output
properties, but I can't get it to work.
Here are some sample code to illustrate what I am doing:
1. Setting up and kicking off the transformation:
...
...
Serializer serializer = SerializerFactory.getSerializer
(OutputProperties.getDefaultMethodProperties("xml"));
serializer.setOutputStream(new FileOutputStream(outputFile));
xmlFilter.setContentHandler(serializer.asContentHandler());
xmlFilter.parse(inputSource);
2. Override the output properties:
When I want to output csv format, the xml declaration should be removed:
<xsl:output xalan:method="text" />
When I want to output xml format, add DTD to the generated XML file:
<xsl:output xalan:doctype-system="system_id" />
These <xsl:output> elements are ignored. I am able to get it working if I
specify the OutputProperties when I create the serializer, but it would be much
more convenient for me if I can do it in the stylesheets.
What am I doing wrong? Does the implementation of my custom XMLReader affect
the overriding of the output properties?
Any feeback is much appreciated. Thanks for your time.
Roger Kjensrud