That will add a header to the http response, not an element to the text of the xml output. There may be an easier way to do what you want with a middleware, but the only thing I can think of is to basically prepend your desired xml header to the response text and create a new HttpResponse with that text.
Hope that helps, Peter On 4/20/10 2:57 PM, "Tim Arnold" <a_j...@bellsouth.net> wrote: > Hi, I want to serve some raw xml files, but add a stylesheet to the > response so the user can view it better. > > The raw xml begins like this: > <chapter xmlns="http://docbook.org/ns/docbook" version="5.0"> > etc. > </chapter> > > I want to create some middleware to serve them like this: > <?xml version="1.0"?> > <?xml-stylesheet type="text/css" href="/media/css/XSL/driver.css" ?> > <chapter xmlns="http://docbook.org/ns/docbook" version="5.0"> > etc. > </chapter> > > I've got this as a starting point but I have my doubts about it. Even > if it works, my guess is it will put an xml-stylesheet as an element, > not as a processing instruction. > ----------------------------------------- > css = '/media/css/XSL/driver.css' > > class XMLMiddleware(object): > def process_response(self, request, response): > if request.path.endswith('.xml'): > response['xml-stylesheet'] = css > return response > > > I haven't wired anything up to test yet; I thought I'd ask if this is > the right way to do it before going much further. > thanks, > --Tim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.