on 07-23-2010 9:55 PM
Hi experts,
I am developing a Java mapping program for a very specific situation. I chose to do that using SAX API, but I found a problem with that.
The following lines are throwing a ClassCastException during the mapping test in the Enterprise Service Builder (PI 7.1 EHP 4):
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {
try {
InputPayload inputPayload = in.getInputPayload();
InputStream inputStream = inputPayload.getInputStream();
OutputPayload outputPayload = out.getOutputPayload();
OutputStream outputStream = outputPayload.getOutputStream();
// create a TransformerHandler for producing XML output
SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler th = factory.newTransformerHandler();
Result result = new StreamResult(outputStream);
th.setResult(result);
// ...
I copied most of that from [this|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4143] [original link is broken]; article.
After some tests, I realise that the Exception occurs in this line:
SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
I believe that's because the method newInstance is returning something that cannot be converted into a SAXTransformerFactory, but I could not find another way from using the TransformerHandler that not doing so.
Is there anyway to fix that problem? Do you have other samples of SAX mapping?
Thanks anyway.
Experts, the problem was solved using DOM.
Anyway, I will take a look at the tutorials.
Thanks anyway.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my opinion the code in the blog is wrong.
It should not be SAXTransformerFactory but SAXParserFactory
See tutorial of SUN:
http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/jaxp/sax/parsing.html
and a different blog:
/people/sankararao.bhatta/blog/2008/07/27/java-mapping-secrets-revealed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check if you J2EE engine of PI system has those API classes. If not you might have to deploy those classes first or need to use DOM or something else that is available by default.
VJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.