You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jeff Jones <JA...@weather.com> on 2004/06/02 23:44:18 UTC

Aggregation - or is it? How do I combine multiple streams of SAX events?

I have a set of XSP/ESQL based pipelines that generate XML documents from an
Oracle database. Essentially I'm using them as a sort of customized SQL/XML
bridge, and I've been very happy with Cocoon for that purpose so far. (I'm using
Cocoon 2.1.4 on Linux, but will upgrade to 2.1.5 at some point.)

Now I'd like to combine several of those individual XML documents into a single
document. I know there are many possible approaches - map:aggregate, CInclude
transformer, XInclude, taglibs, etc, etc. I've read through the online docs and
the Cocoon Wiki, but I haven't found anything that makes sense yet.

What makes this more challenging are the following restrictions:

1. There's not one static list of sub-documents to include - it's based on the
request, with a mapping that changes fairly frequently, so I'd rather not put it
in my sitemap if I can easily avoid it.

2. I get a single key as a query parameter in the request; it's basically a ZIP
code/postal code. That's sufficient for me to query the database for the first
sub-document in the list, which contains information about that postal code,
including several mappings to primary keys of other tables. I then need to read
those mapped values from the first sub-document in order to run the queries to
get the other sub-documents.

3. I know that I will have to worry about server capacity, given the traffic
that this application will see, so I need to design efficiently. Because of
this, I want to avoid any unnecessary steps I can. In particular, I want to
include the "raw" output of my XSP/ESQL, (i.e. the streams of SAX events) rather
than serializing each document to XML only to immediately reparse it. Better
yet, I'd like to cache as many of the sub-documents as possible.

So, basically, I need to generate the first sub-document and send it down the
pipeline, but also read values out of it in order to generate and "merge in"
other streams of dynamically generated XML. I need to be able to easily specify
what pieces are included for a given request URI, and I need to do it all
without a lot of extra steps. (And while I'm wishing, I'd like a pony.)

What would be the best approach to accomplish all of this? I would very much
appreciate some suggestions, with pointers to documentation or source I should
look at. A nudge in the right direction would be a great help.

Thanks in advance!

Jeff Jones
jajones -at- weather.com
TWC Interactive



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


Re: Aggregation - or is it? How do I combine multiple streams of SAX events?

Posted by "Volkm@r" <pl...@arcor.de>.
Jeff Jones wrote:
> I have a set of XSP/ESQL based pipelines that generate XML documents from an
> Oracle database. Essentially I'm using them as a sort of customized SQL/XML
> bridge, and I've been very happy with Cocoon for that purpose so far. (I'm using
> Cocoon 2.1.4 on Linux, but will upgrade to 2.1.5 at some point.)
> 
> Now I'd like to combine several of those individual XML documents into a single
> document. I know there are many possible approaches - map:aggregate, CInclude
> transformer, XInclude, taglibs, etc, etc. I've read through the online docs and
> the Cocoon Wiki, but I haven't found anything that makes sense yet.
> 
> What makes this more challenging are the following restrictions:
> 
> 1. There's not one static list of sub-documents to include - it's based on the
> request, with a mapping that changes fairly frequently, so I'd rather not put it
> in my sitemap if I can easily avoid it.

Mapping to frequently changing sources can be done using Cinclude.
 From sitemap.xmap you may call transformer with parameters from request 
like here:
=======================================================================
<map:match pattern="**.include">
   <map:generate src="logics/includes.xsl"/>
   <map:transform src="logics/includes.xsl">
     <map:parameter name="path" value="{1}"/>
   </map:transform>
   <map:transform type="cinclude"/>
   <map:serialize type="xml"/>
</map:match>
=======================================================================

And this is "includes.xsl" putting together pieces from pipeline along 
with pieces from changing source like
         <ci:include src="{$newpath}" select="..."/>
=======================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:ci="http://apache.org/cocoon/include/1.0">
   <xsl:param name="path"/>
   <xsl:variable name="newpath">
     <xsl:value-of select="$path"/>
     <xsl:if test="$path=''">index.html</xsl:if>
     <xsl:if test="substring($path, string-length($path), 1) = '/' ">
       index.html
     </xsl:if>
   </xsl:variable>
   <xsl:template match="/">
     <html>
       <head>
         <ci:include src="{$newpath}"
                     select="//*[local-name()='head']/*"/>
         <ci:include src="cocoon:/{$newpath}.navtoolbar"
                     select="links/*"/>
       </head>
       <body>
         <ci:include src="cocoon:/{$newpath}.linkmap"/>
         <div id="content">
           <ci:include src="{$newpath}"
                       select="//*[local-name()='body']/*"/>
         </div>
       </body>
     </html>
   </xsl:template>
</xsl:stylesheet>
=======================================================================

HTH
--
Volkmar  W.  Pogatzki


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