Hi André,

Florent André schrieb:
Now, my transformer can : - create a Lenya document
- put content (inside <content>) into the document

This two actions are now in a same "big function". And I would like to put
each action in a function : - createLenyaDocument()
- addLenyaDocContent()

So, I see different ways :
1 ------------

___Declaration :
A global lenyaDoc object in my tranformer class
void createLenyaDocument(params)
void addLenyaDocContent(dom content)

___use : createLenyaDocument(params)
addLenyaDocContent(dom content)

2 ---------------

___Declaration :
o.a.l.c.publication.Document createLenyaDocument(params)
void addLenyaDocContent(a.o.l.c.p.Document lenyadoc, params)

___use : o.a.l.c.publication.Document lenyaDoc = createLenyaDocument(params)
addLenyaDocContent(lenyadoc, params)

3 ----------------

___Declaration :
o.a.l.c.publication.Document createLenyaDocument(params)
dom.Document addLenyaDocContent(a.o.l.c.p.Document lenyadoc, params)

___use : o.a.l.c.publication.Document lenyaDoc = createLenyaDocument(params)
org.apache.lenya.cms.cocoon.source.SourceUtil.writeDOM(addLenyaDocContent(lenyadoc,
params), lenyadoc.getOutputStream());

I think either of those approaches is OK. I'd tend to prefer (2) because the signatures are clear (I'm not a fan of fields in service classes (i.e., non-data classes) because they make the service class harder to understand).

4 ---------------
Another best way ??

Since you already process a SAX stream, I'd avoid the conversion to DOM before writing the content to the document's output stream. I'd just create the document and pipe the SAX events directly into the output stream, e.g. using a serializer.

-- Andreas


--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to