Replace DOMResult result = null; with DOMResult result = new DOMResult();
HTH, Gary > -----Original Message----- > From: Aleksi Kallio [mailto:[EMAIL PROTECTED] > Sent: Monday, July 29, 2002 11:36 PM > To: Gary L Peskin; xalan-j-users > Subject: Re: Stylesheet requires attribute: version > > > Xalan is 2.4.D1. This is my code: > > > // create a Document from XML-string > Document xmlDoc= new > DocumentBuilderFactoryImpl().newDocumentBuilder().parse(new > InputSource(new StringBufferInputStream( > "<?xml version=\"1.0\"?><root/>" > ))); > > > // create an namespace aware parse and xsl-Document from > string DocumentBuilderFactory dbf = new > DocumentBuilderFactoryImpl(); dbf.setNamespaceAware(true); > Document xslDoc= dbf.newDocumentBuilder().parse(new InputSource(new > StringBufferInputStream( > "<?xml version=\"1.0\"?> <xsl:stylesheet > xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"> > <xsl:template match=\"root\"> <out><xsl:value-of select=\".\"/></out> > </xsl:template> </xsl:stylesheet>" > ))); > > > // create Transformer and do the transform > DOMResult result = null; > Transformer transformer = > TransformerFactory.newInstance().newTransformer(new > DOMSource(xslDoc)); transformer.transform(new > DOMSource(xmlDoc), result); > > // serialise it to servlet output stream > Document resultDoc = (Document)result.getNode(); > new HTMLSerializer(response.getOutputStream(), new > OutputFormat()).serialize(resultDoc); > > > > > How are you invoking XalanJ and what version are you using? > How are > > you creating your Result? > > > > Gary > > > > > >>-----Original Message----- > >>From: Aleksi Kallio [mailto:[EMAIL PROTECTED] > >>Sent: Monday, July 29, 2002 10:57 PM > >>To: Gary L Peskin > >>Cc: 'Xalan-J-User (E-mail)' > >>Subject: Re: Stylesheet requires attribute: version > >> > >> > >>I did that and now I'm getting: > >> > >>java.lang.NullPointerException at > >>org.apache.xalan.transformer.TransformerImpl.createResultConte > >>ntHandler(TransformerImpl.java:1125) > >> at > >>org.apache.xalan.transformer.TransformerImpl.createResultConte > >>ntHandler(TransformerImpl.java:1028) > >> at > >>org.apache.xalan.transformer.TransformerImpl.transform(Transfo > >>rmerImpl.java:1143) > >> > >> > >>This exception is very uninformative and Google doesn't give > >>any hints > >>either. What could possibly be wrong? The stylesheet is the same. > >> > >> > >>>You need to use a namespace-aware parser for your stylesheet. > >>> > >>>Gary > >>> > >>> > >>> > >>>>-----Original Message----- > >>>>From: Aleksi Kallio [mailto:[EMAIL PROTECTED] > >>>>Sent: Monday, July 29, 2002 4:09 AM > >>>>To: [EMAIL PROTECTED] > >>>>Subject: Stylesheet requires attribute: version > >>>> > >>>> > >>>>I'm getting this: > >>>> > >>>>javax.xml.transform.TransformerConfigurationException: > >>>>stylesheet requires attribute: version at > >>>>org.apache.xalan.processor.TransformerFactoryImpl.newTransform > >>>>er(TransformerFactoryImpl.java:684) > >>>> > >>>> > >>>> > >>>>My stylesheet should be OK, so I just can't figure out > whats wrong. > >>>> > >>>> > >>>> > >>>>Stylesheet is: > >>>> > >>>><?xml version="1.0" encoding="UTF-8"?> > >>>><xsl:stylesheet version="1.0" > >>>>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > >>>><xsl:template match="root"> <out><xsl:value-of > >>>>select="."/></out> </xsl:template> </xsl:stylesheet> > >>>> > >>>> > >>>>(it's a single line because I've embedded it into Java code) > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>> > >> > >> > > >
