Dispatcher does not force UTF-8 usage
-------------------------------------
Key: FOR-1194
URL: https://issues.apache.org/jira/browse/FOR-1194
Project: Forrest
Issue Type: Bug
Components: Whiteboard: Dispatcher (stax)
Reporter: Thorsten Scherler
Priority: Critical
There is a problem in the dispatcher which seems only occur in Windows and Mac.
In linux it is working fine.
If you create a contract and add e.g. ¿ñÜí which is
something like ü ñ ¿ it will become ¬ø√±√ú√≠
I am investigating since 2 days now and I identify the following code where the
encoding get lost in Mac os. Actually everything that goes into the
transformation is utf-8. after the transformer.transform(saxSource,
streamResult); it is lost.
XSLContractHelper.java
public void transform(InputStream dataStream, Result streamResult)
throws ContractException {
//Source dataSource = new StreamSource(dataStream);
try {
InputSource inputSource = new InputSource(new
InputStreamReader(dataStream, "UTF-8"));
inputSource.setEncoding("UTF-8");
SAXSource saxSource = new SAXSource(xmlReader,inputSource);
transformer.transform(saxSource, streamResult);
} catch (Exception e) {
String message = "The xsl transformation has thrown an exception. for "
+ "the contract \""+name+"\".\nPlease see some FAQ:"
+ "\n"
+ e
+ "\n\nproblem->solution:\n"
+ "- org.apache.xpath.XPathException: Can not convert #STRING to a
NodeList!\n"
+ "-> Try to activate \"allowXml\" and/or \"shrink\". If this is not
working try the contract "
+ "xsl standalone and make sure it is not a xsl specific problem.";
throw new ContractException(message);
}
}
This method is invoked from XSLContract.java, The out.toString is scrampled:
public BufferedInputStream execute(InputStream dataStream,
Map<String, Object> properties) throws ContractException {
...
ByteArrayOutputStream out = new ByteArrayOutputStream();
// create a StreamResult and use it for the transformation
try {
OutputStreamWriter writer = new OutputStreamWriter(out,"UTF-8");
Result streamResult = new StreamResult(writer);
helper.transform(dataStream,streamResult);
} catch (Exception e) {
String message = "Could not invoke the transformation for "
+ "the contract \""+name+"\". "+"\n"+ e;
throw new ContractException(message);
}
log.debug(out.toString());
...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.