XSLT Transformatation under java 1.5


XML & Web services: XSLT Transformatation under java 1.5

  1. XSLT Transformatation under java 1.5 (2 messages)

    Hi All, I have a strange situation with XSLT transformations. I am using a Java code for XML-to-XML transformations for around 600 XML files Under Java 1.4 the transformations are good. But under Java 1.5 not all the files are completely transformed. ......... .......... TransformerFactory factory = TransformerFactory.newInstance(); Templates template = factory.newTemplates(new StreamSource(new FileReader("abc.xsl"))); Transformer transformer = template.newTransformer(); ...... ....... for(int i=0; i < filenames.length; i++) { transformer.transform( new javax.xml.transform.stream.StreamSource( filenamesS), new javax.xml.transform.stream.StreamResult("T-"+filenamesS)); } ........... ......... Let me explain it properly. The code reads each file from the given directory and transformation is performed on that file. Under 1.5 not all the files are completely transformed. Lots of data is missing from the transformed file. No errors or exceptions at all But when I change the code to perform transformations on those specific files the transformation is complete and the result file contains all the data. At first I thought it might be problem due to the different JAXP packages in 1.4 & 1.5 But the problem seems to be something else. Can somebody please help me with what exactly is going wrong in this scenario??

    Threaded Messages (2)

  2. A couple of things to try[ Go to top ]

    I don't know for sure what the issue is, but there are a couple of things you could try: 1. Create each file output stream separately, and then create a StreamResult from it (without losing the reference to the file output stream). Then, after each transformation, flush and close the file output stream. 2. Create a new transformer object inside the main loop, i.e. a separate transformer object for each transformation. Note that JDK 1.5 defaults to using the compiling version of the Xalan XSLT engine, JDK 1.4 doesn't, and so there are significant differences in how each actually processes XSLT transformations. Cheers, Tony. -- Author, XMI APIs chapter, "Advanced XML Applications from the Experts at The XML Guild" http://www.amazon.com/XML-Power-Comprehensive-Guide-Guides/dp/1598632140/
  3. The Step 2 worked[ Go to top ]

    The step 2 worked for me... Thank you !!!!