cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject Re: XObjects / document fragments
Date Thu, 21 Sep 2000 09:04:43 GMT
At 16:27 +0200 20/09/00, Echoes wrote:
>  Hello,
> I'm trying to insert in the output tree the
>value of some attributes from a java object.
>I can do this in the xsp page with this kind of
>code :
> It's alright when there is only a few fields, but becomes a nightmare
>with complex objects.
> I heard about document fragments and XObjects that can do the job in
>a cleaner way, but I can't find any description, or better a small

I have been using XObject for implementing TagLibs, this is an untested and
trivial example of the general technique.

in your xsp:

<xsp:expr>new myObject()</xsp:expr>

import org.apache.cocoon.framework.XObject;
import org.w3c.dom.*;
import org.xml.sax.*;

public class myObject() implements XObject {

	String message = new String("you got me Geeza!");

	public myObject() {
		// set me up

	public void toDOM(Node node) {
		// this is used by C1
		Document doc = node.getOwnerDocument();

	public void toSAX(DocumentHandler handler) {
		// this is used by C2
		// and I do not know how to write it yet :)

	public String toString() {
		// used by <xsp:attribute name="blah">new myObject()</xsp:attribute>
		return message;


Hope this helps.

regards Jeremy


   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <>     		 <>
    <phone:+44.[0].20.7737.6831>        <>

View raw message