You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by "Thorsten Scherler (JIRA)" <ji...@apache.org> on 2010/05/17 18:49:42 UTC
[jira] Created: (FOR-1194) Dispatcher does not force UTF-8 usage
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.
[jira] Closed: (FOR-1194) Dispatcher does not force UTF-8 usage
Posted by "Thorsten Scherler (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/FOR-1194?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thorsten Scherler closed FOR-1194.
----------------------------------
Resolution: Fixed
In the end the problem was in the last step that:
Index: ../java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java
===================================================================
--- ../java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java (revision 940483)
+++ ../java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java (working copy)
@@ -374,7 +374,7 @@
}
// get the result of the structurer as stream
InputStream result = structurer.execute(new BufferedInputStream(
- new ByteArrayInputStream(document.getBytes())), requestedFormat);
+ new ByteArrayInputStream(document.getBytes("UTF-8"))), requestedFormat);
// requesting a parser
parser = (SAXParser) manager.lookup(SAXParser.ROLE);
// adding the result to the consumer
Committed revision 945269.
> 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.