[Seaside] Seaside with XML output?
philippe.marschall at gmail.com
Tue Aug 15 08:58:58 UTC 2017
On Mon, Aug 14, 2017 at 9:59 PM, StormByte <stormbyte at gmail.com> wrote:
> I am trying to use Seaside for output XML on some components (not all),
> but I am having problems with it, this way, I am trying to create a
> minimal component which its own purpose is to output generated XML directly.
> I red the mailing list and found some interesting info, but mainly for
> output a XML file, or create an XML on the fly to be downloaded via an
> anchor click, but that is different that what I need, which is to output
> XML directly (instead of HTML).
> The best approach seems to be subclassing WARequestHandler, but then,
> how can I use it inside my new minimal example to play with and test?
> Like, for example having a method rendererClass returning my own canvas
> to render.
I think in your case it's best to take a gradual approach. Here's what
I would do:
1. start with subclassing WARequestHandler
aRequestContext respond: [ :response |
contentType: (WAMimeType main: 'text' sub: 'xml');
nextPutAll: '<xml/>' ]
This returns static XML (you can change it to be XML in your schema).
This is simply to get you started so you can experiment.
2. Use Magritte XML or WAXmlCanvas to generate the XML, so you can
have dynamic XML. There are other options, but these are common ones.
If you decide to go with WAXmlCanvas
render: [ :xml |
with: 'the-content' ]
Then you probably want to implement a custom canvas for your XML
dialect. Have a look at RRRssRenderCanvas from Seaside-RSS on how to
3. Decide on with component model you want to use. I don't really know
what your use case is so it's hard to tell. If your building a REST
interface the obvious choice is Seaside-REST. If you want to go with
components have a look at RRComponent from Seaside-RSS. It is also
possible to combine the two approaches, fire up an XML canvas in a
Seaside-REST request handler and let it render a painter.
This probably requires some experimentation from your side to figure
out what fits best your needs.
More information about the seaside