cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Neigaard <>
Subject SV: SAX tree?
Date Tue, 13 Nov 2001 22:12:54 GMT
Well... Hmm... But..??

Ok - In the previous supplied link
it seemed (to me anyway) that I could give C2 a DOM/SAX source directly, and
C2 then could work on this. Can I, and how?

Ok - If not, what to do then? How do I do the things you talk about (the
offical writer that can write to the xsp page, or even better, the parent
SAXHandler for the xsp page)? The XML I return is actually a XML fragment,
and is only part of a bigger XML document C2 should process.

Basicly I don't know what to do, so please aid me :)

Mvh/Best regards

-----Oprindelig meddelelse-----
Fra: Karl Øie []
Sendt: 13. november 2001 04:57
Emne: RE: SAX tree?

obviously I cant type right, the SAXSource msg is supposed to be used in the
transform command, not the undeclared mystic source variable....

transformer.transform( msg, result );

mvh karl øie

-----Original Message-----
From: Karl Øie []
Sent: 13. november 2001 13:50
Subject: RE: SAX tree?

yes, the SAX source is useless without any handler, what you are looking for
is perhaps to serialize this to xml. i havent yet looked at xsp actually,
but here is one approach that might create xml from a SAX source inside a
xsp page:

try {
	TransformerFactory factory = TransformerFactory.newInstance();
	Transformer transformer = factory.newTransformer();

	SAXSource msg = Controller.execute();
	StreamResult result = new StreamResult( new PrintWriter(System.out) );
	//SAXResult result = new SAXHandler( xspsuperparent.handler );

	transformer.transform( source, result );
catch( Exception e ) {

as i said, i havent yet written one single line of xsp myself, but this
might work, what happens here is that the sax source msg is transformed
without a stylesheet to the system.out pipe, this should be replaced with
the offical writer that can write to the xsp page, or even better, the
parent SAXHandler for the xsp page. you might find some info here in the
list or at the homepage how to get tre transformation to stream directly
into your xsp page.

hope this helped a little! :-)

mvh karl

-----Original Message-----
From: Søren Neigaard []
Sent: 13. november 2001 22:32
Subject: SV: SAX tree?

Oh - Thanks for clearing this out for me :)

Now my Java method returns a "javax.xml.transform.sax.SAXSource", and I put
this in my logicsheet like this:

<xsl:template match="pim:controller">
		SAXSource msg = Controller.execute();

But this prints out "javax.xml.transform.sax.SAXSource@7b56e", which looks
like a reference the object. Do you have any idea what I'm doing wrong here?

Best regards

-----Oprindelig meddelelse-----
Fra: Karl Øie []
Sendt: 13. november 2001 03:03
Emne: RE: SAX tree?

there is no such thing as a SAX tree, if it is a tree it is a DOM tree.

SAX is an interface that generates event streams, like when you parse a xml
file with sax the sax parser would fire events like startDocument(),
startElement(), endElement(), endDocument() in a succession of function

DOM creates a tree of nodes much like an unbalanced b-tree where every node
represents a element, atrribute and visa versa.

DOM is then again mosty buildt up by a SAX parser, because you could taje
the events from the SAX parser and create the corresponding nodes when the
event functions tells you so.

the javax.xml.transform.sax.SAXSource is junction between thes two ways of
processing xml because a SAXSource could be a stream of
ascii(, a stream of SAX events
(javax.xml.transform.sax.SAXSource) or a DOM tree
javax.xml.transform.dom.DOMSource. all of these can be a
javax.xml.transform.Source to create SAX events which is what cocoon2 likes
to eat.

Cocoon2s generators are in general just routines that creates SAX events
from various sources. if you have a Document object in memory, you can pass
it to cocoon2 through "DOMStreamer", a utility class in cocoon2 that
generates SAX events from a DOM source.

to make a long story short, DOM is xml nodes in memory as nodes in a b-tree,
while SAX is just function events that pass by a api and never leaves
anything in memory, SAX leaves the responsability of creating memory objects
if required to the SAX Handler.

hope this helped a bit! :-)

mvh karl øie

-----Original Message-----
From: Søren Neigaard []
Sent: 13. november 2001 20:30
Subject: SAX tree?

This subject is a little offtopic :)

Ok I will try to return a SAX tree to C2 instead of a stream of XML. I found
the following link that talks about this:

Now I'm not a XML shark, so I could need some help doing this. I guess I
will be using this API to create a SAX tree:, but what object should I
return? What is it excactly C2 accepts as input? Is it a

Please just give a few pointers :)

Med venlig hilsen/Best regards
Søren Neigaard
System Architect
Mobilethink A/S
Åboulevarden 23, 5.sal
DK - 8000 Århus C
Telefon: +45 86207800
Direct: +45 86207810
Fax: +45 86207801

Please check that your question has not already been answered in the
FAQ before posting. <>

To unsubscribe, e-mail: <>
For additional commands, e-mail: <>

View raw message