xslfo in a jsp is it possible?
im not sure what i am doing but i want to create a pdf document using apache's FOP. I have added the required jars to the web-inf directory in tomcat, but do you know where i write the xslfo is it in the jsp itself ? ive found examples of how to write xsl-fo but i dont know what file to put them in to test it.
My main interface are jsp files so if i could place them in there would be great i just dont know how?
a xsl-fo example script i found...
http://www.w3schools.com/xslfo/default.asp
<?xml version="1.0" encoding="ISO-8859-1"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello W3Schools</fo:block>
</fo:flow>
</fo:page-sequence></fo:root>
[1180 byte] By [
h1400046a] at [2007-11-26 18:43:46]

# 1
[nobr]Assuming you have installed and configured your environment for
JSTL 1.1
You could use the
<x:transform tag , to transform an XML file with any XSLT file.
In order to use ><x:transform you'll first need to import the XML and XSLT file using ><c:import
JSTL uses Xalan which currently supports only XSLT 1.0 , if you are using XSLT 2.0 .
I tried transforming a sample XML with XSL-FO inside a JSP, but the output is only being printed on the JSP. I wasn't able to generate a PDF file from it.
If the intention is to print something to JSP then I would use plain-old XSLT instead of XSL-FO
Here's the code I tried:
><%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<html>
<head><title>Transforming XML with XSLT inside a JSP</title></head>
<body>
Transforming XML with XSLT inside a JSP
<br/><br/>
<c:import url="/p/test33/some_xml_file.xml" var="xml"/>
<c:import url="/p/test33/some_xslt_file.xsl" var="xsl"/>
<x:transform doc="${xml}" xslt="${xsl}"/>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<title>xyz</title>
<author>Eric</author>
<isbn>124354</isbn>
</book>
<book>
<title>abc</title>
<author>Susan</author>
<isbn>9999</isbn>
</book>
<book>
<title>ggg</title>
<author>Megan</author>
<isbn>5555</isbn>
</book>
</books>
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<!-- Page template goes here -->
Test 1
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<!-- Page content goes here -->
Test 2
</fo:page-sequence>
</fo:root>
Message was edited by:
appy77[/nobr]