Need some help with XSL-FO attribute inheritance workaround

"Sharmila Pandith" <[email protected]> Thu, 31 Oct 2002 18:03:21 -0500
Newsgroups gmane.text.xml.jfor.general
Message-ID <[email protected]>
Hi,

I am using inherit-attributes.xsl as a workaround to solve the "BOLD"
problem. I am using JBoss Catalina 2.4.4. Here is a snippet of my code:

try
{	
     	TransformerFactory tFactory = TransformerFactory.newInstance();

	// Get the xsl:fo as the XML input 
     	javax.xml.transform.Source xmlSource = 
      new StreamSource( new StringReader(foWriter.toString()) );
      
     	javax.xml.transform.Source xslSource = null;      
     	try{
      
     		// Get the inherit-attributes.xsl as the xsl source   
		InputStream inStream = getServletContext().getResourceAsStream("/WEB-INF/plugins/inherit-attributes.xsl");       
		xslSource = new StreamSource( inStream ) ;              
  	}catch (Exception e){
    		log.info("In the xslSource statement");
     		log.error("error processing xslSource", e);
     		log.error("xslSource MESSAGE: " + e.getMessage());	  
  	}          	         
	                      
      // Generate the transformer.
      javax.xml.transform.Transformer transformer = null;
      	
      try{
      	transformer = tFactory.newTransformer(xslSource);
   	}catch (TransformerConfigurationException tce){
     		log.error("error processing newTransformer", tce);
     		log.error("xslSource MESSAGE: " + tce.getMessageAndLocation());  
	}

     	// Perform the transformation, sending the output to the response.
     	transformer.transform( xmlSource, oStreamResult );*/
    
     	// send the result to a file
	File resultFile = File.createTempFile("Streams", ".xml");
	Result result = new StreamResult(resultFile);
 
	// do the transformation
	transformer.transform(xmlSource, result);
    
    }
    // If an Exception occurs, return the error to the client.
    catch (TransformerException te)
    {
    	log.info("In the TransformerException statement");
      	log.error("error processing inherit-attributes.xsl", te);
      	log.error("MESSAGE: " + te.getMessage());
      	//e.printStackTrace(out);    
    }
    catch (Exception e)
    {
    	log.info("In the catch statement");    
    }	

Here is the error I get:
[17:22:04,715,erpro] In the newTransformer statement
[17:22:04,715,erpro] error processing newTransformer
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Document root element is missing.
	at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:767)
..................

Does anyone know what I am doing wrong? Please advice.
If anyone has this working in a jsp/servlet please send me the code.

Thanks,
S P
    



-------------------------------------------------------
This sf.net email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en