473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Does it mean source and result should both be either DOM or Stream or SAX and not mixed?

Hi all,
I intend to retrieve the fault node as a a string from the soap
message. When i used transform(DOMSource,StreamResult) i get just the
<?xml version="1.0" encoding="UTF-8"?>
as string. but when i use transform(StreamSource,StreamResult) i get
the expected String of fault Node.
where am i wrong?. transform(DOMSource,StreamResult) and
transform(StreamSource,StreamResult) are they different . Does it mean
source and result should both be either DOM or Stream or SAX and not
mixed?
See information below
public String doSerialization(Message soapMsg)
{
StreamSource sourceXSL=new
StreamSource(Thread.currentThread().getClass()
.getClassLoader().getResourceAsStream("de/
AxisFaultProcessor.xsl"));

DOMSource domSource=new
DOMSource(soapMsg.getSOAPEnvelope().getAsDocument( ));

ByteArrayOutputStream out=new ByteArrayOutputStream();

StreamResult streamResult=new StreamResult(out);

TransformerFactory transformerFactory
=TransformerFactory.newInstance();

Transformer transformer
=transformerFactory.newTransformer(sourceXSL);

transformer.setParameter("action",
"serializeAxisFaultFromSOAPEnvelope");
transformer.setOutputProperty("method", "xml");
transformer.transform(domSource, streamResult);

return out.toString();
}


/// XSL below

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<xsl:param name="action" />
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$action='serializeAxisFaultFromSOAPEnvelope' ">
<xsl:copy-of select="soap:Envelope/soap:Body/soap:fault"/>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

Mar 1 '07 #1
8 1785
moralbarometer wrote:
When i used transform(DOMSource,StreamResult)
Mixing these should be no problem, so I'm presuming the error is
something else, such as a DOM that isn't providing information this XSLT
processor needs.

Are you absolutely sure soapMsg is a namespace-aware DOM Level 2 DOM
instance? (That is, do the elements have namespaces and localnames, or
only node names?)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 1 '07 #2
Hi Joe,
thx for the prompt reply. see below the
i have used for testing the xml below:

<?xml version='1.0' ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:fault>
<soap:code>
<soap:value>X90</soap:value>
<soap:subcode>
<soap:value>Y90</soap:value>
</soap:subcode>
</soap:code>
<soap:reason>
<soap:text>remote exception occurred during this period</soap:text>
<soap:text>This reason has been logged in our system for further
references please consult with the number ID</soap:text>
</soap:reason>
<soap:detail>
<message>3-Piece luggage set. Black Polyester</message>
<id>100</id>
</soap:detail>
</soap:fault>
</soap:Body>
</soap:Envelope>

Mar 1 '07 #3
That isn't what I asked. Yes, your input document uses namespaces. Does
the DOM display them correctly? If not, whatever's building the DOM has
to be fixed.
Mar 1 '07 #4
the code below shows how i created the DOMSource
Is there any error in it?
thx

InuputStream confiXML=StreamSource(Thread.currentThread().getCl ass()
.getClassLoader().getResourceAsStream("de/
SOAP.xml"));

DocumentBuilderFactory
documentBuilderFactory=DocumentBuilderFactory.newI nstance();
DocumentBuilder
documentBuilder=documentBuilderFactory.newDocument Builder();
Document document=documentBuilder.parse(confiXML);
DOMSource domSource=new DOMSource(document);

Mar 1 '07 #5
moralbarometer wrote:
the code below shows how i created the DOMSource
Is there any error in it?
thx

InuputStream confiXML=StreamSource(Thread.currentThread().getCl ass()
.getClassLoader().getResourceAsStream("de/
SOAP.xml"));

DocumentBuilderFactory
documentBuilderFactory=DocumentBuilderFactory.newI nstance();
// Add this line. (Arguably should be the default these days, but
// generally isn't for historical reasons of compatability with
// ancient code.)
documentBuilderFatory.setNamespaceAware(true);

DocumentBuilder
documentBuilder=documentBuilderFactory.newDocument Builder();
Document document=documentBuilder.parse(confiXML);
DOMSource domSource=new DOMSource(document);


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 1 '07 #6
Joseph Kesselman wrote:
documentBuilderFatory.setNamespaceAware(true);
Should of course have been ...Factory.set...

(Sorry. Free, typo-free, useful; pick any two.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 1 '07 #7
Hallo Joe,
Thanks alot. it works well.
have a nice weekend

Mar 2 '07 #8
Hi all,
is namespace enabled when retreiving document from SOAPMessage.
AXIS is used in this case. As shown below
DOMSource domSource=new
DOMSource(soapMsg.getSOAPEnvelope().getAsDocument( ));
thanks

Mar 5 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
22
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems...
5
by: Barry Anderberg | last post by:
I'm using a tool by Sci-Tech called the .NET Memory Profiler. We have a massive .NET/C# application here and it has been exhibiting memory leak behavior for some time. Attempting to remedy the...
17
by: Hazz | last post by:
In this sample code of ownerdraw drawmode, why does the '(ComboBox) sender' line of code need to be there in this event handler? Isn't cboFont passed via the managed heap, not the stack, into this...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
1
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
29
by: Vol | last post by:
I think 'atan' can get the angle but it is not the four quadrant angle. Is there any function that i can get the angle from -pi to pi? or I have to use some if ... else? I know in Matlab, we use...
52
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.