cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hippe David <dhi...@pi-ag.com>
Subject AW: Example for displaying XML by a servlet?
Date Fri, 07 Apr 2000 15:47:31 GMT
All the examples are running now!

My xsl and dtd are stored in seperate files on my server.

What I want to do now is to attach these to files to xml which is generated
by a servlet.
The generated xml should not be stored in a file but only displayed in the
browser.

Are there any hints what is missing or what the right way is to do such
things?
Does anybody know of an example to do something like this?


inspired by the example "CocoonFromServlet" i have tried something like this
but I didn't get the result I wanted because when I switched to source view
in the browser I have just seen the same code I generated here:


public class RepvaFromServlet extends HttpServlet {

    public void service(HttpServletRequest req, HttpServletResponse res)
        throws IOException, ServletException {

        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

        // Build an XML Document
        String document = "<?xml version=\"1.0\" encoding='ISO-8859-1'?>"
				
            + "<?cocoon-process type=\"xslt\"?>"
            + "<?xml-stylesheet
href=\"http://hippe.piag.com/~hippe/xml/xmlva.xsl\" type=\"text/xsl\">"
           // + "<?cocoon:format type=\"text/xslt\"?>"
	+ "<!DOCTYPE abrechnungsdoc SYSTEM
\"http://hippe.piag.com/~hippe/xml/xmlva.dtd\">"
            + "<!-- XML-CODE -->"
	+	"<abrechnungdoc>  "
	+	"	<abrechnung>    "
	+	"		<logo>PuI Wiesbaden</logo>"
	+	"			<kopf>                  "
	+	"		<pdata>                     "
	+	"			<sortk>123/xcv/manoed/lll</sortk>"
	+	"			<pname>Otto Müller</pname>        "
	+	"			<pstr>Schnepfenweg 55</pstr>       "
	:
	:
	+"</abrechnungdoc>
";

  try {
            // Get the Cocoon Engine
            //out.println("Getting an instance of the Cocoon engine...<br
/>");
            Engine cocoonEngine = Engine.getInstance();

            // Wrap my request object and add the String document to it
            //out.println("Wrapping the original request...<br />");
            CocoonServletRequest myReq =
                new CocoonServletRequest(document, req);

            // Specify some additional parmaters
            //out.println("Adding parameters to my request to Cocoon... <br
/>");
            myReq.addParameter("foo", "bar");
            myReq.addParameter("apache", "xml");

            // Pass in the real response object.  If I wanted to
            //   filter the output further, I could easily construct
            //   a CocoonServletResponse object and pass that in,
            //   and pull the output out of it.
            //out.println("Generate some content... <br />");
            cocoonEngine.handle(myReq, res);

        } catch (Exception e) {
            out.println("Error: " + e.getMessage());
        }
        //	out.println(document);

        out.close();

    }

}
     
DHippe

> -----Ursprüngliche Nachricht-----
> Von:	Robin Green [SMTP:greenrd@hotmail.com]
> Gesendet am:	Freitag, 7. April 2000 09:17
> An:	cocoon-users@xml.apache.org
> Betreff:	Re: Example for displaying XML by a servlet?
> 
> dhippe@pi-ag.com wrote:
> 
> >I tried the example in the samples directory but it doesnt work.
> >
> >Does anyone have a simple example?
> 
> If the samples don't work, your cocoon installation is probably incorrect.
> 
> First read the docs, especially the FAQ, and if you still can't get it to 
> work, tell us what you've got installed (including version numbers) and
> what 
> is outputted when you try to access the sample page.
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

Mime
View raw message