tags:

views:

93

answers:

2

Hi,

Are there any XSLT parsers (like MSXML 4.0) helping to retrieve the XSL FO document during the XSL-Transformaion Process ?

In other words, how do I get a XSL FO file from a XML and XSL file ?

Thanks, Aiwee

+3  A: 

You can't automatically.

The original XSL specification was split in to 3 seperate specifications:

  1. transformations (XSLT)
  2. formatting/display documents (XSL:FO)
  3. querying xml (XPATH)

XSL:FO should be seen as a way to describe documents in XML. XSLT can help you generate such an XML structure but it won't do so automatically.

The flow is as followed:

XML input => XSLT => XML output.

XSL:FO is XML output nothing more nothing less.

The flow is not

XML input => XSLT => XML output & XSL:FO.

I think the root of the confusion stems from the fact that the term XSL encompasses XSLT/XSLFO & XPATH yet often XSL is used as a synonym for XSLT.

w3schools has a section on how these two seperate specifications can aid one another:

http://www.w3schools.com/xslfo/xslfo_xslt.asp

Martijn Laarman
xlm:FO is just as well an xml document and can be generated.
pvgoddijn
Of course, I'm aware and my answer reflects that. His question seems to suggests that if you have any XML and any XSLT how do you get the an XSLFO out of it. Where in fact the XSLT should generate the XSLFO.
Martijn Laarman
i guess we misunderstood each other, apologies.
pvgoddijn
No probem, not sure if your the one who downvoted me but it would be friendly if you undo'd it :)
Martijn Laarman
i did but cant undo till post is edited, so maybe add some white-space :)
pvgoddijn
A: 

you can use a simple xml transform for this.

for example:

Source source = new StreamSource(new File("imput.xml"));
Source style = new StreamSource(new FileInputStream("style-fo.xsl"));       
TransformerFactoryImpl saxon = new TransformerFactoryImpl();
Transformer transformer = saxon.newTransformer();
transformer.transform(source, new StreamResult(System.out));

transforms the in.xml document with the xsl-fo style sheet into xml-fo and prints in on the console.

pvgoddijn