File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Question Mark's appearing in MS word document Generated using XML, XSL FO and jFor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Question Mark Watch "Question Mark New topic

Question Mark's appearing in MS word document Generated using XML, XSL FO and jFor

Mohan Mani

Joined: Sep 02, 2004
Posts: 16
Hi all,
We are getting a strange problem while generating a word document (*.rtf) and displaying that in the client browser.
In offshore , we are using SunOne ApplicationServer 7 on Windows 2000 and we are not facing any Problem.
In Onsite , its on SunOne ApplicationServer 7 on SunSolaris and we are getting the problem over there.

The final XML has
<?xml version='1.0' encoding='ISO-8859-1'?>
<![CDATA[Address 1#4]]> - CDATA Enclosed for all the data.

We are follwing the below steps to generate the .rtf Document.

1> Fetch the XML from the from the database which is in a CLOB format.
2> Convert that to XML using to an user defined object using xerces DOMParser.
3> Transforming the XML and XSL using xmlParserAPIs.
4> Converting that to RTF documet using jFor CmdLineConverter.
5> Flusing the content into Response.

We are also getting "?" in the
pls find the code below.
StringBuffer strFinalXml = getFinalXMLStringForPublish(documentObj);

File xslFile = new File(ETClsWebAppProperties.getProperty(ETClsWebAppProperties.XSL_FOR_RTF));
Source xslSource = new StreamSource(xslFile);
Source xmlSource = new StreamSource(new StringReader(strFinalXml.toString()));
logWriter.fatal("complete xml file " + strFinalXml.toString());
TransformerFactory transformFact = TransformerFactory.newInstance();
//store result here
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
Result result = new StreamResult(outStream);
Transformer trans = transformFact.newTransformer(xslSource);
trans.transform(xmlSource, result);

logWriter.fatal("OutPut Stream - 1 " + outStream.toString());
ByteArrayInputStream bInputStream = new ByteArrayInputStream(outStream.toByteArray());

logWriter.fatal("OutPut Stream - 2 " + outStream.toString());

CmdLineConverter rtfGenerator = new CmdLineConverter();
outStream = (ByteArrayOutputStream)rtfGenerator.rtfConverter(bInputStream);
logWriter.fatal("OutPut Stream - 3 " + outStream.toString());

// set the content disposition .
response.setHeader("Content-Disposition", "inline;filename=Document" + objSelectedListDocument.getDispDocumentNo() + "-" + objSelectedListDocument.getDispRevId() + ".rtf");
OutputStream resOS = response.getOutputStream();
ByteArrayInputStream bis = new ByteArrayInputStream(outStream.toByteArray());
byte[] arr = new byte[1024];
int size =;
while (size != -1) {
resOS.write(arr, 0, size);
size =;

} // if wording generated

Can anyone help us in the above regards.

Mohan Mani
I agree. Here's the link:
subject: Question Mark's appearing in MS word document Generated using XML, XSL FO and jFor
It's not a secret anymore!