velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garey <gmi...@library.berkeley.edu>
Subject [Fwd: Re: Problem with referencing a stylesheet from an XML document generated by a Velocity template]
Date Fri, 08 Jun 2007 18:33:16 GMT
Nathan -

    The message below was sent inadvertently before completion. In 
extending the ViewServlet, what seems best to me is to signal the 
content-type from my logic. Stuff an attribute into the request? Any 
problems with that that you can see?


Thanks for any help;

Garey Mills


-------- Original Message --------
Subject: 	Re: Problem with referencing a stylesheet from an XML document 
generated by a Velocity template
Date: 	Fri, 08 Jun 2007 11:24:05 -0700
From: 	Garey <gmills@library.berkeley.edu>
Reply-To: 	Velocity Users List <user@velocity.apache.org>
To: 	Velocity Users List <user@velocity.apache.org>
References: 	<4669845B.3040903@library.berkeley.edu> 
<4d651da50706080945rdd28d93gfb2a4343084fa5f0@mail.gmail.com> 
<466988A1.10902@library.berkeley.edu> 
<4d651da50706081016n606d9fc7mbfe9514e725bf2a4@mail.gmail.com>



Nathan -

   I tried setting the content type from the template and no joy. I 
also tried setting the content type in the response
from my logic before passing the request off to the VelocityViewServlet. 
Also no go. I suppose that is because either a) the handoff to the 
ViewServlet is a forward so the View servlet doesn't even see my partial 
response, or b) the ViewServlet explicitly sets the content type. Since 
a) is more probable, I will probably have to extend the ViewServlet.



Nathan Bubna wrote:
> On 6/8/07, Garey <gmills@library.berkeley.edu> wrote:
>> Nathan -
>>
>>     I'm using VelocityViewServlet, but this template produces an HTML
>> form if 'binds' is not defined. Is there a
>> way to set the content type from inside the template?
>
> hmm.  the VelocityViewServlet automatically puts the
> HttpServletResponse in the context as $response.  So you could try
> calling $response.setContentType('text/xsl') from within the template.
> But i'm a little skeptical that this will work, unless perhaps it
> happens in the template before any and all content that would be
> output written to the response's writer.  In other words, try it
> however is easiest.  If that doesn't work, try to make that the very
> first thing in the template.  If that doesn't work, you will probably
> need to create your own subclass of the VelocityViewServlet and
> override a few methods to dynamically set the content type before the
> template is processed.   If it comes to that, feel free to ask for
> more details on doing that. :)
>
>> Garey
>>
>>
>>
>> Nathan Bubna wrote:
>> > This sounds like an issue with the content-type your servlet (the one
>> > processing the template) is setting on the response.  Are you using
>> > the VelocityViewServlet or your own?  if the former, are you setting
>> > the 'default.contentType' property to 'text/xsl' in your
>> > velocity.properties?  If not, then the servlet is telling your browser
>> > that it's sending 'text/html' (which is the default).
>> >
>> > On 6/8/07, Garey <gmills@library.berkeley.edu> wrote:
>> >> Hi -
>> >>
>> >>     The subject kinda says it all. Here is a snippet of my template
>> >>
>> >>
>> >> <?xml version="1.0" encoding="UTF-8" ?>
>> >> <?xml-stylesheet type="text/xsl" href="bindings.xsl" ?>
>> >>
>> >> <BindReply>
>> >>
>> >>     <Count>${count}</Count>
>> >>
>> >> #foreach($bind in ${binds})
>> >>
>> >>     <BindStatus>
>> >>         <Status>${bind.statusString}</Status>
>> >>         <ARK>ark:/${bind.noid}</ARK>
>> >>         <Message>${bind.message}</Message>
>> >>     </BindStatus>
>> >>
>> >> #end
>> >>
>> >> </BindReply>
>> >>
>> >>
>> >>
>> >>     When this generates a page that is viewed by a browser, the 
>> browser
>> >> does not apply the stylesheet. If, however,  I save the generated 
>> page,
>> >> put it where I can access it via a web server and view it, the 
>> template
>> >> is applied.
>> >>
>> >> Any suggestions on how to get the browser to apply a stylesheet to an
>> >> XML document generated by a Velocity template?
>> >>
>> >> Garey Mills
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> For additional commands, e-mail: user-help@velocity.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message