Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Does it mean source and result should both be either DOM or Stream or SAX and not mixed? Does it mean source and result should both be either DOM or Stream or SAX and not mixed?To: NULL Date: 3/1/2007 1:52:00 AM
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>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
