Joe Kesselman wrote:
Quote:
I don't know about JSPs, but the JAXP/TrAX APIs *should* transform from
any of the Source variants to any of the Result classes. This sounds
like a bug -- either in how you're configuring these processing stages,
or perhaps you're using an out-of-date version of the code.
>
Reminder: If you want to put a DOM, or a pre-parsed SAX event stream,
through XSLT you need to be *very* sure you've turned on all the
relevant namespace features of the parser.
>
To say more than that I'd have to see the code. I don't do JSPs, but
presumably the stuff that's failing can also be demonstrated in a
one-page stand-alone example...?
|
Below is a snippet of the relevant code. If I comment out the
DOMResult line and
uncomment the line below it it works fine. With the DOMResult line I
get the
EmptyStackException. The XML that it's trying to process as a result
of the call
to the other server is tacked on the end.
String strXML = "http://myserver.com/whatever";
String strXSL = "path/to/my.xsl";
URL url = new URL(strXML);
StreamSource xml=null;
try
{
xml = new StreamSource(url.openStream());
StreamSource xsl = new StreamSource(strXSL);
//StreamResult result = new StreamResult(out);
DOMResult result = new DOMResult();
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xsl);
transformer.transform(xml, result);
if ( xml != null )
{
Reader xmlReader = xml.getReader();
if ( xmlReader != null )
{
out.print(xmlReader.toString());
}
}
}
catch ( Exception e )
{
out.print( "<br/><b>Forms and publications search is" +
" currently unavailable. Please contact the" +
" administrator if problem persists.</b>" );
//e.printStackTrace(new PrintWriter(out));
}
XML it's trying to process looks like this. This is not something I
can modify, btw,
as it's from an off-the-shelf search aggregator.
<?xml version="1.0" encoding="UTF-8"?>
<searchdoc>
<results hits="31" time="0.01" query="keywords:vwadocument AND work"
suggest="" filter="" sort="relevance" start="1" end="10"
currentpage="1" lastpage="4" startdate="0" xsl="xml">
<result no="1">[...]</result>
[...etc...]
</results>
</searchdoc>