cocoon-users mailing list archives

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

Ok - In the previous supplied link
(http://www.aoindustries.com/docs/cocoon-1.8.2/faqs.html#faq-xspinsertxml)
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
Søren

-----Oprindelig meddelelse-----
Fra: Karl Øie [mailto:karl@gan.no]
Sendt: 13. november 2001 04:57
Til: cocoon-users@xml.apache.org
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 [mailto:karl@gan.no]
Sent: 13. november 2001 13:50
To: cocoon-users@xml.apache.org
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:

<xsp:logic>
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 ) {
	aaaaarrrrrggggg!!!
	}
</xsp:logic>

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 [mailto:s.neigaard@mobilethink.dk]
Sent: 13. november 2001 22:32
To: cocoon-users@xml.apache.org; karl@gan.no
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">
	<xsp:logic>
		SAXSource msg = Controller.execute();
	</xsp:logic>
	<xsp:expr>msg</xsp:expr>
</xsl:template>
------------------

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
Søren

-----Oprindelig meddelelse-----
Fra: Karl Øie [mailto:karl@gan.no]
Sendt: 13. november 2001 03:03
Til: cocoon-users@xml.apache.org
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
calls.

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(javax.xml.transform.stream.StreamSource), 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 [mailto:s.neigaard@mobilethink.dk]
Sent: 13. november 2001 20:30
To: cocoon-users@xml.apache.org
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:
http://www.aoindustries.com/docs/cocoon-1.8.2/faqs.html#faq-xspinsertxml

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:
http://java.sun.com/xml/jaxp/dist/1.1/docs/api/, but what object should I
return? What is it excactly C2 accepts as input? Is it a
"javax.xml.transform.sax.SAXSource"?

Please just give a few pointers :)

Med venlig hilsen/Best regards
Søren Neigaard
System Architect
................................
Mobilethink A/S
Arosgaarden
Åboulevarden 23, 5.sal
DK - 8000 Århus C
Telefon: +45 86207800
Direct: +45 86207810
Fax: +45 86207801
Email: s.neigaard@mobilethink.dk
Web: www.mobilethink.dk
................................


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message