cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajesh Aravindakshan <aravindraj...@yahoo.com>
Subject Transform Custom Generated Output
Date Thu, 14 Apr 2005 14:49:31 GMT
Hi,
I am able to get an xml output from a custom
generator.It displays in the browser as XML tree. But,
I am not able to transform the output with an xsl
stylesheet. It displays the data as text. 
What am I doing wrong. Please help. Thank you.

Here is my sitemap:
<map:match pattern="mygenerator.xml">
 <map:generate type="mygenerator">
   <map:parameter name="use-request-parameters"
value="true"/>
 </map:generate>
 <map:transform src="stylesheets/test.xsl"/>
 <map:serialize type="html"/>
</map:match>
------------------------------
Here is my custom generator code.
(Sorry for the long code)

public class MyGenerator extends AbstractGenerator {

  Request request = null;
  Enumeration paramNames = null;


public void setup(SourceResolver resolver, Map
OjectModel,String src, Parameters par)
           throws ProcessingException, SAXException,
IOException {

public void generate () throws IOException,
SAXException, ProcessingException {
try{
 SAXParserFactory spf =
SAXParserFactory.newInstance();
 spf.setValidating(false);
 SAXParser saxParser = spf.newSAXParser();
 // create an XML reader
 XMLReader reader = saxParser.getXMLReader();
   
 String message = getResponse();
 reader.setContentHandler(super.xmlConsumer);
 reader.parse(new InputSource(new
StringReader(message)));
  	} catch(Exception e){}
      /*XMLReader xmlreader =
SAXReaderFactory.createXMLReader();
      xmlreader.setContentHandler(super.xmlConsumer);
      InputSource source = new InputSource(new
StringReader(message));
      xmlreader.parse(source);*/
  }


  private String getResponse() {
	  String xmlResponse = new String();
	  String inputLine;

	  String urlstr =
"http://srv/cgi-bin/cgiip.exe/getxml.p";
      String str = "?";

	  try{
		  URL url = new URL(urlstr);
		  URLConnection  connection = url.openConnection();
		  BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));


	  	  while ((inputLine = in.readLine()) != null) {
	  	  	if (xmlResponse==null) xmlResponse = new
String();
	  	  	xmlResponse = xmlResponse + inputLine;
	  	  } // while

	  	  in.close();
	  	 } catch(Exception e){
	  	 	System.out.println("ERROR WHILE CONNECTION: " +
e.toString());
	  	    return
"<response><status>ERROR</status></response>";
	  	 }

	  	 return xmlResponse;
  }

Thanks in advance.
Rajesh Aravindakshan

Regards,
Rajesh Aravindakshan


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message