Roger --

I'm using the examples in the UseXMLFilters example, since I don't have
your exact details.  Instead of 

  XMLFilter xmlFilter3 = saxTFactory.newXMLFilter(new
StreamSource("foo3.xsl"));

on the "last" filter, create a Templates object instead like this:

  Templates template3 = saxTFactory.newTemplates(new
StreamSource("foo3.xsl"));

A Templates object is a "compiled" representation of your foo3.xsl
stylesheet.  Then, get the output properties designated by the foo3.xsl
stylesheet which will incorporate your xsl:output options:

  Properties myProps = template3.getOutputProperties();

Now, you can build your serializer with the proper properties:

  Serializer = SerializerFactory.getSerializer(myProps);

Finally, create your XMLFilter from the same compiled Templates object:

  XMLFilter xmlFilter3 = saxTFactory.newXMLFilter(template3);

And you can continue with your existing code:

  serializer.setOutputStream(new FileOutputStream(outputFile));
  xmlFilter3.setContentHandler(serializer.asContentHandler());
  xmlFilter3.parse(inputSource);

HTH,
Gary
> -----Original Message-----
> From: Roger Kjensrud [mailto:[EMAIL PROTECTED] 
> Sent: Monday, June 17, 2002 1:13 PM
> To: [EMAIL PROTECTED]
> Subject: <xsl:output> values ignored
> 
> 
> 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
> 
> 
> 
> 

Reply via email to