You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "M.Weiss" <m....@gmx.net> on 2003/01/08 18:18:39 UTC

Rendering XML /w more than 1024 Bytes impossible ?

Hi everybody,

first... happy new year to everybody, as this is my first posting in 2003...

Again I got a serious problem rendering an XML-Document containing more than
1024 Bytes. The following happens:

I got a Method that takes an XSL-Stylesheet and and XMLDocument as parameter
to generate the PDF-Output as an Byte[]:

-- snip --
 public byte[] createContent(int template, XMLDocument xmlDoc) throws
Exception {

  System.setProperty("org.xml.sax.driver",
"org.apache.xerces.parsers.SAXParser");

  String xslTemplate = "";
  // Template definieren
  switch (template) {
   case 1:
    xslTemplate = "1.xsl";
    break;
   case 2:
    xslTemplate = "2.xsl";
    break;
   case 3:
    xslTemplate = "3.xsl";
    break;
  }

  // OutputStream für binäre Daten der PDF-Datei erzeugen
  ByteArrayOutputStream out = new ByteArrayOutputStream();

  // Driver für den PDF-Renderer initialisieren
  Driver driver = new Driver();
  driver.setOutputStream(out);
  driver.setRenderer(Driver.RENDER_PDF);

  // DOM-Factory laden um XML-Struktur zu parsen
  DOMFactory domFact = new DOMFactory();
  xmlDoc.output(domFact.getOutputStream());

  //XSL-Handler initialisieren
  XSLTInputHandler inputHandler = new XSLTInputHandler(new File(""), new
File(xslTemplate));
  XMLReader parser = inputHandler.getParser();
  driver.setOutputStream(out);

  // XML-Dokument anhand XSL-Definition parsen
  driver.render( parser, new InputSource(new
ByteArrayInputStream(xmlDoc.toString().getBytes())));

  return out.toByteArray();
 }

-- snap --

Now, in the application itself I build up an XMLDocument
(org.apache.ecs.xml.XMLDocument). Rendering this XML-Document was quite good
until now. Suddenly the rendering stopped without any warning, any error or
any comment. When searching for any reason, I tried to have the XML-Document
written on STDOUT by

System.out.writeln(xmlDoc.toString());

Using this it became obvious, that the rendering runs quite fine until the
xmlDoc (represented by it's String on STDOUT) reaches 1024 bytes. Having
1025 bytes it hangs.

Has anybody an idea how to fix this ? I can't imagine that FOP has problems
with more than 1KB of data, or has it ?

Thanks for any help in advance...


Marcus


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


Re: Rendering XML /w more than 1024 Bytes impossible ?

Posted by "J.Pietschmann" <j3...@yahoo.de>.
M.Weiss wrote:


>   // DOM-Factory laden um XML-Struktur zu parsen
>   DOMFactory domFact = new DOMFactory();
>   xmlDoc.output(domFact.getOutputStream());
> 
>   //XSL-Handler initialisieren
>   XSLTInputHandler inputHandler = new XSLTInputHandler(new File(""), new
> File(xslTemplate));
>   XMLReader parser = inputHandler.getParser();
>   driver.setOutputStream(out);
> 
>   // XML-Dokument anhand XSL-Definition parsen
>   driver.render( parser, new InputSource(new
> ByteArrayInputStream(xmlDoc.toString().getBytes())));

It's odd that this code works at all.
See for example
  http://marc.theaimsgroup.com/?l=fop-user&m=104039847419217&w=2
for alternative ideas.
There is also a DOMSource in case you need it. Serializing a DOM
tree to a string and then reparse it is almost always a bad idea.

J.Pietschmann



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