Trying to get the string from javax.xml.transform.Source
I have a SOAP client that will submit a string of data to a url and return an xml string back. It works ok besides that last part.
I found on another site someone took the returned XML and printed it to the system print box. I want to just get the string out to a variable to pass back..
This chunk works:
TransformerFactory tff = TransformerFactory.newInstance();
Transformer tf = tff.newTransformer();
Source sc = rp.getSOAPPart().getContent();
StreamResult result = new StreamResult(System.out);
tf.transform(sc, result);
System.out.println();Instead of this I just want to catch the XML string in a String variable. Thanks for the help.
Instead of giving your StreamResult System.out, give it a StringWriter. You can then call toString on the StringWriter, and get what you're after
StringWriter output = new StringWriter();
TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(output));
String xmlResult = output.toString();
Similar Messages
-
Problem with return of javax.xml.transform.Source impl from webService
I have a web services that needs to return an XML string to the calling client. If I return the XML as a String object it gets deserialized twice and the end result is no longer XML. My research indicates that I can return an implementation of javax.xml.transform.Source and this will cause SOAP to attach the XML string to the message rather than embed it (protecting it from deserialization). The following is the effective part of my method:
public Source[] consumeTextMessage(String id) throws RemoteException {
try {
MessageConsumer mc = new MessageConsumer();
String[] messages = mc.consumeTextMessage(id);
StreamSource[] sources = new StreamSource[messages.length];
for(int i = 0; i < messages.length; i++) {
sources[ i ] = new StreamSource();
return sources;
} catch(RemoteException e) {
throw e;
note: the mc.consumeTextMessage(id) call works correctly and I know that I'm not putting anything in the StreamSource objects in the loop to build the array of StreamSource objects - just trying to get SOMETHING to work
so this deploys without problem, but when I try to get a wsdl for the webservice i get a Server 500 error; the log says this:
javax.servlet.ServletException: WSDL Generation exception: java.lang.Exception javax.xml.transform.Source is an abstract class: cannot be instanciated
ok.... if I change the method return type to a concrete class (StreamSource[]), redeploy and try to get a wsdl, I get this absolutely crazy error:
javax.servlet.ServletException: WSDL Generation exception: java.lang.Exception java.io.Reader is an abstract class: cannot be instanciated
I have NO clue why it thinks it needs a Reader.
If I change the method return type to String[] (and make the various adjustments to the method) then it deploys ok and gives me a good WSDL (though it still doesn't work because the Strings are deserialized twice so this isn't a viable solution but it does show that my webservice config is correct).
So... bottom line seems to be that the webService "engine" of 10g AS doesn't like Source or StreamSource.....
Any ideas what I can do??Funny story here: trying to deploy a different webserivce all together and got the same error message; thought I remembered seeing it before but wasn't sure; did a google search on it and lo and behold came across my first posting in this thread.... crazy.
Anyway, I have discovered something that answers some of the questions I had in my first post: It seems that the argument types used in a webservice signature MUST be CONCRETE classes (and I would think primitives would work too though I don't remember trying them) - they can not be Interfaces or abstract classes. Probably if I read the webservices spec it would tell me that.
So the error I was getting before was because Source was not a concrete class, and presumably the second error was caused by some signature somewhere along the line using the Reader abstract class.
Fun stuff. -
Swing: when trying to get the values from a JTable inside an event handler
Hi,
I am trying to write a graphical interface to compute the Gauss Elimination procedure for solving linear systems. The class for computing the output of a linear system already works fine on console mode, but I am fighting a little bit to make it work with Swing.
I put two buttons (plus labels) and a JTextField . The buttons have the following role:
One of them gets the value from the JTextField and it will be used to the system dimension. The other should compute the solution. I also added a JTable so that the user can type the values in the screen.
So whenever the user hits the button Dimensiona the program should retrieve the values from the table cells and pass them to a 2D Array. However, the program throws a NullPointerException when I try to
do it. I have put the code for copying this Matrix inside a method and I call it from the inner class event handler.
I would thank you very much for the help.
Daniel V. Gomes
here goes the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import AdvanceMath.*;
public class MathF2 extends JFrame {
private JTextField ArrayOfFields[];
private JTextField DimOfSis;
private JButton Calcular;
private JButton Ativar;
private JLabel label1;
private JLabel label2;
private Container container;
private int value;
private JTable DataTable;
private double[][] A;
private double[] B;
private boolean dimensionado = false;
private boolean podecalc = false;
public MathF2 (){
super("Math Calcs");
Container container = getContentPane();
container.setLayout( new FlowLayout(FlowLayout.CENTER) );
Calcular = new JButton("Resolver");
Calcular.setEnabled(false);
Ativar = new JButton("Dimensionar");
label1 = new JLabel("Clique no bot�o para resolver o sistema.");
label2 = new JLabel("Qual a ordem do sistema?");
DimOfSis = new JTextField(4);
DimOfSis.setText("0");
JTable DataTable = new JTable(10,10);
container.add(label2);
container.add(DimOfSis);
container.add(Ativar);
container.add(label1);
container.add(Calcular);
container.add(DataTable);
for ( int i = 0; i < 10 ; i ++ ){
for ( int j = 0 ; j < 10 ; j++) {
DataTable.setValueAt("0",i,j);
myHandler handler = new myHandler();
Calcular.addActionListener(handler);
Ativar.addActionListener(handler);
setSize( 500 , 500 );
setVisible( true );
public static void main ( String args[] ){
MathF2 application = new MathF2();
application.addWindowListener(
new WindowAdapter(){
public void windowClosing (WindowEvent event)
System.exit( 0 );
private class myHandler implements ActionListener {
public void actionPerformed ( ActionEvent event ){
if ( event.getSource()== Calcular ) {
if ( event.getSource()== Ativar ) {
//dimensiona a Matriz A
if (dimensionado == false) {
if (DimOfSis.getText()=="0") {
value = 2;
} else {
value = Integer.parseInt(DimOfSis.getText());
dimensionado = true;
Ativar.setEnabled(false);
System.out.println(value);
} else {
Ativar.setEnabled(false);
Calcular.setEnabled(true);
podecalc = true;
try {
InitValores( DataTable, value );
} catch (Exception e) {
System.out.println("Erro ao criar matriz" + e );
private class myHandler2 implements ItemListener {
public void itemStateChanged( ItemEvent event ){
private void InitValores( JTable table, int n ) {
A = new double[n][n];
B = new double[n];
javax.swing.table.TableModel model = table.getModel();
for ( int i = 0 ; i < n ; i++ ){
for (int j = 0 ; j < n ; j++ ){
Object temp1 = model.getValueAt(i,j);
String temp2 = String.valueOf(temp1);
A[i][j] = Double.parseDouble(temp2);What I did is set up a :
// This code will setup a listener for the table to handle a selection
players.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = players.getSelectionModel();
rowSM.addListSelectionListener(new Delete_Player_row_Selection(this));
//Class will take the event and call a method inside the Delete_Player object.
class Delete_Player_row_Selection
implements javax.swing.event.ListSelectionListener
Delete_Player adaptee;
Delete_Player_row_Selection (Delete_Player temp)
adaptee = temp;
public void valueChanged (ListSelectionEvent listSelectionEvent)
adaptee.row_Selection(listSelectionEvent);
in the row_Selection function
if(ex.getValueIsAdjusting()) //To remove double selection
return;
ListSelectionModel lsm = (ListSelectionModel) ex.getSource();
if(lsm.isSelectionEmpty())
System.out.println("EMtpy");
else
int selected_row = lsm.getMinSelectionIndex();
ResultSetTableModel model = (ResultSetTableModel) players.getModel();
String name = (String) model.getValueAt(selected_row, 1);
Integer id = (Integer) model.getValueAt(selected_row, 3);
This is how I got info out of a table when the user selected it -
Little background:
Went to open Itunes, error message told me I was missing files and I was unable to open. I deleted Itunes and re-downloaded and received same message. I then "repaired" Itunes from my "unistall/change" program menu. The error message then changed to being "unable to read my library of music." So I fixed that by following some other forum directions (Went to My Computer/Music/Itunes then dragged the most recent Itunes Library selection to my desktop, then opened the folder under music titled "Previous Itunes library" and moved that file into that folder. Thankfully that worked... sort of... I have some music in my library. None of the music from my super old Limewire library, or any recent music from my phone. All of which was in my library last night. Not to mention the HOURS of cd's I burned to Itunes over the entire weekend. Hundreds (at least) of songs are missing.
So I attempted to sync my phone and was told it would delete all of the files in my phone to replace with files from my computer. Which is NOT what I want to happen. Trying to get music FROM my phone to my computer.
Can someone please help me simply sync my phone to my computer? And then somehow get the music from my Limewire library to my Itunes library? I know I may not get the burned music back... But that sure would be amazing.
I am at a loss. Apple won't help unless I pay them... So hopefully this looks familiar to someone!
Thanks,
KatieThis happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, or that the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout,or vice-versa, and so is looking in slightly the wrong place.
Select a track with an exclamation mark, use Ctrl-I to get info, then cancel when asked to try to locate the track. Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, or a drive letter has changed, it should be possible to reverse the actions.
Alternatively, as long as you can find a location holding the missing files, then you should be able to use my FindTracks script to reconnect them to iTunes .
tt2 -
Getting the string from an NSTextField
Hi there,
I am trying to get and log (to ensure) the text of a text field in my app.
NSString * whatYouSaid;
whatYouSaid = [inputA objectValue];
NSLog (@"%c", whatYouSaid);
//[outputA setObjectValue:whatYouSaid];
This will not log anything. What am I doing wrong?
TIA,
Ricky.And third of all...
since NSLog expects an NSString * as it's first parameter you don't really need to specify a format string.
NSString * whatYouSaid;
whatYouSaid = [inputA stringValue];
// No format string needed if you're logging an NSString *
NSLog(whatYouSaid);
// If you want to include a format string use %@ where your NSString goes
NSLog(@"The value of whatYouSaid is "%@"", whatYouSaid);
// In addition, since [inputA stringValue] returns an NSString * you
// don't even need your variable unless you're going to use
// the variable for some other purpose. You can just log the
// message result directly like this...
NSLog([inputA stringValue]);
// or
NSLog(@"Value of text field is "%@"", [inputA stringValue]);
Steve -
How to get the number from a xml file to flash as3 Text Box "Get_Days"?
Hi,
I have to daily update the number of days finished from the specified days. Say, One work to be finished in 30 days. And the start day is today. So, tomorrow it will be 29 days left. and so on....
So, instead of reducing one number everyday from the last days number using flash, it will be easy changing in xml file.
How can I do that?
I have a simple text box "dynamic text box" and the instance name : "Days_Left". Since I am learner, I cannot make complex projects. I am learning small things with very few lines of code which can be modified using xml files.
So, Whatever I type in a xml file, it should appear in a text box called "Days_Left".
Thanks.then you can use:
var currentDate:Date = new Date();
// this is today's date
var projectDueDate:Date = new Date(2010,11,29);
// use whatever date you want for the due date.
// months are zero-based. (ie, jan is month 0, dec is month 11.)
var daysToCompleteProject:Number = (projectDueDate.getTime()-currentDate.getTime())/(1000*60*60*24);
// this is number of days between currentDate and projectDueDate. you probably want to round or use days:hours:minutes for your display -
what am i spoopsed to type here?!?!?!
Photos taken by and saved to the iPod are included in the backup that iTunes makes evetime you sync or if do a manual or iCloud backup.
Per the following the backup includes:
iTunes: About iOS backups
Camera Roll (Photos, screenshots, images saved, and videos taken. Videos greater than 2 GB are backed up with iOS 4.0 and later.)
Note: For devices without a camera, Camera Roll is called Saved Photos.
Thus if you backed up after the photos were taken yuo can restore an iDevice from that backup -
Hi All,
I am working on Version 12.1.8 Build(20), I have referred SAP notes 1294013 and placed the following files
- serializer.jar
- xalan.jar
- xercesImpl.jar
- xml-apis.jar
- xsltc.jar
in the specified path.
now when i use XSLT transformation block using IllumRowsetTableWithPageBreaks.xsl i am getting an error
[ERROR] [XSL_Transformation_0]XSLTransform error: while trying to invoke the method javax.xml.transform.Transformer.transform(javax.xml.transform.Source, javax.xml.transform.Result) of an object loaded from local variable 'processor'
please guide me.Hi Alex,
No, the case you have explained is not applicable to me. Sharing the code snippet for your reference. This is the code due to which my XSLT gives an error, if I remove these lines of code then the XSLT works fine.
<xsl:variable name="ENERGY" select="translate(ENERGY,',','')">
<xsl:choose>
<xsl:when test="ENERGY= ''">
<xsl:value-of select="0.00"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ENERGY"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Also, the same XSLT works absolutely fine in 12.1 but gives error in 14.0 SP05.
Warm Regards,
Anuj -
Unable to get the data from the stored procedure
Hello Folks,
I have this stored procedure and am trying to get the data from the table stage_bill but for some reason i am not sure its not pulling the data.Am a beginner in pl/sql Can any one please help to find out. I can give the code below.
create or replace procedure Load_FADM_Staging_Area_TEST(p_data_load_date date) is
-- local variables
v_start_date date;
v_end_date date;
-- cursor starting
CURSOR c_get_data
IS
SELECT
a.batch_id
,a.beginning_service_date
,a.bill_id
,a.bill_method
,a.bill_number
,a.bill_received_date
,a.bill_status
,a.bill_type
,a.change_oltp_by
,a.change_oltp_date
,a.client_datafeed_code
,a.client_id
,a.created_date
,a.date_of_incident
,a.date_paid
,a.deleted_oltp_by
,a.deleted_oltp_date
,a.duplicate_bill
,a.ending_service_date
,a.event_case_id
,a.event_id
,a.from_oltp_by
,a.oltp_bill_status
,a.review_status
,'HRI' schema_name
, sysdate Load_date
,'ETLPROCESS001' Load_user
,v_start_date as Row_Effective_Date
,null Row_End_date
from stage_bill a
where
--created_date >= to_date('20101031 235959', 'YYYYMMDD HH24MISS')
created_date >= v_start_date
and
--created_date <= to_date('20101111 235959', 'YYYYMMDD HH24MISS')
created_date <= v_end_date
and not exists
(select
b.batch_id
,b.beginning_service_date
,b.bill_id
,b.bill_method
,b.bill_number
,b.bill_received_date
,b.bill_status
,b.bill_type
,b.change_oltp_by
,b.change_oltp_date
,b.client_datafeed_code
,b.client_id
,b.created_date
,b.date_of_incident
,b.date_paid
,b.deleted_oltp_by
,b.deleted_oltp_date
,b.duplicate_bill
,b.ending_service_date
,b.event_case_id
,b.event_id
,b.from_oltp_by
,b.oltp_bill_status
,b.review_status,
b.schema_name,
b.Load_date,
b.Load_user,
b.Row_Effective_Date,
b.Row_End_Date
from STG_FADM_HRI_STAGE_BILL_TEST b)
-- cursor o/p variables
v_batch_id stage_bill.batch_id%TYPE;
v_beginning_service_date stage_bill.beginning_service_date%TYPE;
v_bill_id stage_bill.bill_id%TYPE;
v_bill_method stage_bill.bill_method%TYPE;
v_bill_number stage_bill.bill_number%TYPE;
v_bill_received_date stage_bill.bill_received_date%TYPE;
v_bill_status stage_bill.bill_status%TYPE;
v_bill_type stage_bill.bill_type%TYPE;
v_change_oltp_by stage_bill.change_oltp_by%TYPE;
v_change_oltp_date stage_bill.change_oltp_date%TYPE;
v_client_datafeed_code stage_bill.client_datafeed_code%TYPE;
v_client_id stage_bill.client_id%TYPE;
v_created_date stage_bill.created_date%TYPE;
v_date_of_incident stage_bill.date_of_incident%TYPE;
v_date_paid stage_bill.date_paid%TYPE;
v_deleted_oltp_by stage_bill.deleted_oltp_by%TYPE;
v_deleted_oltp_date stage_bill.deleted_oltp_date%TYPE;
v_duplicate_bill stage_bill.duplicate_bill%TYPE;
v_ending_service_date stage_bill.ending_service_date%TYPE;
v_event_case_id stage_bill.event_case_id%TYPE;
v_event_id stage_bill.event_id%TYPE;
v_from_oltp_by stage_bill.from_oltp_by%TYPE;
v_oltp_bill_status stage_bill.oltp_bill_status%TYPE;
v_review_status stage_bill.review_status%TYPE;
v_schema_name varchar(50);
v_Load_date date;
v_Load_user varchar(50);
v_Row_Effective_Date date;
v_Row_End_Date date;
Begin
if p_data_load_date is null then
select (sysdate - 7), (sysdate - 1) into v_start_date, v_end_date from dual;
elsif p_data_load_date is not null then
select (p_data_load_date - 7), (p_data_load_date - 1) into v_start_date, v_end_date from dual;
else
raise_application_error('-20042', 'Data control - GetDataControlAuditData : Date parameter must be a date of this or a previous week.');
end if;
-- cursor c_get_data loop begin
OPEN c_get_data;
LOOP -- cursor c_get_data loop begin
FETCH c_get_data
INTO
v_batch_id,
v_beginning_service_date,
v_bill_id ,
v_bill_method ,
v_bill_number,
v_bill_received_date,
v_bill_status,
v_bill_type,
v_change_oltp_by,
v_change_oltp_date,
v_client_datafeed_code,
v_client_id,
v_created_date,
v_date_of_incident,
v_date_paid,
v_deleted_oltp_by,
v_deleted_oltp_date,
v_duplicate_bill,
v_ending_service_date ,
v_event_case_id ,
v_event_id,
v_from_oltp_by,
v_oltp_bill_status,
v_review_status,
v_schema_name,
v_Load_date,
v_Load_user,
V_Row_Effective_Date,
v_Row_End_Date;
EXIT WHEN c_get_data%NOTFOUND;
insert into STG_FADM_HRI_STAGE_BILL_TEST
batch_id
,beginning_service_date
,bill_id
,bill_method
,bill_number
,bill_received_date
,bill_status
,bill_type
,change_oltp_by
,change_oltp_date
,client_datafeed_code
,client_id
,created_date
,date_of_incident
,date_paid
,deleted_oltp_by
,deleted_oltp_date
,duplicate_bill
,ending_service_date
,event_case_id
,event_id
,from_oltp_by
,oltp_bill_status
,review_status
,schema_name
,Load_date
,Load_user
,Row_Effective_Date
,Row_End_Date
values(
v_batch_id,
v_beginning_service_date,
v_bill_id ,
v_bill_method ,
v_bill_number,
v_bill_received_date,
v_bill_status,
v_bill_type,
v_change_oltp_by,
v_change_oltp_date,
v_client_datafeed_code,
v_client_id,
v_created_date,
v_date_of_incident,
v_date_paid,
v_deleted_oltp_by,
v_deleted_oltp_date,
v_duplicate_bill,
v_ending_service_date ,
v_event_case_id ,
v_event_id,
v_from_oltp_by,
v_oltp_bill_status,
v_review_status,
v_schema_name,
v_Load_date,
v_Load_user,
v_Row_Effective_Date,
v_Row_End_Date ) ;
COMMIT;
END LOOP;
CLOSE c_get_data;Maybe you need something else, like
CREATE OR REPLACE PROCEDURE load_fadm_staging_area_test (
p_data_load_date DATE
) IS
v_start_date DATE;
v_end_date DATE;
BEGIN
SELECT NVL (p_data_load_date, SYSDATE) - 7,
NVL (p_data_load_date, SYSDATE) - 1
INTO v_start_date,
v_end_date
FROM DUAL;
MERGE INTO stg_fadm_hri_stage_bill_test b
USING (SELECT *
FROM stage_bill
WHERE created_date BETWEEN v_start_date AND v_end_date) a
ON (b.bill_id = a.billl_id)
WHEN NOT MATCHED THEN
INSERT (batch_id,
beginning_service_date,
bill_id,
bill_method,
bill_number,
bill_received_date,
bill_status,
bill_type,
change_oltp_by,
change_oltp_date,
client_datafeed_code,
client_id,
created_date,
date_of_incident,
date_paid,
deleted_oltp_by,
deleted_oltp_date,
duplicate_bill,
ending_service_date,
event_case_id,
event_id,
from_oltp_by,
oltp_bill_status,
review_status,
schema_name,
load_date,
load_user,
row_effective_date,
row_end_date
VALUES (a.batch_id,
a.beginning_service_date,
a.bill_id,
a.bill_method,
a.bill_number,
a.bill_received_date,
a.bill_status,
a.bill_type,
a.change_oltp_by,
a.change_oltp_date,
a.client_datafeed_code,
a.client_id,
a.created_date,
a.date_of_incident,
a.date_paid,
a.deleted_oltp_by,
a.deleted_oltp_date,
a.duplicate_bill,
a.ending_service_date,
a.event_case_id,
a.event_id,
a.from_oltp_by,
a.oltp_bill_status,
a.review_status,
'HRI',
SYSDATE,
'ETLPROCESS001',
v_start_date,
NULL
END load_fadm_staging_area_test;Whenever you code a cursor and a loop, ask yourself. Do I need that?
Regards
Peter -
How to get the approver from a basic approval
Hi you all,
I am building a custom process which requires a basic approval. When an approver approves or rejects the basic approval in the TODO tab, I need to be able to access the approver's mskey during the process that follows the approval. I have attached a screenshot of where I require the approver's mskey.
Please let me know if you can be of any help!
Thanks!
AnuHi Jai,
I tried to get the approvers from MX_APPROVERS, but when I write to the log, I see that the attribute is undefined.
Here is a snapshot of the destination tab:
Please let me know your thoughts. Right now, the script just approves the attestation and inserts a comment into the link audit table.
Anu -
Get the month from a date column with the calculated column
I am trying to get the month from a date field with the help of calculated column. However I get this syntax error whenever I want to submit the formula:
Error
The formula contains a syntax error or is not supported.
the default language of our site is German and [datum, von] is a date field.Hi,
I have created two columns
Current MM-YY
Calculated (calculation based on other columns)
Today
Date and Time
Current MM-YY is calculated value with formula as
=TEXT(Today,"mmmm")
But the output shows as December instead of May.
I have tried =TEXT([Datum, von];"mmmm") but no help.
I am trying to populated the column automatically with current month..ex: if its May the field should show May, next month it should show June an so on.
Any kind help is grateful.
Regards,
Pradeep -
Hi all
In my other thread "javax.xml.transform." last replied to on 17/04/05, I described that having & in my xml was causing TransformerExceptions when I attempted to apply a stylesheet to the xml.
I've now deployed exactly the same xml, xsl and java on a completely different environment and have found that the error does NOT occur.
This completely baffled me at first, but then I read the following in the API documentation for TransformerFactory: -
"A TransformerFactory instance can be used to create Transformer and Templates objects.
The system property that determines which Factory implementation to create is named "javax.xml.transform.TransformerFactory". This property names a concrete subclass of the TransformerFactory abstract class. If the property is not defined, a platform default is be used.
I think that the key must lie in the system property "javax.xml.transform.TransformerFactory". The two environments must be using a different value for this - one representing a class that objects to & and one that doesn't. In neither case do I actually set this property, so my main question is what does it default to and how can I find out what each environment is using for this?
I'm really baffled here guys, any help would be massively appreciated.
Thank you
Jonjavax.xml.transform.TransformerFactory is a real class implemented by someone. It looks at the system property to figure out what actual implementation to use. It the property doesn't exist, it uses the class that came bundled with the javax.xml.transform.TransformerFactory class you are using.
Here, for instance, is the javax.xml.transform.TransformerFactory that comes with jdk1.4.2
public static TransformerFactory newInstance()
throws TransformerFactoryConfigurationError
try {
return (TransformerFactory) FactoryFinder.find(
/* The default property name according to the JAXP spec */
"javax.xml.transform.TransformerFactory",
/* The fallback implementation class name */
"org.apache.xalan.processor.TransformerFactoryImpl");
} catch (FactoryFinder.ConfigurationError e) {
throw new TransformerFactoryConfigurationError(e.getException(),
e.getMessage());
} -
Javax.xml.transform.TransformerException durin XSL Transformation in Java
Hi,
Below is my piece of code where i access a web service that returns a xml as a string. I apply a xsl tranformation on it and try to store the result as a string. I get this error message
javax.xml.transform.TransformerException: Result object passed to ''{0}'' is invalid.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at NewService.main(NewService.java:52)My Code:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class NewService {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
String endPoint = "http://localhost:8080/SampleDynamicWebProj/services/SampleClient";
Service service = new Service();
Call callOne;
try {
callOne = (Call) service.createCall();
callOne.setTargetEndpointAddress(new URL(endPoint));
callOne.setOperationName(new QName("http://DefaultNamespace",
"getXMLString"));
String concated = (String) callOne.invoke(new Object[] { "s" });
InputStream xsltFile = new FileInputStream("xslpackage/empTran.xsl");
Source xmlSource = new StreamSource(new StringReader(concated));
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
Result result = new StreamResult();
trans.transform(xmlSource, result);
System.out.println(result.toString());
} catch (ServiceException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (TransformerConfigurationException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
}I get the transformed XML into a Result object, but when i do a toString() oon it, i get the above exception.
any help wil be appreciated,
DilipOh well, yes it was a typo in address tag...ok agreed that its a bad example, check this out then,
i have a XML data that i convert to a html format using xsl transformation, now this converted html has to be shown in a html page(i use the out.write option).
so my initial xml looks like this ::
<?xml version="1.0" encoding="ISO-8859-1"?>
<Results>
<ColumnCount>6</ColumnCount>
<Columns>
<column>UID</column>
<column>UserName</column>
<column>Password</column>
<column>LastName</column>
<column>FirstName</column>
<column>EmailAddress</column>
</Columns>
<Rows>
<Row>
<value>1</value>
<value>userone</value>
<value>password-1</value>
<value>Anant</value>
<value>Dilip</value>
<value>[email protected]</value>
</Row>
<Row>
<value>2</value>
<value>usertwo</value>
<value>password-2</value>
<value>Palli</value>
<value>Gilli</value>
<value>[email protected]</value>
</Row>
</Rows>I apply XSL transformation on this to get a HTML which i will be writing into my output screen hoping that the user will see it in a tabular format!
<[!CDATA["
<?xml version="1.0" encoding="UTF-8"?>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">UID</th>
<th align="left">UserName</th>
<th align="left">Password</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">EmailAddress</th>
</tr>
<tr>
<td>1</td>
<td>userone</td>
<td>password-1</td>
<td>Anant</td>
<td>Dilip</td>
<td>[email protected]</td>
</tr>
<tr>
<td>2</td>
<td>usertwo</td>
<td>password-2</td>
<td>Palli</td>
<td>Gilli</td>
<td>[email protected]</td>
</tr>
</table>
"]]>The entire data is passed to a XML parser . I want the transformed xml data (which will be inside a <status></status> tag to be untouched by this parser. As you see i have put the transformed xml in a CDATA tag, but this aint helping me...
need urgent help,
Dilip -
How do I get my entire photo stream to my new iPad. I use my ICloud and some of them showed up but most if them did not. I am trying to sync the photos from my phone to an iPad 1 and iPad mini.
Photostream in the cloud only keeps photos from the last 30 days (subject to a 1,000 photo limit). When photostream syncs the photos to your device they will stay there until deleted, which means you may well have more photos in your photostream album on your device than there are in photostream in the cloud.
The consequence of this is that if you turn photostream off and on again on your device (or enable it for the first time), it will only be populated with photos from the last 30 days, which may not be all the photos that were previously in the photostream album on that device. -
i am trying to display the output from my ipod touch on apple tv. i can get the audio but no video. Thank you for any advice.
What output are you trying to get to your tv?
Maybe you are looking for
-
Hai, we are calling the report using the command line method not run_product.for these reports 'Generate to File' menu is not working.It shows an error like Umimplemented Error (rep-0999).There is one default printer attached to m/c. and the operatio
-
Dear all - I am writing with the confidence that someone will be able to assist me. I am using the Flash Builder Data Services Wizard to access a Server that utilizes REST type calls and returns JSON objects. The server is a JETTY server and it appar
-
My new Macbook Pro is cutting off suddenly and I do not know why
I recently got my Macbook Pro for Christmas and recently it has been cutting off suddenly. I do not know why,
-
I just installed Yosemite on to my MacBook Pro
I just installed Yosemite on to my MacBook Pro and I have noticed that my computer has slowed down, I now start working and all of a sudden, the cursor turns into the little round colored circle and the system "stalls" for a bit. My favorite bookmark
-
How make file association with a sgd application
hi! I need to know, how i make file association from a sgd client. I need open file .doc with a sgd application just make doble click in the file .doc in the client SO: rhel5u1 i have word.desktop file [Desktop Entry] Version=1.0 Encoding=UTF-8 Name=