[Grok-dev] XML output using a page template?

Sascha Boch sascha.boch at gmx.de
Wed Feb 16 05:46:21 EST 2011


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"/>
</tal:rep>

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.
> 
> HTH
> regards, jw

-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone


More information about the Grok-dev mailing list