File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program for xml and xsl

 
raj kothari
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an java code which does xml + xsl transform and gives me .html files. This works fine in win xp, however it doesnt work in linux. When running this, in linux, only empty html files are getting created. for information, I have data in xml, style defined in xsl and this code block is small part of full code where i feel is the issue. Please help.

FileOutputStream fos = new FileOutputStream(helpHtmlDir+ helpTreeHtmlFileName + "_" + productId + ".html");

OutputStreamWriter osw = new OutputStreamWriter(fos,Utf8Charset);

BufferedWriter br = new BufferedWriter(osw);

InputStream xmlIs = Thread.currentThread().getContextClassLoader().getResourceAsStream(xmlFileName);

StreamSource xmlSource = new StreamSource(xmlIs);

if (xmlSource != null) {
StringWriter sw = new StringWriter();
StreamResult sr = new StreamResult(sw);
Map params = new HashMap(2);
XSLTransformUtil.doTransform(xmlSource, helpTreeXslFile,sr, params);
br.write(sw.toString());
}

br.close();
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code doesn't do a lot of error checking. What happens if xmlSource == null? Are you sure that the filename you're using is correct, so that getResourceAsStream() can find it?

Add some error checking code.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic