[jdom-interest] XSLT transformation

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Jun 19 08:32:59 PDT 2001


I would say that you XSL stylesheet produces ill-formed XML. The problem 
occurs when SAXHandler (allocated by JDOMResult) tries to build the output 
JDOM Document. Apparently, it receives some text data before the beginning of 
the root element or after the end of the root element.

Laurent

Mika Haapakorpi wrote:

> I try to do xslt conversion using following code:
> 
>                 InputStream xsl = this.getClass().getClassLoader()
>                     
> ...getResourceAsStream("com/nokia/cn/dccp/service/test/dcotest.xsl");
>                    
>                 System.out.println("xsl: " + xsl);
>                    
>                 // xsl transform XML -> XHTML:
>                 Transformer transformer = TransformerFactory.newInstance()
>                     ...newTransformer(new StreamSource(xsl));
>              
>                 JDOMResult out = new JDOMResult();
>                
>                 transformer.transform(
>                     new JDOMSource(new 
> Document(response.getElement("dcos"))), out);
>                
>                 // write to outputstream as XHTML:
>                 outputter.output(out.getDocument(), res.getOutputStream());
> 
> and i get exception:
> 
> javax.xml.transform.TransformerException: java.util.EmptyStackException
>         at 
> org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1212)
>         at 
> org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
>         at java.lang.Thread.run(Thread.java:484)
> ---------
> java.util.EmptyStackException
>         at java.util.Stack.peek(Stack.java:82)
>         at org.jdom.input.SAXHandler.characters(SAXHandler.java:483)
>         at 
> org.xml.sax.helpers.XMLFilterImpl.characters(XMLFilterImpl.java:614)
>         at 
> org.apache.xalan.transformer.ResultTreeHandler.characters(ResultTreeHandler.java:446)
>         at 
> org.apache.xalan.templates.ElemTextLiteral.execute(ElemTextLiteral.java:233)
>         at 
> org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEach.java:495)
>         at 
> org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates...java:193)
>         at 
> org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2154)
>         at 
> org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2097)
>         at 
> org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2029)
>         at 
> org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1189)
>         at 
> org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:2894)
>         at java.lang.Thread.run(Thread.java:484)
> 
> ??




More information about the jdom-interest mailing list