[Grok-dev] XML output using a page template?
cklinger at novareto.de
Wed Feb 16 06:42:31 EST 2011
you have to define the tal namespace in your template.
Hope this helps..
> Ok, I tried what you suggested. But I got the same error again:
> PTRuntimeError: ['Compilation failed', "<class 'xml.parsers.expat.ExpatError'>: unbound prefix: line 2, column 0"]
> Here's the page template code:
> <?xml version="1.0" encoding="utf-8" ?>
> <function tal:repeat="f python: context.functions" tal:attributes="name f"><span tal:replace="f"/>
> functions is a list that I want to output as XML. Any recommendations? This should be possible with a page template, shouldn't it? Or do I need to output the XML straight from the view class?
> -------- Original-Nachricht --------
>> Datum: Wed, 16 Feb 2011 09:44:12 +0100
>> Von: Jan-Wijbrand Kolman<janwijbrand at gmail.com>
>> An: grok-dev at zope.org
>> Betreff: Re: [Grok-dev] XML output using a page template?
>> On 2/16/11 8:40 AM, Sascha Boch wrote:
>>> Quick question - I'd like to use a page template to output XML data. How
>> do I do this?
>> Add an xml declaration at the top of your pt..:
>> <?xml version="1.0" encoding="utf-8" ?>
>> ..and off you go adding a root element and childs! Page templates are
>> XML themselves, basically, and are designed to render XML.
>> You might need to set the response content type header explicitly in you
>> view component, something like so..:
>> def update(self):
>> self.request.response.setHeader("Content-Type", "text/xml")
>> ..where the actual content type might of course be even more specific
>> than that.
>> regards, jw
More information about the Grok-dev