![]() |
Java code needed to read/render the XSL |
Post Reply
|
| Author | |
gabig
Admin Group
Joined: 06 Aug 2008 Posts: 144 |
Post Options
Quote Reply
Topic: Java code needed to read/render the XSLPosted: 25 Oct 2010 at 7:08am |
|
Would using a Server Template work for you? It means you would first upload your XFD or XSL template to the server, then let Ultrascale handle the transform server-side.
Also, could you send a sample template to support? Perhaps we can troubleshoot the original issue and see why the template cannot be processed successfully with Java's internal XSL engine. Regards, Gabi Edited by gabig - 25 Oct 2010 at 7:09am |
|
![]() |
|
srivatsahg
Newbie
Joined: 06 Oct 2010 Location: Stuttgart Posts: 36 |
Post Options
Quote Reply
Posted: 25 Oct 2010 at 3:37am |
|
I still face the same issue...
![]() Could you please send me a snippet of the code which 1. Reads a stylesheet from a file location. 2. Sets the Transformation parameters and 3. sets the parameter for Rendering engine. Though im sure of points 2 and 3. I am not sure about the Point 1. Kindly reply Srivatsa |
|
![]() |
|
gabig
Admin Group
Joined: 06 Aug 2008 Posts: 144 |
Post Options
Quote Reply
Posted: 22 Oct 2010 at 4:34am |
|
We have multiple XSLT engines. Are you sure you're using the same in both cases?
In XF Designer, go to the Options dialog, in the XSL Transformations section. Here you can view or change the XSLT engine used by the Designer. Now in your code, you can choose to let Ultrascale perform the transformation using that engine. Use the XsltEngine rendering parameter to set it. Use InputFormat.XML instead of XSLFO to pass the XML stream directly to Ultrascale. The idea here is to let Ultrascale manage the transformation as well. Create a LocalDocumentTemplate from your XSL and set it as the Template parameter. The transformation will be performed client side. Finally, pass the XML stream as the input for the Engine.Render() method. Let me know if you encounter any issues. Regards, Gabi |
|
![]() |
|
srivatsahg
Newbie
Joined: 06 Oct 2010 Location: Stuttgart Posts: 36 |
Post Options
Quote Reply
Posted: 22 Oct 2010 at 3:46am |
|
The same stylesheet works perfectly from the XF designer. But it does not work when i do it programmatically. I dont think its a problem with the XSL.
|
|
![]() |
|
florinv
Admin Group
Joined: 19 May 2008 Posts: 82 |
Post Options
Quote Reply
Posted: 21 Oct 2010 at 3:07pm |
|
If you get a stylesheet compilation error, most likely the error is in the XSL file, not in the JAVA code.Try to validate the XSL in XF Designer.
|
|
![]() |
|
srivatsahg
Newbie
Joined: 06 Oct 2010 Location: Stuttgart Posts: 36 |
Post Options
Quote Reply
Posted: 20 Oct 2010 at 4:51am |
|
Anyone out there to help me
|
|
![]() |
|
srivatsahg
Newbie
Joined: 06 Oct 2010 Location: Stuttgart Posts: 36 |
Post Options
Quote Reply
Posted: 20 Oct 2010 at 3:19am |
|
Hello
I have modified the sample Java snippet provided by Ecrion to my needs. However i get error when i start the transformation using TransformerFactory and i get the error msg as the stylesheet could not be compiled String xmlString; String xslString; File xmlFile = new File("C:/Srivatsa/Reports/Ecrion/DemoReport/Demo.xml"); File xsltFile = new File("C:/Srivatsa/Reports/Ecrion/DemoReport/Demo.xsl"); xmlString = FileUtils.readFileToString(xmlFile); xslString = FileUtils.readFileToString(xsltFile,"utf-8"); InputStream xml = new StringBufferInputStream(xmlString); InputStream xslt = new StringBufferInputStream(xslString); OutputStream outputStream = new FileOutputStream("C:\\XSLTransformation.pdf"); // JAXP reads data using the Source interface Source xmlSource = new StreamSource(xml); Source xsltSource = new StreamSource(xslt); // the factory pattern supports different XSLT processors TransformerFactory transFact = TransformerFactory.newInstance(); Transformer trans = transFact.newTransformer(xsltSource); ByteArrayOutputStream xmlResult = new ByteArrayOutputStream(); trans.transform(xmlSource, new StreamResult(xmlResult)); InputStream inputStream = new StringBufferInputStream(xmlResult.toString()); Engine eng = new Engine(); RenderingParameters rp = new RenderingParameters(); rp.InputFormat = Engine.InputFormat.XSLFO; rp.OutputFormat = Engine.OutputFormat.PDF; eng.Render(inputStream, outputStream, rp); // remember to close the streams inputStream.close(); outputStream.close(); System.out.println("Document rendered successfully!"); Any idea where am i going wrong Vatsa |
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |