User-config (RE: Question on XSLTInputHandler)

2001-11-12 Thread Ramin Firoozye

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:[EMAIL PROTECTED]]
> Sent: Monday, November 12, 2001 11:08 AM
> To: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 12, 2001 12:49 PM
> To: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


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




RE: xslt and number formats

2001-11-29 Thread Ramin Firoozye

Hi Brian,

I tried your code in Xalan (C and J) and MSXML and got '2.79' (with the
digits after decimal point intact). The XSLT spec says that numbers are kept
in double format internally so you shouldn't be getting any truncation loss
as a result of doing math. The 'sum' function is also supposed to keep
numbers in their original format. The only culprit may be the xsl:value-of
instruction (although on my system, it's working fine). You might want to
try to force a format using something like:



The '#' characters default to the formatting scheme defined in the JDK 1.1
java.text.DecimalFormat class

.

Hope this helps,
Ramin

>
>
> Sorry this is probably not the most appropriate forum, but I have looked
> everywhere I can think of. If anyone on this list can point me in
> the right
> direction I would be grateful.
> Thanks,
> Brian
> - Original Message -
> From: "Brian T. Wolf" <[EMAIL PROTECTED]>
> Newsgroups: comp.text.xml
> Sent: Tuesday, November 27, 2001 2:04 PM
> Subject: xslt and number formats
>
>
> > OK, I am at my wits' end. I have looked at various sites, specs, and
> > FAQ's, and I just am not getting an understanding of number
> > formatting. I am using templates to transform my XML data into a table
> > after which I will have column totals. I am using the sum() function
> > and the math seems to be working as expected - with one minor hitch:
> > the decimals are being truncated. Since I am printing invoices dealing
> > with currency it is essential that the decimals remain down to the
> > penny. Can someone explain this in clear English for me, or else point
> > me somewhere I may not have yet seen?
> >
> > sample XML:
> > 
> >  
> >   Federal Excise Tax
> >   2.25
> >  
> >  
> >   State 911 Emergency Tax
> >   0.54
> >  
> > 
> >
> > sample XSL:
> > 
> >  
> >  
> >   
> >
> > 
> >
> >   
> >  
> >  
> > 
> >
> > I am using xalan-2.0.0 for the transformation, if that makes a
> > difference.
> >
> > Thanks much,
> > Brian
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


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




RE: Page Breaks

2001-12-04 Thread Ramin Firoozye

Hi Jim,

Sounds like a text-replace is called for. A few questions:

- Do you have the opportunity to pre-process the goods via Java/sed/perl or
something like that? That would be the easiest way to do a text replace
before you even get to the XSLT processor.

- You might need to tweak the XML encoding to be able to handle the ASCII
form-feed character un-escaped. Depends on the parser you're using.

- If your environment allows it you can also invoke XSLT extension functions
to do the replacement.

- Have you thought of trying the contains(), substring-before() and
substring-after() functions recursively to try to locate and extract the
text surrounding the form-feed character? It won't be pretty but if you
*must* stay in XSLT, it's pretty much your only choice.

Just some ideas...

Ramin

>
> How would I code my XSL to scan a text element for form feeds and insert a
> "" and the corresponding
> "" at the
> correct places?
>
> Jim
>
> -Original Message-
> From: Vladimir Sneblic [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 03, 2001 4:13 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Page Breaks
>
>
> Try using break-before="page" property of fo:block something like:
>
>  The text to appear on the next
> page
>
> I think you can leave it empty (i.e. a block with no content), and use it
> purely as a page break mechanism.
>
> Have fun,
>
> Vlad
>
>
>
>-Original Message-
>   From:   Jim Urban [mailto:[EMAIL PROTECTED]]
>   Sent:   Tuesday, 4 December 2001 11:07 a.m.
>   To: FOP Dev
>   Subject:Page Breaks
>
>   I have a servlet which dynamically generates XML which is
> then translated into FO and ran through FOP to generate PDFs.  What can I
> embed (like a "\f") in the XML text that will cause FOP to automatically
> start a new page?
>
>   Thanks,
>
>   Jim Urban
>   Product Manager
>   Netsteps Inc.
>   Suite 505E
>   1 Pierce Pl.
>   Itasca, IL  60143
>   Voice:  (630) 250-3045 x2164
>   Fax:  (630) 250-3046
><< File: ATT70001.txt >>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>


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