You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Tobias Kuhn <tk...@mailserv.rz.fh-muenchen.de> on 2002/10/02 15:54:22 UTC

AW: AW: large tables loop problem

Hello,
 
i don't know how to view my xslt result.
i am working on a project , where all the data of the software can be
saved to xml...
now i want to create a pdf report file out of the xml data, and i only
provide and xsl file with FO tags.
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));
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 );

driver.reset();
fo.flush();
fo.close();
}

This works very well, i only have to provide an xsl File that contains
the information, which data of the xml file should be shown in the pdf.
when a table larger than one pdf (A4) page has to be created, the
endless loop appears. otherwise it runs with no problem...
 
As i am really new to FOP, any hints are welcome,
 
regards, 
 
T. Kuhn
 
 -----Ursprüngliche Nachricht-----
Von: J.Pietschmann [mailto:j3322ptm@yahoo.de] 
Gesendet: Montag, 30. September 2002 21:53
An: fop-dev@xml.apache.org
Betreff: Re: AW: large tables loop problem



Tobias Kuhn wrote: 
> This is the part of the code creating the tables which will not fit in

> one page in some cases... 

I can't reproduce the problem. 

Posting snippets form the XSLT is unwise, you should post 
the result of the XSL transformation, after trimming it 
to the part which actually demonstrates the problem, and 
perhaps anonymizing company data. 

I guess you'll spot the problem yourself when looking 
at the XSLT result. 

J.Pietschmann 


--------------------------------------------------------------------- 
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org 
For additional commands, email: fop-dev-help@xml.apache.org 


Re: AW: AW: large tables loop problem

Posted by "J.Pietschmann" <j3...@yahoo.de>.
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: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org