logo       

RE: Convert the result of a query after a xslt transformation: msg#00008

Subject: RE: Convert the result of a query after a xslt transformation
Hi

Did you consider looking at the javaDoc for StreamResult? 

You could try this:

// construct a writer we can easily get a String from
StringWriter paperbackWriter = new StringWriter();
// tell the stream result to dump to our writer, not sys.out
Result res = new StreamResult(paperbackWriter); 
// do all the rest you were doing
// then get your string via
paperbackWriter.toString();
// ...

-----Original Message-----
From: Pasche [mailto:pasche@xxxxxxx] 
Sent: Wednesday, 7 September 2005 10:40
To: xindice-users@xxxxxxxxxxxxxx
Subject: AW: Convert the result of a query after a xslt transformation

Hi,

the problem is that I don´t have a string. So the first question is how can I 
convert the result to a string? See m example below.

JasDA

-----Ursprüngliche Nachricht-----
Von: Yan Langlois [mailto:yan.langlois@xxxxxxx]
Gesendet: Mittwoch, 7. September 2005 00:03
An: xindice-users@xxxxxxxxxxxxxx
Betreff: Re: Convert the result of a query after a xslt transformation

Hello,

I have already done this in one of my applications. I added the string in the 
request variable:

in the Java program (servlet):
...
    public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
    {
           ...
           String htmlResponse = "Hello!";
           request.setAttribute("htmlResponse",htmlResponse);
           ...
           RequestDispatcher rd =
request.getRequestDispatcher("path/to/my/JSP/file");
           rd.forward(request,response);
    }
..

in the JSP file: <%=(String)request.getAttribute("htmlResponse")%> will
write: "Hello!"

Do not forget that the browser will interpret the String as HTML.

Yan.



Pasche wrote:

> I transform the result of a xindice query by this:
>
>  
>
> javax.xml.transform.TransformerFactory tFactory = 
> javax.xml.transform.TransformerFactory.newInstance();
>
>                                                           
>
> Result res = new StreamResult(System.out);                
>
> Source xsl = new StreamSource(stylesheet);
>
>                                                           
>
> javax.xml.transform.Transformer transformer = 
> tFactory.newTransformer(xsl);
>
> transformer.transform(src, res);
>
>  
>
> As you can see, the result of the transformation is shown in Tomcat 
> (or whatever) console (System.out). Now I want to return this result 
> as a String or whatever because this class is called from a JSP in 
> which I want to put out the result of the transformation.
>
>  
>
> Can anybody help me how I can deliver the Result to a JSP?
>
>  
>
> JasDA
>

--------------------------------------------------------------------------------------
Disclaimer:
"The information contained in this document is confidential to the addressee(s) 
and
may be legally privileged.  Any view or opinions expressed are those of the 
author
and may not be those of the organisation to which the author belongs.  No 
guarantee
or representation is made that this communication is free of errors, viruses or
interference.  If you have received this e-mail message in error please delete 
it
and notify me.  Thank you."
--------------------------------------------------------------------------------------



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe