Thanks Karl. Glad to know somebody has had similar thoughts/needs.
I will try this. You're right this doesn't replace generators - but it does allow you to quite easily implement some sort of "Pull MVC" model a opposed to the generator push model - and will allow me to use my existing stylesheets mostly unchanged. Cheers Luke -----Original Message----- From: Karl �ie [mailto:[EMAIL PROTECTED]] Sent: 05 December 2001 12:49 To: [EMAIL PROTECTED] Subject: RE: Inserting / Comining XML data > 3. Maybe I could use some sort of custom URL protocol manager like the > cocoon:/ and resource:/? Is it possible to supply new instances of these? > > 4. Or I could use my URI resolvers again? Is it possible to set Custom URI > solvers in C2 i have found two ways to accomplish this, but it took some time to find out, mostly because this is not very well documented yet... ok here we go: in the "cocoon.xconf" file there is a "source-handler" entry, you can create own protocols here: <source-handler> <protocol name="cool" class="org.apache.cocoon.components.source.CoolSourceFactory"/> </source-handler> then you will have to create two classes called "org.apache.cocoon.components.source.CoolSourceFactory" and "org.apache.cocoon.components.source.CoolSource". they will have to implement "org.apache.cocoon.components.source.SourceFactory" and "org.apache.cocoon.environment.Source". Where the "CoolSourceFactory" resolves urls with cool:/some/thing.xml and creates a "CoolSource" for it. now you can refere to "cool:/some/thing.xml" many places in your project. BUT this didn't work for me because the "org.apache.cocoon.environment.Source" interface expects a org.xml.sax.InputSource and it delivers a characterstream or bytestream back, and i had a sax/dom source and i didn't want to serialize it to text to get it parsed again... so i snooped around some more and found this: again in your "cocoon.xconf" there is an entry for your default transformer. i hacked mine like this: <xslt-processor class="org.apache.cocoon.components.xslt.KarlsXSLTProcessorImpl" logger="root.xslt"> <parameter name="use-store" value="true"/> <parameter name="incremental-processing" value="false"/> </xslt-processor> then i created a class "called org.apache.cocoon.components.xslt.KarlsXSLTProcessorImpl" containing this (please not that i had to create it in the org.apache.cocoon.components.xslt package to be allowed to extend XSLTProcessorImpl) : public class XonataXSLTProcessorImpl extends XSLTProcessorImpl { public javax.xml.transform.Source resolve(String href, String base) throws TransformerException { if (!href.startsWith("karl:")) { return super.resolve(href,base); } else { SAXSource source = new SAXSource( ... ); or DOMSource source = new DOMSource( ... ); or StreamSource source = new StreamSource( ... ); return source; } } } this way i can respond and create any SAX/DOM/Stream source for any protocol for the transformer, and i can use "document('rmi://myserver/mydatachunk')" in my xsl documents. this does not replace a generator thou.... i would be happy if anyone could tell me if there is an easier way to create protocol handlers that can deliver SAX or DOM and not only Stream. mvh karl �ie --------------------------------------------------------------------- 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: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]> --------------------------------------------------------------------- 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: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>
