cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: [Important] Taglib authorws: XObject
Date Sun, 03 Dec 2000 14:02:17 GMT
At 09:34 +0000 01/12/00, Ulrich Mayring wrote:
>Paul Russell wrote:
>>
>> As a quick straw poll, how many people are *already* using
>> the existing C1 XObject class in their taglibs? How many
>> people would we affect by deprecating the existing implemenation,
>> and how many people would be happy to see it move to a
>> location which is consistant with the cocoon2 architecture?
>
>I do not use XObject in my taglibs and don't even know what it is. Where
>can I read about it?


Basically I use it like this:


LogicSheet:

	<xsl:template match="blah:xobject-sample">
		<xsl:variable name="value">
			<xsl:call-template name="get-nested-content">
				<xsl:with-param name="content" select="."/>
			</xsl:call-template>
		</xsl:variable>
		<xsp:expr>new xObjectSample(<xsl:copy-of select="$value"/>)</xsp:expr>
	</xsl:template>

Java Class:

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

public class xObjectSample implements XObject{

	private Object value = null;

	// Constructor
	public xObjectSample(Object value) {
		this.value = value;
	}

	// Cocoon 1 Handler
	public void toDOM(Node node) {
		// output Elements into the DOM Node
	}

	// Cocoon 2 handler (once it is implemented ;)
	public void toSAX(DocumentHandler handler) {
		// output SAX Events
	}
}


I write a Class to handle each Tag, that implements XObject.
The logicsheet instantiates an object from the class, in this case it
passes a single parameter to the constructor, but the Class could have
other parameters/setter methods etc.

The object itself is passed to xsp:expr, the XSP Engine determines if the
Object implements XObject, if it does it calls the Object's toDOM or toSAX
method depending on whether you are in C1 or C2.

Please keep in mind that XObject is not implemented in C2 yet.

The current XObject in C1 will most likely need to be depreciated so a new
one can be made that can be added to C2.

One issue is the toSAX method using the depreciated DocumentHandler, the
other is the lack of a similar package heirarchy in C2.


Hope this helps.

regards Jeremy

-- 
   ___________________________________________________________________

   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <mailto:sharkbait@mac.com>     		 <http://www.media.demon.co.uk>
    <phone:+44.[0].20.7737.6831>        <pager:jermq@sms.genie.co.uk>

Mime
View raw message