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 Ulrich Mayring <ul...@denic.de> on 2001/11/12 19:49:24 UTC

Question on XSLTInputHandler

Hello,

I've looked at the example servlet and found that the XSLTInputHandler
takes as input a java.io.File. However, I am constructing the XML
document dynamically and have it as a java.lang.String in memory. It
seems unnecessary I/O to write it out to a temporary file, just to pass
it to the XSLTInputHandler. Looking at the source of
XSLTInputHandler.java I didn't find any alternate way to call it. What
would the recommended procedure be in this case, where I already have
the XML document in memory?

thanks in advance for any pointers,

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

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


Re: User-config (RE: Question on XSLTInputHandler)

Posted by Jeremias Maerki <je...@outline.ch>.
The problem is that FOP still makes extensive use of static constructs.
The Options class accesses the Configuration class which has static
Hashtables to hold the configuration.

Apart from that the code below should work.

On Mon, 12 Nov 2001 11:31:28 -0800 Ramin Firoozye wrote:
> Since we're on the subject of embedding FOP...
> 
> I still can't figure out how to specify the FOP Driver to load the user
> configuration file from inside a servlet. You need this if you want to have
> your servlet support fonts other than the built-in ones.
> 
> The docs say use something like:
> 
>   Options opt = new Options();
>   opt.loadUserconfiguration("/path-to-user-conf/userconfig.xml");
> 
> But there are no calls on the Driver object (that I can see) to get it to
> use the alternate Options object.
> 
> Any thoughts?
> 
> Ramin

Cheers,
Jeremias Märki

mailto:jeremias.maerki@outline.ch

OUTLINE AG
Postfach 3954 - Rhynauerstr. 15 - CH-6002 Luzern
Fon +41 (41) 317 2020 - Fax +41 (41) 317 2029
Internet http://www.outline.ch


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


Re: User-config (RE: Question on XSLTInputHandler)

Posted by "Peter B. West" <pb...@powerup.com.au>.
Ramin,

When I looked at this code I came to the same conclusion, but I can't 
say that I feel at home in there, so maybe a rabbit is pulled out of the 
hat somewhere.

See also my earlier comments on redesign of options/command-line processing.

Peter

Ramin Firoozye wrote:

> Since we're on the subject of embedding FOP...
> 
> I still can't figure out how to specify the FOP Driver to load the user
> configuration file from inside a servlet. You need this if you want to have
> your servlet support fonts other than the built-in ones.
> 
> The docs say use something like:
> 
>   Options opt = new Options();
>   opt.loadUserconfiguration("/path-to-user-conf/userconfig.xml");
> 
> But there are no calls on the Driver object (that I can see) to get it to
> use the alternate Options object.
> 
> Any thoughts?
> 
> Ramin
> 
> 
>>-----Original Message-----
>>From: Jim Urban [mailto:jim.urban@netsteps.net]
>>Sent: Monday, November 12, 2001 11:08 AM
>>To: fop-dev@xml.apache.org
>>Subject: RE: Question on XSLTInputHandler
>>
>>
>>Here is a block of code our of one my servlets. This code takes a string
>>containing XML, applies an XSL:FO style sheet to it, and runs the XML:FO
>>through FOP and send s the PDF directly back to the browser.
>>
>>Writer      out             = new StringWriter();
>>Transformer pdfTransformer  =
>>NsTransformerCollection.loadTransformer("my.xsl");;
>>String xmlString = .....
>>Source      xmlSource  = new StreamSource(new StringReader(xmlString));
>>pdfTransformer.transform(xmlSource, new StreamResult(out));
>>out.close();
>>String fopstring = out.toString();
>>InputSource foSource = getInput(fopstring);
>>try
>>{
>> ByteArrayOutputStream out = new ByteArrayOutputStream();
>> uResponse.setContentType("application/pdf");
>> Driver driver = new Driver(iInputSource, out);
>> driver.setRenderer(Driver.RENDER_PDF);
>> driver.run();
>> byte[] content = out.toByteArray();
>> uResponse.setContentLength(content.length);
>> uResponse.getOutputStream().write(content);
>> uResponse.getOutputStream().flush();
>> uResponse.flushBuffer();
>>}
>>catch (Exception e){}
>>
>>Jim
>>
>>
>>-----Original Message-----
>>From: ulim@denic.de [mailto:ulim@denic.de]
>>Sent: Monday, November 12, 2001 12:49 PM
>>To: fop-dev@xml.apache.org
>>Subject: Question on XSLTInputHandler
>>
>>
>>Hello,
>>
>>I've looked at the example servlet and found that the XSLTInputHandler
>>takes as input a java.io.File. However, I am constructing the XML
>>document dynamically and have it as a java.lang.String in memory. It
>>seems unnecessary I/O to write it out to a temporary file, just to pass
>>it to the XSLTInputHandler. Looking at the source of
>>XSLTInputHandler.java I didn't find any alternate way to call it. What
>>would the recommended procedure be in this case, where I already have
>>the XML document in memory?
>>
>>thanks in advance for any pointers,
>>
>>Ulrich
>>
>>--
>>Ulrich Mayring
>>DENIC eG, Systementwicklung
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
>>For additional commands, email: fop-dev-help@xml.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
>>For additional commands, email: fop-dev-help@xml.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
> 
> 


