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 Aleksi Kallio <ak...@csc.fi> on 2002/07/29 13:09:24 UTC

Stylesheet requires attribute: version

I'm getting this:

javax.xml.transform.TransformerConfigurationException: stylesheet
requires attribute: version at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(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)







RE: Stylesheet requires attribute: version

Posted by Gary L Peskin <ga...@firstech.com>.
Replace
  DOMResult result = null;
with
  DOMResult result = new DOMResult();

HTH,
Gary 

> -----Original Message-----
> From: Aleksi Kallio [mailto:akallio@csc.fi] 
> 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:akallio@csc.fi]
> >>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:akallio@csc.fi]
> >>>>Sent: Monday, July 29, 2002 4:09 AM
> >>>>To: xalan-j-users@xml.apache.org
> >>>>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)
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>
> >>
> 
> 
> 


Re: Stylesheet requires attribute: version

Posted by Aleksi Kallio <ak...@csc.fi>.
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:akallio@csc.fi] 
>>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:akallio@csc.fi]
>>>>Sent: Monday, July 29, 2002 4:09 AM
>>>>To: xalan-j-users@xml.apache.org
>>>>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)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>




RE: Stylesheet requires attribute: version

Posted by Gary L Peskin <ga...@firstech.com>.
How are you invoking XalanJ and what version are you using?  How are you
creating your Result?

Gary

> -----Original Message-----
> From: Aleksi Kallio [mailto:akallio@csc.fi] 
> 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:akallio@csc.fi]
> >>Sent: Monday, July 29, 2002 4:09 AM
> >>To: xalan-j-users@xml.apache.org
> >>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)
> >>
> >>
> >>
> >>
> >>
> >>
> > 
> 
> 
> 


Re: Stylesheet requires attribute: version

Posted by Aleksi Kallio <ak...@csc.fi>.
I did that and now I'm getting:

java.lang.NullPointerException at 
org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(TransformerImpl.java:1125)
         at 
org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(TransformerImpl.java:1028)
         at 
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.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:akallio@csc.fi] 
>>Sent: Monday, July 29, 2002 4:09 AM
>>To: xalan-j-users@xml.apache.org
>>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)
>>
>>
>>
>>
>>
>>
> 




RE: Stylesheet requires attribute: version

Posted by Gary L Peskin <ga...@firstech.com>.
You need to use a namespace-aware parser for your stylesheet.

Gary

> -----Original Message-----
> From: Aleksi Kallio [mailto:akallio@csc.fi] 
> Sent: Monday, July 29, 2002 4:09 AM
> To: xalan-j-users@xml.apache.org
> 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)
> 
> 
> 
> 
> 
>