You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Thad Humphries <th...@mindwrap.com> on 2002/03/06 23:25:09 UTC
Mixing SAXSource and StreamResult?
I have an XML file and a stylesheet that work from the command line
using org.apache.xalan.xslt.Process. Now I'm trying to put do the work
via a JSP and display the results in the browser. To make things
interesting, my JSP is explicity ignoring the DTD in the XML document
because I can't count on it being around in all cases. My code looks
like this:
<%!
public class DTDResolver implements EntityResolver
{
public InputSource resolveEntity( String publicId, String systemId )
{
if ( systemId.toLowerCase().endsWith( "dtd" ) )
{
return new InputSource( new StringReader( "" ) );
}
return null;
}
};
%>
<%
byte [] docBuffer = // my XML document
byte [] xsltBuffer = // my XXL document
...
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer( new
StreamSource( new ByteArrayInputStream( xsltBuffer ) ) );
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating( false );
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.setEntityResolver( new DTDResolver() );
SAXSource source = new SAXSource( reader,
new InputSource( new ByteArrayInputStream( docBuffer ) ) );
transformer.transform( source,
new StreamResult( out ) );
%>
My problem is that the output is *just* the XML docs' text data with
none of the XSL applied. I have tested xstlBuffer and it contains my
XSL document.
What am I missing? Can I mix a SAXSource and a StreamResult in my
transformer.transform()? I've used Xalan 1 for a long while but just
got startd with Xalan 2 yesterday. My other JSPs using StreamSource and
StreamResult (and following the example
http://xml.apache.org/xalan-j/usagepatterns.html#basic) works but this
one doesn't.
Thanks!
--
------------------------------------------------------------------------
Thad Humphries "...no religious test shall ever be required
Web Development Manager as a qualification to any office or public
Phone: 540/675-3015, x225 trust under the United States." -Article VI