-- 
Peter B. West  pbwest@powerup.com.au  http://powerup.com.au/~pbwest
"Lord, to whom shall we go?"


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


no visual tool for FOP?

Posted by Huaxin Zhang <hx...@tango.binary-solutions.net>.
I am wondering if there is no way for users 
to generate WISWIG xsl:fo files? 

like for HTML, users would use Dreamweaver, rather
than writing programs Document doc.addElement(new Table(...)).

I think it should be the same for PDF. Is there
any program that intakes a parsed XHTML and convert it to
PDF?  (I doult all PDF is generated using hand written xsl:fo)...


thanks a lot!



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


User-config (RE: Question on XSLTInputHandler)

Posted by Ramin Firoozye <ra...@wizen.com>.
Since we're on the subject of embedding FOP...

I still can't figure out how to specify the FOP Driver to load the user
configuration file from inside a servlet. You need this if you want to have
your servlet support fonts other than the built-in ones.

The docs say use something like:

  Options opt = new Options();
  opt.loadUserconfiguration("/path-to-user-conf/userconfig.xml");

But there are no calls on the Driver object (that I can see) to get it to
use the alternate Options object.

Any thoughts?

Ramin

> -----Original Message-----
> From: Jim Urban [mailto:jim.urban@netsteps.net]
> Sent: Monday, November 12, 2001 11:08 AM
> To: fop-dev@xml.apache.org
> Subject: RE: Question on XSLTInputHandler
>
>
> Here is a block of code our of one my servlets. This code takes a string
> containing XML, applies an XSL:FO style sheet to it, and runs the XML:FO
> through FOP and send s the PDF directly back to the browser.
>
> Writer      out             = new StringWriter();
> Transformer pdfTransformer  =
> NsTransformerCollection.loadTransformer("my.xsl");;
> String xmlString = .....
> Source      xmlSource  = new StreamSource(new StringReader(xmlString));
> pdfTransformer.transform(xmlSource, new StreamResult(out));
> out.close();
> String fopstring = out.toString();
> InputSource foSource = getInput(fopstring);
> try
> {
>  ByteArrayOutputStream out = new ByteArrayOutputStream();
>  uResponse.setContentType("application/pdf");
>  Driver driver = new Driver(iInputSource, out);
>  driver.setRenderer(Driver.RENDER_PDF);
>  driver.run();
>  byte[] content = out.toByteArray();
>  uResponse.setContentLength(content.length);
>  uResponse.getOutputStream().write(content);
>  uResponse.getOutputStream().flush();
>  uResponse.flushBuffer();
> }
> catch (Exception e){}
>
> Jim
>
>
> -----Original Message-----
> From: ulim@denic.de [mailto:ulim@denic.de]
> Sent: Monday, November 12, 2001 12:49 PM
> To: fop-dev@xml.apache.org
> Subject: Question on XSLTInputHandler
>
>
> Hello,
>
> I've looked at the example servlet and found that the XSLTInputHandler
> takes as input a java.io.File. However, I am constructing the XML
> document dynamically and have it as a java.lang.String in memory. It
> seems unnecessary I/O to write it out to a temporary file, just to pass
> it to the XSLTInputHandler. Looking at the source of
> XSLTInputHandler.java I didn't find any alternate way to call it. What
> would the recommended procedure be in this case, where I already have
> the XML document in memory?
>
> thanks in advance for any pointers,
>
> Ulrich
>
> --
> Ulrich Mayring
> DENIC eG, Systementwicklung
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>


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


RE: Question on XSLTInputHandler

Posted by Jim Urban <ji...@netsteps.net>.
Here is a block of code our of one my servlets. This code takes a string
containing XML, applies an XSL:FO style sheet to it, and runs the XML:FO
through FOP and send s the PDF directly back to the browser.

Writer      out             = new StringWriter();
Transformer pdfTransformer  =
NsTransformerCollection.loadTransformer("my.xsl");;
String xmlString = .....
Source      xmlSource  = new StreamSource(new StringReader(xmlString));
pdfTransformer.transform(xmlSource, new StreamResult(out));
out.close();
String fopstring = out.toString();
InputSource foSource = getInput(fopstring);
try
{
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 uResponse.setContentType("application/pdf");
 Driver driver = new Driver(iInputSource, out);
 driver.setRenderer(Driver.RENDER_PDF);
 driver.run();
 byte[] content = out.toByteArray();
 uResponse.setContentLength(content.length);
 uResponse.getOutputStream().write(content);
 uResponse.getOutputStream().flush();
 uResponse.flushBuffer();
}
catch (Exception e){}

Jim


-----Original Message-----
From: ulim@denic.de [mailto:ulim@denic.de]
Sent: Monday, November 12, 2001 12:49 PM
To: fop-dev@xml.apache.org
Subject: Question on XSLTInputHandler


Hello,

I've looked at the example servlet and found that the XSLTInputHandler
takes as input a java.io.File. However, I am constructing the XML
document dynamically and have it as a java.lang.String in memory. It
seems unnecessary I/O to write it out to a temporary file, just to pass
it to the XSLTInputHandler. Looking at the source of
XSLTInputHandler.java I didn't find any alternate way to call it. What
would the recommended procedure be in this case, where I already have
the XML document in memory?

thanks in advance for any pointers,

Ulrich

--
Ulrich Mayring
DENIC eG, Systementwicklung

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



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