You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rajesh Aravindakshan <ar...@yahoo.com> on 2005/04/14 17:42:52 UTC
Transform Custom Generated Output [Scanned]
Sorry forgot to add the following:
Cocoon: 2.1.6 on Windows
--------------------------------
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.
Regards,
Rajesh Aravindakshan
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org