Hi --

I have a router in my createRoot method which looks like:
        router.attach("/{device}/{format}/filelist",                            
            FilelistResource.class);

The goal is to either return a file listing in one of many formats depending on 
how {format} is set (html,xml) for right now.  In my Resource constructor I set 
the MediaType to either TEXT_XML or TEXT_HTML.  

In my represent method I branch based on the type of representation I need to 
return.  I select the filelist in an xml format, immediately returning it in a 
DomRepresentation if xml.  My trouble is using the transformer to generate 
output using my xslt and xml.  
                
my represent logic looks like this for the html generation:
        
// get xml doc containing file list to show
DomRepresentation xmlRepresentation = getFileListXML();
                        
                        // need to transform to html
                        DomRepresentation xsltRepresentation = 
                                new DomRepresentation(MediaType.TEXT_XML);
                        
                        // get a factory to build a document
                        DocumentBuilderFactory factory = 
                                DocumentBuilderFactory.newInstance();
                        factory.setNamespaceAware(true);
                        
                        // create a new document builder
                        DocumentBuilder docBldr = 
                                factory.newDocumentBuilder();
                        Document xsltDoc = xsltRepresentation.getDocument();
                        
                        //xsltRepresentation.setDocument(xsltDoc);
                        // read in the xsl document
                        xsltDoc = docBldr.parse("index.xsl");
                        
                                
// create a transformer                 Transformer transformer = 
                                new Transformer(Transformer.MODE_RESPONSE,
                                                         xsltRepresentation);
                        transformer.setResultMediaType(MediaType.TEXT_HTML);
                        //DomRepresentation htmlRepresentation = 
                        return  transformer.transform(xmlRepresentation);

....
The output error is as follows
---------------
[Fatal Error] :1:55: Premature end of file.
ERROR:  'Premature end of file.'
FATAL ERROR:  'Could not compile stylesheet'


Thanks for any help.. I've been stuck on this for quite sometime and dug just 
about everywhere to find a way to use the transformer class.

Thanks

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1249166

Reply via email to