Tobias Kuhn wrote:
> i don't know how to view my xslt result.
Hey, be a bit more creative!

> so i have written a java class with the following code:
>  
> {
> // create XML Tree with project data
>   Document doc = DocumentFactory.getInstance().createDocument();
>   YpiXML ypiXML = new YpiXML(projekt);
>  
>   ypiXML.setFile(outFile);
>   ypiXML.saveProjektDaten(doc, true);
>  
>  OutputStream xmlstream = new ByteArrayOutputStream();
>  ByteArrayInputStream istream = null;
>  String s = "";
>  OutputFormat outFormat = new OutputFormat();
>  outFormat.setEncoding("windows-1252");
>  XMLWriter writer = new XMLWriter(xmlstream,outFormat);
>  writer.write(doc);
>  writer.flush();
>  s = xmlstream.toString();
>  stream = new ByteArrayInputStream(s.getBytes());
> String stemp = istream.toString();
>  istream.close();
> Source strSource = new StreamSource(new StringReader(s));

This is really ugly. Look up javax.xml.transform.dom.DOMSource.

> TransformerFactory transformerFactory = TransformerFactory.newInstance
> ();
>   
> Templates template = transformerFactory.newTemplates(new
> StreamSource(xslFile));
> Transformer transformer = template.newTransformer();
> Driver driver = new Driver();
> driver.setRenderer(driver.RENDER_PDF);
> FileOutputStream fo = new FileOutputStream(outFile);
> driver.setOutputStream(fo);
> Result saxResult = new SAXResult( driver.getContentHandler() );
> transformer.transform( strSource, saxResult );

Omit the driver, and use
  transformer.transform( strSource, new StreamResult(new File("file.fo")));

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to